dever 5 years ago
parent
commit
bd19254b9d
1 changed files with 15 additions and 12 deletions
  1. 15 12
      pages/dream/view/product.vue

+ 15 - 12
pages/dream/view/product.vue

@@ -211,9 +211,13 @@ export default {
 			this.getAttrKey();
 		},
 		// 购买数量变化
-		buyNumChange : function (e) {
-			this.buyNum = e[0];
-			this.getAttrKey();
+		buyNumChange : function (e) {
+			var price = this.getAttrKey();
+			if (price) {
+				console.info(this.buyNum);
+				this.buyNum = e[0];
+				this.payPrice = parseFloat(price) * this.buyNum;			
+			}
 		},
 		// 属性提交
 		attrSubmit : function(e) {
@@ -242,22 +246,21 @@ export default {
 			if (this.item.goods.price_type == 1) {
 				this.kuNum = parseInt(this.item.goods.num);
 				
-				if (this.buyNum > this.kuNum) {
-					this.buyNum = this.kuNum;
-					console.info(this.buyNum);
+				if (this.buyNum >= this.kuNum) {
 					return false;
 				}
-				
-				this.payPrice = parseFloat(this.item.goods.price.min.price) * this.buyNum;
+				this.skuId = 0;
+				return this.item.goods.price.min.price;
 			} else if (this.item.goods.price_type == 2 && this.item.goods.price.list[this.attrKey]) {
 				this.kuNum = parseInt(this.item.goods.price.list[this.attrKey].num);
-				if (this.buyNum > this.kuNum) {
-					this.buyNum = this.kuNum;
+				if (this.buyNum >= this.kuNum) {
 					return false;
 				}
 				this.skuId = this.item.goods.price.list[this.attrKey].id;
-				this.payPrice = parseFloat(this.item.goods.price.list[this.attrKey].price) * this.buyNum;
-			}
+				return this.item.goods.price.list[this.attrKey].price;
+			}
+			
+			return true;
 		},
 		showModal : function() {
 			this.showComment = true;