junyuanz лет назад: 5
Родитель
Сommit
a00461661c

+ 1 - 1
packageUser/pages/user/orders/orders.wxml

@@ -20,7 +20,7 @@
         <view class="order-main" wx:for="{{item.product_list}}" wx:for-item="nitem">
           <image class="order-main__left" src="{{nitem.cover}}"></image>
           <view class="order-main__right">
-            <view class="order-info__title ellipsisLn">{{nitem.name}}</view>
+            <view class="order-info__title ellipsisLn">{{nitem.name}} <span wx:if="{{nitem.color_name || nitem.size_name}}">|</span> {{nitem.color_name}} {{nitem.size_name}}</view>
             <!-- <view class="order-info__type ellipsis">{{nitem.detail}}</view> -->
             <view class="order-info__price">
               <currency symbol="¥" value="{{nitem.price}}" wx:if="{{item.status === 'unpay'}}" />

+ 1 - 1
pages/cart/cart.wxml

@@ -27,7 +27,7 @@
 		        <image src="{{item.cover}}" />
 		      </view>
 		      <view class="cartlist_info">
-		        <view class="cartlist_title">{{item.product_name}}</view>
+		        <view class="cartlist_title">{{item.product_name}} <span wx:if="{{item.color_name || item.size_name}}">|</span> {{item.color_name}} {{item.size_name}}</view>
 		        <view class="cartlist_type">---</view>
 		        <currency class="cartlist_price" symbol="¥" value="{{item.original_price}}" />
 		        <view class="cartlist_num">

+ 1 - 1
pages/pay/pay.wxml

@@ -25,7 +25,7 @@
       <image class="pay-project-img" src="{{item.cover}}"></image>
       <view class="pay-project-info">
         <text class="pay-project-title ellipsisLn">{{item.name}}</text>
-        <!-- <text class="pay-project-spec">规格</text> -->
+        <text class="pay-project-spec" wx:if="{{item.color_name || item.size_name}}">规格:{{item.color_name}} {{item.size_name}}</text>
         <view class="product-info">
           <view class="pay-project-price fl">
             <currency symbol="¥" value="{{item.price}}"/>

+ 64 - 2
pages/projects/project-detail/project-detail.js

@@ -37,7 +37,11 @@ Page({
     // msecond: '00',
     clock: '',
     todaysend: Date.parse(new Date()) / 1000,
-    showpay: true
+    showpay: true,
+    productSize:'',//产品规格
+    size_list:0,
+    color_list:0,
+    canpay:true
   },
   onLoad: function (options) {
     this.data.productId = options.id;
@@ -147,9 +151,45 @@ Page({
       if (val.data.seckill_state == 'seckill') {
         that.starttime()
       }
+      
+      if(val.data.have_size){
+      	that.getProductSize();
+      }
     }
     _request.$get(url, params, success)
   },
+  getProductSize(){
+  	var that = this
+    var url = "v1/product_size/" + that.data.productId;
+    var params = {}
+    var success = function (val) {
+      that.setData({
+        productSize: val.data,
+      });
+    }
+    _request.$get(url, params, success)
+  },
+  getProductDetail () {
+    var that = this;
+    console.log(that.data.size_list);
+    console.log(that.data.color_list);
+    var url = "v1/product_detail/" + that.data.productId + "/" + that.data.size_list + "/" + that.data.color_list;
+    var params = {}
+    var success = function (val) {
+			console.log('val',val)
+			that.setData({
+				canpay:true,
+				project:val.data,
+				productId:val.data.id
+			})
+    }
+    var fail = function(err){
+    	that.setData({
+				canpay:false
+			})
+    }
+    _request.$get(url, params, success, fail)
+  },
   add: function () {
     if (this.data.count < this.data.project.left_count) {
       var count = this.data.count + 1
@@ -309,7 +349,8 @@ Page({
     }
   },
   addCart:function(){
-  	var that = this
+  	var that = this;
+  	console.log('that.data.productId',that.data.productId)
     var url = "v1/cart/" + that.data.productId + "/" + that.data.count
     var params = {}
     var success = function (res) {
@@ -635,4 +676,25 @@ Page({
       },100),
     });
   },
+  checkSize(event){
+  	var type = event.currentTarget.dataset.type;
+  	var id = event.currentTarget.dataset.id;
+  	var list = event.currentTarget.dataset.list;
+		var that = this;
+		
+		var reproduct = this.data.productSize;
+//		console.log('reproduct',reproduct)
+		for(var i in reproduct[type]['attr_values']){
+//			console.log('reproduct[type][i].is_select',reproduct[type]['attr_values'][i].is_select)
+			reproduct[type]['attr_values'][i].is_select = false;
+			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
+	 })
+//		console.log('that.data[type]',that.data[type])
+  	that.getProductDetail();
+  }
 })

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

@@ -173,8 +173,21 @@
         </view>
         <view class="clean"></view>
       </view>
+      
+      <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>
+      </view>
+      
+      
       <form bindsubmit="pay" report-submit="{{true}}" >
-        <button class="dialog-btn" formType="submit" wx:if="{{showpay}}">立即购买</button>
+        <button class="dialog-btn" formType="submit" wx:if="{{showpay}}" disabled="{{!canpay?'true':''}}">立即购买</button>
       </form>
       <button class="dialog-btn" open-type="share" wx:if="{{!showpay}}">立即购买</button>
     </view>
@@ -208,7 +221,19 @@
         </view>
         <view class="clean"></view>
       </view>
-      <button class="detail-yellow" bindtap="addCart" style="width:100%">加入购物车</button>
+      
+      <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>
+      </view>
+      
+      <button class="detail-yellow" bindtap="addCart" style="width:100%" disabled="{{!canpay?'true':''}}">加入购物车</button>
     </view>
   </view>
   <view class="detail-dialog" bindtap="toCart"></view>

+ 15 - 0
pages/projects/project-detail/project-detail.wxss

@@ -580,4 +580,19 @@ margin-right: 2px;
 
 .wxParse-p image{
 	width:100% !important;
+}
+
+.sizeTitle{display: block;}
+.checkList{display: inline-block;}
+.checkList span{
+display: inline-block;
+padding: 15rpx;
+margin: 15rpx;
+text-align: center;
+min-width: 45rpx;
+background: #eee;
+}
+.checkList span.active{
+	background:#eab86a;
+	color:#FFF;
 }

+ 3 - 3
project.config.json

@@ -14,15 +14,15 @@
 		"checkInvalidKey": true,
 		"checkSiteMap": true,
 		"uploadWithSourceMap": true,
-		"compileHotReLoad": false,
 		"babelSetting": {
 			"ignore": [],
 			"disablePlugins": [],
 			"outputPath": ""
 		},
-		"useIsolateContext": true,
 		"useCompilerModule": false,
-		"userConfirmedUseCompilerModuleSwitch": false
+		"userConfirmedUseCompilerModuleSwitch": false,
+		"compileHotReLoad": false,
+		"useIsolateContext": true
 	},
 	"compileType": "miniprogram",
 	"libVersion": "2.0.7",

+ 1 - 0
utils/request.js

@@ -19,6 +19,7 @@ function $get (url, params, success, fail) {
       callBack(res, success, fail)
     },
     fail: function (res) {
+    	callBack(res)
     },
     complete: function (res) {
       wx.hideNavigationBarLoading()