Forráskód Böngészése

添加快捷加入购物车,价格范围相等不显示~

xiaohaizhao 1 éve
szülő
commit
d76f7dafeb

+ 36 - 1
pages/index/market/modules/list/index.js

@@ -1,3 +1,4 @@
+const _Http = getApp().globalData.http;
 Component({
   properties: {
     list: {
@@ -7,6 +8,9 @@ Component({
       type: Number
     }
   },
+  options: {
+    addGlobalClass: true
+  },
   methods: {
     toDetail(e) {
       const {
@@ -18,6 +22,37 @@ Component({
           sa_brandid:item.sa_brandid
         })}`,
       })
-    }
+    },
+    buyMore(e) {
+      const item = e.currentTarget.dataset.item.item[0];
+      const item1 = e.currentTarget.dataset.item;
+      wx.showModal({
+        title: '提示',
+        content: `是否确定将“${item.itemname}”加入到购物车`,
+        complete: (res) => {
+          if (res.confirm) _Http.basic({
+            "id": 20220924095102,
+            "content": {
+              sa_brandid: item1.sa_brandid,
+              "itemid": item.itemid, //货品id
+              "qty": item.orderminqty, //数量
+              itemno: item.itemno, //货品编号
+              tradefield: item1.tradefield,
+              width: item.width,
+              length: item.length
+            },
+          }).then(res => {
+            console.log("加入购物车", res)
+            wx.showToast({
+              title: res.msg == '成功' ? '加入成功' : res.msg,
+              icon: "none"
+            });
+            if (res.msg == '成功') getApp().globalData.getCollectCount().then(badge => this.setData({
+              badge
+            }))
+          })
+        }
+      })
+    },
   }
 })

+ 15 - 6
pages/index/market/modules/list/index.scss

@@ -46,13 +46,12 @@
 			line-height: 34rpx;
 			font-size: 24rpx;
 			color: #888888;
-			margin-top: 8rpx;
 		}
 
 		.tags {
 			display: flex;
 			height: 32rpx;
-			margin-top: 8rpx;
+			margin-top: 6rpx;
 			width: 100%;
 
 			>view {
@@ -73,19 +72,29 @@
 			height: 40rpx;
 			align-items: center;
 			justify-content: space-between;
-			margin-top: 14rpx;
 
-			view {
+			.view {
 				font-size: 28rpx;
 				font-family: PingFang SC-Medium, PingFang SC;
 				font-weight: 550;
 				color: #3874F6;
 			}
 
-			text {
-				font-size: 24rpx;
+			.punit {
+				font-size: 20rpx;
 				color: #888888;
+				margin-left: 12rpx;
+				margin-top: 8rpx;
 			}
+
+			.shopping {
+				font-size: 24rpx;
+
+				.iconfont {
+					color: #F29C37;
+				}
+			}
+
 		}
 	}
 }

+ 19 - 4
pages/index/market/modules/list/index.wxml

@@ -11,7 +11,7 @@
 	</view>
 	<view class="right-box">
 		<view class="title line-1">{{item.groupname||'--'}}</view>
-		<view class="type line-1">{{item.groupnum||'--'}}</view>
+
 		<view class="tags">
 			<view style="background: #FA8C16;">
 				{{item.brandname}}
@@ -20,11 +20,26 @@
 				{{item.tradefield}}
 			</view>
 		</view>
+		<view class="type line-1">
+			型号:{{item.item[0].model || ' --'}}
+		</view>
+		<view class="type line-1">
+			规格:{{item.item[0].standards || ' --'}}
+		</view>
+
 		<view class="price">
-			<view>
-				¥ {{handleHide.query((item.minprice+'~'+item.maxprice),hidePrice)}}
+			<view style="display: flex;">
+				<view class="view" wx:if="{{item.minprice==item.maxprice}}">
+					¥ {{handleHide.query(item.minprice,hidePrice)}}
+				</view>
+				<view class="view" wx:else>
+					¥ {{handleHide.query((item.minprice+'~'+item.maxprice),hidePrice)}}
+				</view>
+				<view class="punit">× {{item.unitname}}</view>
 			</view>
-			<text>× {{item.unitname}}</text>
+			<navigator wx:if="{{!item.isscheme}}" url="#" class="shopping" data-item="{{item}}" catchtap="buyMore">
+				<text class="iconfont icon-gouwuche" />
+			</navigator>
 		</view>
 	</view>
 </navigator>