Răsfoiți Sursa

加购物车测试

mym 1 an în urmă
părinte
comite
9a6f190340
1 a modificat fișierele cu 41 adăugiri și 9 ștergeri
  1. 41 9
      pages/goodsDetails/goodsDetails.vue

+ 41 - 9
pages/goodsDetails/goodsDetails.vue

@@ -25,11 +25,16 @@
 			<u-button class="custom-style" type="warning" @click="addCar()">加入购物车</u-button>
 			<u-button class="custom-style" type="error">立即购买</u-button>
 		</view>
-		<u-popup :show="show" @close="close" @open="open">
+		<!-- <u-popup :show="show" @close="close" @open="open">
 			<view>
-				<text>出淤泥而不染,濯清涟而不妖</text>
+				<view class="num">
+					<u-button class="numBtn" icon="minus" @click="minus()"></u-button>
+					<text v-model="num">{{num}}</text>
+					<u-button class="numBtn" icon="plus"  @click="add()"></u-button>
+				</view>
+				<u-button type="primary" shape="circle" size="40" text="确定" @click="addCar()"></u-button>
 			</view>
-		</u-popup>
+		</u-popup> -->
 	</view>
 </template>
 
@@ -61,21 +66,34 @@
 					}
 				})
 			},
+			minus() {
+				if (this.num == 1) {
+					this.$$common.toast("已经到最小数量,无法在减少")
+					return
+				} else {
+					this.num--
+				}
+			},
+			add() {
+				this.num++
+			},
 			addCar() {
-				this.show = true
-				let user = uni.getStorageInfoSync("info")
+				// this.show = true
+				let user = uni.getStorageSync("info")
 				let params = {
 					buyUserId: user.id,
 					enterpriseId: this.goods.merchantId,
-					shopId: shopId,
+					shopId: this.goods.shopId,
 					tradeAreaId: this.goods.tradeAreaId,
 					saleGoodsInfoId: this.goods.id,
-					buyUserType: user.userType,
-					buyType: 2,
+					// buyUserType: user.userType,
+					// buyType: parseInt(2),
 					goodsImg: this.goods.goodsImg,
 					goodsName: this.goods.goodsName,
-					buyNum: num
+					// buyNum: parseInt(this.num)
 				}
+
+				console.log(params)
 				this.$api.addCar(this.goods).then(res => {
 					console.log(res)
 				})
@@ -124,6 +142,20 @@
 		margin-bottom: 10rpx;
 	}
 
+	.num {
+		width: 100%;
+		padding: 10rpx;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+		font-size: 40rpx;
+	}
+
+	.numBtn {
+		width: 20%;
+		margin: 20rpx;
+	}
+
 	.footer {
 		width: 100%;
 		display: flex;