junyuanz 5 роки тому
батько
коміт
3bec123155

+ 45 - 12
pages/projects/project-detail/project-detail.js

@@ -41,7 +41,11 @@ Page({
     productSize:'',//产品规格
     size_list:0,
     color_list:0,
-    canpay:true
+    cname:'',
+    sname:'',
+    canpay:true,
+    checkbox:'',
+    noproduct:false
   },
   onLoad: function (options) {
     this.data.productId = options.id;
@@ -163,8 +167,15 @@ Page({
     var url = "v1/product_size/" + that.data.productId;
     var params = {}
     var success = function (val) {
+    	let cbox = [];
+    	for(let i in val.data){
+    		if(i != 'product') cbox.push(i);
+    	}
+    	console.log('cbox',cbox)
       that.setData({
         productSize: val.data,
+        canpay:false,
+        checkbox:cbox
       });
     }
     _request.$get(url, params, success)
@@ -177,16 +188,28 @@ Page({
     var params = {}
     var success = function (val) {
 			console.log('val',val)
-			that.setData({
-				canpay:true,
-				project:val.data,
-				productId:val.data.id
-			})
+			if(val.data.product){
+				that.setData({
+					canpay:true,
+					project:val.data.product,
+					productId:val.data.product.id,
+					noproduct:false
+				})
+				that.setData({
+					canpay:true,
+					project:val.data.product,
+					productId:val.data.product.id,
+					noproduct:false
+				})
+			}else{
+				that.setData({
+					canpay:false,
+					noproduct:true
+				})
+			}
     }
     var fail = function(err){
-    	that.setData({
-				canpay:false
-			})
+    	
     }
     _request.$get(url, params, success, fail)
   },
@@ -680,8 +703,9 @@ Page({
   	var type = event.currentTarget.dataset.type;
   	var id = event.currentTarget.dataset.id;
   	var list = event.currentTarget.dataset.list;
+  	var tname = event.currentTarget.dataset.tname;
 		var that = this;
-		
+		var tkey = type=='color_list'?'cname':'sname';
 		var reproduct = this.data.productSize;
 //		console.log('reproduct',reproduct)
 		for(var i in reproduct[type]['attr_values']){
@@ -690,11 +714,20 @@ Page({
 			if(reproduct[type]['attr_values'][i].id == id) reproduct[type]['attr_values'][i].is_select = true;
 		}
 //		console.log('reproduct',reproduct)
+		
 		that.setData({
 			productSize :reproduct,
-			[type]:id
+			[type]:id,
+			[tkey]:tname
 	 })
 //		console.log('that.data[type]',that.data[type])
-  	that.getProductDetail();
+		let cflag = true;
+		for(let i in that.data.checkbox){
+			if(that.data[that.data.checkbox[i]] == 0) cflag = false;
+		}
+		if(cflag){
+  		that.getProductDetail();
+		}
+
   }
 })

+ 27 - 20
pages/projects/project-detail/project-detail.wxml

@@ -153,13 +153,15 @@
       <image class="dialog-cancel" src="http://fohow.oss-cn-shenzhen.aliyuncs.com/xcx/image/cancel.png" bindtap="toPay"></image>
       <view class="dialog-content">
         <image class="dialog-img" src="{{project.pics[0].img}}"></image>
-        <view class="dialog-info">
-          <view class="dialog-word dialog-red">
+        
+        <view class="dialog-info" style="margin-top: 20rpx;">
+          <h6 style="font-size: 35rpx;font-weight: bold;color: #666;">{{project.name}}</h6>
+          <view class="dialog-word dialog-black" style="margin-top: 15rpx;color: #999;">库存{{project.left_count}}件   <text wx:if="{{project.have_size && (sname || cname)}}">(已选:{{cname}} {{sname}})</text></view>
+          <view class="dialog-word dialog-red" style="font-size: 35rpx;margin-top: 25rpx;">
             <!-- {{project.price}}代金券 -->
             <currency symbol="¥" value="{{project.price}}"></currency>
           </view>
           <!-- <view class="dialog-word dialog-gray">或{{project.price}}代金券</view> -->
-          <view class="dialog-word dialog-black">库存{{project.left_count}}件</view>
         </view>
         <view class="clean"></view>
       </view>
@@ -176,20 +178,22 @@
       
       <view wx:if="{{project.have_size}}" class="select-count">
       	<view wx:for="{{productSize}}" wx:for-item="i" wx:key="{{index}}">
-			<h5 class="sizeTitle">{{i.name}}</h5>
-			<view wx:for="{{i.attr_values}}" wx:for-index="index2" wx:for-item="j" class="checkList">
-				<span bindtap="checkSize" data-type='{{index}}' data-list="{{index2}}" data-id="{{j.id}}" class="{{j.is_select?'active':''}}">
-				{{j.name}}
-				</span>
+      		<view wx:if="{{index != 'product'}}">
+				<h5 class="sizeTitle">{{i.name}}</h5>
+				<view wx:for="{{i.attr_values}}" wx:for-index="index2" wx:for-item="j" class="checkList">
+					<span bindtap="checkSize" data-type='{{index}}' data-tname="{{j.name}}" data-list="{{index2}}" data-id="{{j.id}}" class="{{j.is_select?'active':''}}">
+					{{j.name}}
+					</span>
+				</view>
 			</view>
         </view>
       </view>
       
       
       <form bindsubmit="pay" report-submit="{{true}}" >
-        <button class="dialog-btn" formType="submit" wx:if="{{showpay}}" disabled="{{!canpay?'true':''}}">立即购买</button>
+        <button class="dialog-btn" formType="submit" wx:if="{{showpay}}" disabled="{{!canpay?'true':''}}"><text wx:if="{{!noproduct}}">立即购买</text><text wx:if="{{noproduct}}">暂无库存</text></button>
       </form>
-      <button class="dialog-btn" open-type="share" wx:if="{{!showpay}}">立即购买</button>
+      <button class="dialog-btn" open-type="share" wx:if="{{!showpay}}"><text wx:if="{{!noproduct}}">立即购买</text><text wx:if="{{noproduct}}">暂无库存</text></button>
     </view>
   </view>
   <view class="detail-dialog" bindtap="toPay"></view>
@@ -201,13 +205,14 @@
       <image class="dialog-cancel" src="http://fohow.oss-cn-shenzhen.aliyuncs.com/xcx/image/cancel.png" bindtap="toCart"></image>
       <view class="dialog-content">
         <image class="dialog-img" src="{{project.pics[0].img}}"></image>
-        <view class="dialog-info">
-          <view class="dialog-word dialog-red">
+        <view class="dialog-info" style="margin-top: 20rpx;">
+          <h6 style="font-size: 35rpx;font-weight: bold;color: #666;">{{project.name}}</h6>
+          <view class="dialog-word dialog-black" style="margin-top: 15rpx;color: #999;">库存{{project.left_count}}件   <text wx:if="{{project.have_size && (sname || cname)}}">(已选:{{cname}} {{sname}})</text></view>
+          <view class="dialog-word dialog-red" style="font-size: 35rpx;margin-top: 25rpx;">
             <!-- {{project.price}}代金券 -->
             <currency symbol="¥" value="{{project.price}}"></currency>
           </view>
           <!-- <view class="dialog-word dialog-gray">或{{project.price}}代金券</view> -->
-          <view class="dialog-word dialog-black">库存{{project.left_count}}件</view>
         </view>
         <view class="clean"></view>
       </view>
@@ -224,16 +229,18 @@
       
       <view wx:if="{{project.have_size}}" class="select-count">
       	<view wx:for="{{productSize}}" wx:for-item="i" wx:key="{{index}}">
-			<h5 class="sizeTitle">{{i.name}}</h5>
-			<view wx:for="{{i.attr_values}}" wx:for-index="index2" wx:for-item="j" class="checkList">
-				<span bindtap="checkSize" data-type='{{index}}' data-list="{{index2}}" data-id="{{j.id}}" class="{{j.is_select?'active':''}}">
-				{{j.name}}
-				</span>
-			</view>	
+			<view wx:if="{{index != 'product'}}">
+				<h5 class="sizeTitle">{{i.name}}</h5>
+				<view wx:for="{{i.attr_values}}" wx:for-index="index2" wx:for-item="j" class="checkList">
+					<span bindtap="checkSize" data-type='{{index}}' data-tname="{{j.name}}" data-list="{{index2}}" data-id="{{j.id}}" class="{{j.is_select?'active':''}}">
+					{{j.name}}
+					</span>
+				</view>
+			</view>
         </view>
       </view>
       
-      <button class="detail-yellow" bindtap="addCart" style="width:100%" disabled="{{!canpay?'true':''}}">加入购物车</button>
+      <button class="detail-yellow" bindtap="addCart" style="width:100%" disabled="{{!canpay?'true':''}}"><text wx:if="{{!noproduct}}">加入购物车</text><text wx:if="{{noproduct}}">暂无库存</text></button>
     </view>
   </view>
   <view class="detail-dialog" bindtap="toCart"></view>

+ 4 - 4
pages/projects/project-detail/project-detail.wxss

@@ -106,8 +106,7 @@
   width: 282rpx;
   color: #fff;
   line-height: 88rpx;
-  background: -webkit-linear-gradient(left, #ffc72f, #ffa729);
-  background: linear-gradient(to right, #ffc72f, #ffa729);
+  background:#eab86a;
 }
 .detail-red {
   color: #fff;
@@ -582,15 +581,16 @@ margin-right: 2px;
 	width:100% !important;
 }
 
-.sizeTitle{display: block;}
+.sizeTitle{display: block;font-size:24rpx}
 .checkList{display: inline-block;}
 .checkList span{
 display: inline-block;
-padding: 15rpx;
+padding: 12rpx;
 margin: 15rpx;
 text-align: center;
 min-width: 45rpx;
 background: #eee;
+font-size:24rpx;
 }
 .checkList span.active{
 	background:#eab86a;