liujiaxin пре 3 недеља
родитељ
комит
4c2f37cb1a

+ 11 - 1
pages/shopping/productDetails.vue

@@ -103,7 +103,7 @@
 					<text class="label">咨询</text>
 					<button class="contact-btn" open-type="contact"></button>
 				</view>
-				<view class="item" @click="navgetTo('./cart')">
+				<view class="item" @click="toCart('./cart')">
 					<uni-badge size="small" :text="cartCount" absolute="rightTop" type="error">
 						<image src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/cart36.png" mode=""></image>
 					</uni-badge>
@@ -463,6 +463,16 @@
 					}
 				})
 			},
+			toCart(url) {
+				this.utils.isLogin().then(res => {
+					if(res){
+						uni.switchTab({
+							url: url
+						})
+					}
+				})
+			},
+			
 			// 加入购物车
 			addCart(type) {
 				this.utils.isLogin().then(res => {

+ 1 - 1
pages_course/living.vue

@@ -4645,7 +4645,7 @@
 					position: relative;
 
 					&.chat-content-focused {
-						height: 64rpx;
+						height: 100rpx;
 					}
 
 					.notice-message {

+ 8 - 7
pages_shopping/live/confirmCreateOrder.vue

@@ -176,7 +176,8 @@
 				confirmParam: [],
 				type: '',
 				isFirstLoad: true,
-				recordId: ''
+				recordId: '',
+				productValueSelect:''
 			}
 		},
 
@@ -190,7 +191,7 @@
 			this.type = options.type;
 			this.isFirstLoad = true;
 			this.recordId = options.recordId || '';
-
+            this.productValueSelect=options.productValueSelect||''
 			if (options.type == 'win') {
 				this.getKey()
 			}
@@ -285,7 +286,8 @@
 					totalNum: this.totalNum,
 					productId: this.productId,
 					orderKey: this.orderKey,
-					couponUserId: this.couponUserId || ''
+					couponUserId: this.couponUserId || '',
+					attrValueId:this.productValueSelect
 				}
 
 				computed(data).then(res => {
@@ -337,13 +339,12 @@
 					userName: this.address.realName,
 					remark:this.orderData.remark||'',
 					userPhone: this.address.phone,
-					userAddress: this.address.province + ' ' + this.address.city + ' ' + this.address.district + ' ' +
-						this.address
-						.detail,
+					userAddress: this.address.province + ' ' + this.address.city + ' ' + this.address.district + ' ' +this.address.detail,
 					cartId: "5",
 					productId: this.productId,
 					totalNum: this.totalNum,
-					couponUserId: this.couponUserId
+					couponUserId: this.couponUserId,
+					attrValueId:this.productValueSelect
 
 				}
 

+ 26 - 4
pages_shopping/live/goods.vue

@@ -121,7 +121,7 @@
 		},
 		data() {
 			return {
-				attrs:null,
+				attrs:[],
 				banner: [],
 				goodsId: null,
 				totalNum: 1,
@@ -133,7 +133,7 @@
 				productId: null,
 				goosDetail: null, //商品详情
 				buyText: "立即购买",
-				// goodsNum: 0, //商品选择数量
+				goodsNum: 0, //商品选择数量
 				// 当前轮播的图片
 				activeBanner: 1,
 				// 规格弹窗
@@ -192,8 +192,7 @@
 							uni.navigateTo({
 								url: '/pages_shopping/live/confirmCreateOrder?&orderKey=' + this.orderKey +
 									'&liveId=' + this.liveId + '&goodsId=' + this.goodsId +
-									'&productId=' + this.productId + '&totalNum=' + this
-									.totalNum
+									'&productId=' + this.productId + '&totalNum=' + this.totalNum+"&productValueSelect="+this.productValueSelect.id
 							})
 						} else {
 							uni.showToast({
@@ -209,6 +208,12 @@
 			goodsNumChange(e) {
 				console.log('当前选择商品数量为: ' + e.value)
 				this.totalNum = e.value
+				if(this.totalNum < 1) {
+					this.totalNum = 1
+				}
+				if(this.totalNum>=this.productValueSelect.stock){
+					this.totalNum=this.productValueSelect.stock
+				}
 			},
 			// 提交
 			submit() {
@@ -237,6 +242,8 @@
 							     item.values=item.attrValues.split(',');
 								 item.index=0
 							});
+							this.values=res.productValues;
+							this.choseSpec(0,0)
 						} else {
 							uni.showToast({
 								title: res.msg,
@@ -247,6 +254,12 @@
 					rej => {}
 				);
 			},
+			getValueSelect(){
+				var valueSelect=this.values.filter((item)=>{
+				     return item.sku==this.selectVal;
+				});
+				return valueSelect;
+			},
 			// 规格选择
 			choseSpec(index,subIndex) {
 				this.attrs[index].index = subIndex;
@@ -274,6 +287,15 @@
 				this.updateSpecNum();
 				
 			},
+			//更新数量
+			updateSpecNum(){
+				if(this.productValueSelect.stock==0){
+					this.totalNum=0;
+				}
+				else{
+					this.totalNum=1;
+				}
+			}
 		}
 	}
 </script>