修复易购商品加入购物车错误的问题
This commit is contained in:
parent
24d6593f42
commit
41c389743e
@ -107,10 +107,12 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="review-time">{{ comment.create_time }}</view>
|
<view class="review-time">{{ comment.create_time }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-purchase">已购 {{ comment.goods_name.goods_name }}{{ comment.goods_name.goods_spec }}</view>
|
<view class="user-purchase">已购 {{ comment.goods_name.goods_name }}{{ comment.goods_name.goods_spec
|
||||||
|
}}</view>
|
||||||
<view class="review-content">{{ comment.user_review }}</view>
|
<view class="review-content">{{ comment.user_review }}</view>
|
||||||
<view class="review-images" v-if="comment.review_image.length > 0">
|
<view class="review-images" v-if="comment.review_image.length > 0">
|
||||||
<image :src="img" class="review-img" v-for="(img, idx) in comment.review_image" :key="idx"></image>
|
<image :src="img" class="review-img" v-for="(img, idx) in comment.review_image" :key="idx">
|
||||||
|
</image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -203,7 +205,7 @@
|
|||||||
<!-- 分享 -->
|
<!-- 分享 -->
|
||||||
<view class="shadow" @click.stop="changeShadow" v-if="boxshadow1">
|
<view class="shadow" @click.stop="changeShadow" v-if="boxshadow1">
|
||||||
<view class="shadowBox1">
|
<view class="shadowBox1">
|
||||||
<button class="shadowBox1Item_btn" open-type="share" bindtap="onShareButtonClick"/>
|
<button class="shadowBox1Item_btn" open-type="share" bindtap="onShareButtonClick" />
|
||||||
<view class="shadowBox1Item" @click="shareFriend">
|
<view class="shadowBox1Item" @click="shareFriend">
|
||||||
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_WX.png"
|
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_WX.png"
|
||||||
mode="aspectFill"></image>
|
mode="aspectFill"></image>
|
||||||
@ -231,9 +233,12 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="line"></view>
|
<view class="line"></view>
|
||||||
<view class="shadowBoxInfo">
|
<view class="shadowBoxInfo">
|
||||||
<image class="shadowboxInfo_left" :src="qrcodePath || 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/qrcode_placeholder.png'" mode="aspectFill"></image>
|
<image class="shadowboxInfo_left"
|
||||||
|
:src="qrcodePath || 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/qrcode_placeholder.png'"
|
||||||
|
mode="aspectFill"></image>
|
||||||
<view class="shadowboxInfo_right">
|
<view class="shadowboxInfo_right">
|
||||||
<view class="shadowboxInfo_right_1">{{ currentGG && currentGG.goods_name ? currentGG.goods_name : '' }}</view>
|
<view class="shadowboxInfo_right_1">{{ currentGG && currentGG.goods_name ?
|
||||||
|
currentGG.goods_name : '' }}</view>
|
||||||
<view class="shadowboxInfo_right_2">
|
<view class="shadowboxInfo_right_2">
|
||||||
长按识别小程序 <br />
|
长按识别小程序 <br />
|
||||||
数量有限马上抢购
|
数量有限马上抢购
|
||||||
@ -271,7 +276,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="review-time">{{ comment.create_time }}</view>
|
<view class="review-time">{{ comment.create_time }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-purchase">已购 {{ comment.goods_name.goods_name }}{{ comment.goods_name.goods_spec }}</view>
|
<view class="user-purchase">已购 {{ comment.goods_name.goods_name }}{{
|
||||||
|
comment.goods_name.goods_spec }}</view>
|
||||||
<view class="review-content">{{ comment.user_review }}</view>
|
<view class="review-content">{{ comment.user_review }}</view>
|
||||||
<view class="review-images" v-if="comment.review_image.length > 0">
|
<view class="review-images" v-if="comment.review_image.length > 0">
|
||||||
<image :src="img" class="review-img" v-for="(img, idx) in comment.review_image" :key="idx">
|
<image :src="img" class="review-img" v-for="(img, idx) in comment.review_image" :key="idx">
|
||||||
@ -303,7 +309,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="itemSizeBox" v-for="(item, index) in info.commodity_goods_info_list" :key="item.id"
|
<view class="itemSizeBox" v-for="(item, index) in info.commodity_goods_info_list" :key="item.id"
|
||||||
@click="changeGG(item, index)">
|
@click="changeGG(item, index)">
|
||||||
<text class="itemSize" :class="index == currentGGIndex ? 'itemSize_active' : ''">{{ item.goods_name }} {{ item.goods_spec }} / {{ item.goods_unit }}</text>
|
<text class="itemSize" :class="index == currentGGIndex ? 'itemSize_active' : ''">{{ item.goods_name }}
|
||||||
|
{{ item.goods_spec }} / {{ item.goods_unit }}</text>
|
||||||
</view>
|
</view>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
</view>
|
</view>
|
||||||
@ -321,36 +328,36 @@ import {
|
|||||||
} from "../../../utils";
|
} from "../../../utils";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
picUrl,
|
picUrl,
|
||||||
top: "",
|
top: "",
|
||||||
localHeight: "",
|
localHeight: "",
|
||||||
carNum: "",
|
carNum: "",
|
||||||
prevCarNum: "",
|
prevCarNum: "",
|
||||||
currentNum: "0", //当前商品的数量
|
currentNum: "0", //当前商品的数量
|
||||||
type: "error",
|
type: "error",
|
||||||
boxshadow1: false,
|
boxshadow1: false,
|
||||||
boxshadow2: false,
|
boxshadow2: false,
|
||||||
id: "184",
|
id: "184",
|
||||||
info: "",
|
info: "",
|
||||||
currentIndex: "1", //当前轮播图
|
currentIndex: "1", //当前轮播图
|
||||||
|
|
||||||
currentGG: "", //当前选中规格
|
currentGG: "", //当前选中规格
|
||||||
currentGGIndex: "", //当前规格index
|
currentGGIndex: "", //当前规格index
|
||||||
|
|
||||||
carOrderList: [],
|
carOrderList: [],
|
||||||
// 新增评论数据
|
// 新增评论数据
|
||||||
showReviewPopup: false,
|
showReviewPopup: false,
|
||||||
comments: [],
|
comments: [],
|
||||||
show: false,
|
show: false,
|
||||||
showSize: false,
|
showSize: false,
|
||||||
|
|
||||||
changeImg: "",
|
changeImg: "",
|
||||||
changeName: "",
|
changeName: "",
|
||||||
changePrice: "",
|
changePrice: "",
|
||||||
selectedGoods: null, // 保存传入的商品规格信息
|
selectedGoods: null, // 保存传入的商品规格信息
|
||||||
qrcodePath: null, // 存储当前页面的二维码路径
|
qrcodePath: null, // 存储当前页面的二维码路径
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeIndex(e) {
|
changeIndex(e) {
|
||||||
@ -460,7 +467,7 @@ export default {
|
|||||||
}
|
}
|
||||||
this.info = res;
|
this.info = res;
|
||||||
console.log("this.info", this.info.commodity_goods_info_list);
|
console.log("this.info", this.info.commodity_goods_info_list);
|
||||||
|
|
||||||
// 检查是否有传入的选中商品信息,如果有则设置为默认选中
|
// 检查是否有传入的选中商品信息,如果有则设置为默认选中
|
||||||
let selectedIndex = 0;
|
let selectedIndex = 0;
|
||||||
if (this.selectedGoods) {
|
if (this.selectedGoods) {
|
||||||
@ -471,7 +478,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentGG = res.commodity_goods_info_list[selectedIndex];
|
this.currentGG = res.commodity_goods_info_list[selectedIndex];
|
||||||
console.log("this.currentGG", this.currentGG);
|
console.log("this.currentGG", this.currentGG);
|
||||||
this.currentGGIndex = selectedIndex;
|
this.currentGGIndex = selectedIndex;
|
||||||
@ -533,11 +540,11 @@ export default {
|
|||||||
let that = this;
|
let that = this;
|
||||||
// 获取当前商品
|
// 获取当前商品
|
||||||
const currentGoods = this.info.commodity_goods_info_list[this.currentGGIndex];
|
const currentGoods = this.info.commodity_goods_info_list[this.currentGGIndex];
|
||||||
|
|
||||||
// 获取当前购物车数量和库存数量
|
// 获取当前购物车数量和库存数量
|
||||||
const currentQuantity = currentGoods.cart_count ? currentGoods.cart_count.count : 0;
|
const currentQuantity = currentGoods.cart_count ? currentGoods.cart_count.count : 0;
|
||||||
const stockQuantity = currentGoods.stock_quantity || 0;
|
const stockQuantity = currentGoods.stock_quantity || 0;
|
||||||
|
|
||||||
// 检查库存是否充足
|
// 检查库存是否充足
|
||||||
if (currentQuantity >= stockQuantity) {
|
if (currentQuantity >= stockQuantity) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -547,23 +554,22 @@ export default {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果没有当前商品 直接添加一个
|
//如果没有当前商品 直接添加一个
|
||||||
let goods_id_and_count = [];
|
|
||||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {
|
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {
|
||||||
count: currentQuantity + 1,
|
count: currentQuantity + 1,
|
||||||
};
|
};
|
||||||
this.info.commodity_goods_info_list.forEach((item) => {
|
const params = {
|
||||||
goods_id_and_count.push({
|
goods_id_and_count: [
|
||||||
goods_id: item.id,
|
{
|
||||||
count: item.cart_count ? item.cart_count.count : 0,
|
goods_id: this.info.commodity_goods_info_list[this.currentGGIndex].id,
|
||||||
});
|
count: this.info.commodity_goods_info_list[this.currentGGIndex].cart_count.count,
|
||||||
});
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
//因为是当前商品没有 调用update就是增加商品。增加商品之后再获取购物车数量
|
//因为是当前商品没有 调用update就是增加商品。增加商品之后再获取购物车数量
|
||||||
request(apiArr.updateCar, "POST", {
|
request(apiArr.updateCar, "POST", params).then((res) => {
|
||||||
goods_id_and_count,
|
|
||||||
}).then((res) => {
|
|
||||||
that.getShopCar();
|
that.getShopCar();
|
||||||
that.getShopCarList();
|
that.getShopCarList();
|
||||||
});
|
});
|
||||||
@ -638,7 +644,7 @@ export default {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},onLoad(options) {
|
}, onLoad(options) {
|
||||||
const itemObj = JSON.parse(decodeURIComponent(options.item));
|
const itemObj = JSON.parse(decodeURIComponent(options.item));
|
||||||
const meun = menuButtonInfo();
|
const meun = menuButtonInfo();
|
||||||
this.top = meun.top;
|
this.top = meun.top;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user