Procházet zdrojové kódy

购买时增加库存限制

gcz před 4 roky
rodič
revize
c4f6093a8f

+ 16 - 2
pages/product/modal/quickBuy.vue

@@ -42,7 +42,8 @@
 			uniPopup,
 		},
 		created(){
-			console.log(this.pData);
+			console.log('this.pData',JSON.parse(JSON.stringify(this.pData)));
+			if(this.pData.product.stock>0){this.total = 1};
 		},
 		props:{
 			visible: {
@@ -59,7 +60,7 @@
 				loading:false,
 				loadStatus:'loading',
 				min:1,
-				total:1,
+				total:0,
 
 			}
 		},
@@ -80,6 +81,10 @@
 						this.total = 1
 					}
 				}
+				if(this.total>=this.pData.product.stock){
+					this.$api.msg('超出最大库存');
+					this.total = this.pData.product.stock;
+				}
 			},
 			//数量计算
 			calcValue(type,total){
@@ -89,10 +94,19 @@
 						this.total = 1
 					}
 				} else if (type === "add") {
+					// console.log('total',total);
+					if(total>=this.pData.product.stock){
+						this.$api.msg('超出最大库存');
+						return;
+					}
 					this.total++;
 				}
 			},
 			submit(){
+				if(this.total<=0){
+					this.$api.msg('商品数量不能小于1');
+					return;
+				};
 				this.$emit('closeModal',true)
 				bus.$emit('toDetailPage', {
 					data: {

+ 1 - 1
pages/usercenter/myorder/orderdetails/orderdetails.vue

@@ -29,7 +29,7 @@
 		</view>
 		<view class="status-common" v-if="status == 4">
 			<!-- 因交易超时,系统关闭了该笔交易 -->
-			订单已关闭
+			订单已关闭
 		</view>
 		<!-- status end -->		
 		<view class="bill-info">