Jelajahi Sumber

加入购物车时选择领域

zhaoxiaohai 3 tahun lalu
induk
melakukan
5fc056ecb7
3 mengubah file dengan 17 tambahan dan 12 penghapusan
  1. 13 8
      packageA/market/detail.js
  2. 3 1
      packageA/market/detail.wxml
  3. 1 3
      packageA/market/index.js

+ 13 - 8
packageA/market/detail.js

@@ -95,21 +95,29 @@ Page({
     });
     });
     this.getDetail();
     this.getDetail();
   },
   },
+  clickBut() {
+    wx.showToast({
+      title: '请选择加入产品领域',
+      icon: "none",
+      duration: 3000
+    })
+  },
   /* 加入购物车 */
   /* 加入购物车 */
-  storage() {
+  storage(e) {
+    let detail = this.data.detail;
     _Http.basic({
     _Http.basic({
       "id": 20220924095102,
       "id": 20220924095102,
       "content": {
       "content": {
-        "sa_brandid": this.data.detail.brand[0].sa_brandid, //品牌id
-        "itemid": this.data.detail.itemid, //货品id
+        "sa_brandid": detail.brand[0].sa_brandid, //品牌id
+        "itemid": detail.itemid, //货品id
         "qty": 1, //数量
         "qty": 1, //数量
         "itemno": this.data.itemno, //货品编号
         "itemno": this.data.itemno, //货品编号
-        tradefield: this.data.detail.tradefield[0].tradefield
+        tradefield: detail.tradefield[e.detail.value].tradefield
       },
       },
     }).then(res => {
     }).then(res => {
       console.log("加入购物车", res)
       console.log("加入购物车", res)
       wx.showToast({
       wx.showToast({
-        title: res.msg != '成功' ? res.msg : '已加入到购物车',
+        title: res.msg != '成功' ? res.msg : '已将产品加入到购物车',
         icon: "none"
         icon: "none"
       });
       });
       if (res.msg == '成功') _Http.basic({
       if (res.msg == '成功') _Http.basic({
@@ -125,7 +133,4 @@ Page({
   onShow() {
   onShow() {
     this.selectComponent("#Float").setNum(getApp().globalData.num)
     this.selectComponent("#Float").setNum(getApp().globalData.num)
   },
   },
-  onReady() {
-
-  }
 })
 })

+ 3 - 1
packageA/market/detail.wxml

@@ -83,7 +83,9 @@
 <!-- 底部 -->
 <!-- 底部 -->
 <view style="height: 150rpx;" />
 <view style="height: 150rpx;" />
 <view class="footer">
 <view class="footer">
-	<van-button custom-class='but' bindtap="storage">加入购物车</van-button>
+	<picker range='{{detail.tradefield}}' range-key='tradefield' bindchange='storage'>
+		<van-button custom-class='but' bindtap="clickBut">加入购物车</van-button>
+	</picker>
 </view>
 </view>
 
 
 <!-- 购物车按钮 -->
 <!-- 购物车按钮 -->

+ 1 - 3
packageA/market/index.js

@@ -35,7 +35,6 @@ Page({
 			cType: detail.item,
 			cType: detail.item,
 			typeList
 			typeList
 		});
 		});
-		this.setListHeight();
 		this.getList(true);
 		this.getList(true);
 	},
 	},
 	/* 获取品牌 */
 	/* 获取品牌 */
@@ -71,7 +70,6 @@ Page({
 				"cType": res.data[0].ttemclass[0]
 				"cType": res.data[0].ttemclass[0]
 			});
 			});
 			this.getList(true);
 			this.getList(true);
-			this.setListHeight()
 		})
 		})
 	},
 	},
 	/* 获取产品 */
 	/* 获取产品 */
@@ -82,7 +80,6 @@ Page({
 		if (content.pageNumber > content.pageTotal) return;
 		if (content.pageNumber > content.pageTotal) return;
 		content.brandids = [this.data.brand.sa_brandid];
 		content.brandids = [this.data.brand.sa_brandid];
 		content.where.itemclassid = this.data.cType.itemclassid;
 		content.where.itemclassid = this.data.cType.itemclassid;
-
 		_Http.basic({
 		_Http.basic({
 			"id": 20220926142203,
 			"id": 20220926142203,
 			content
 			content
@@ -96,6 +93,7 @@ Page({
 				"content.sort": res.sort,
 				"content.sort": res.sort,
 				loading: false
 				loading: false
 			})
 			})
+			this.setListHeight()
 		})
 		})
 	},
 	},