|
@@ -47,7 +47,8 @@ export default defineComponent({
|
|
|
spDataJson: '',
|
|
|
skuCode: ''
|
|
|
},
|
|
|
- total: 1
|
|
|
+ total: 1,
|
|
|
+ totalData:{}
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -113,6 +114,7 @@ export default defineComponent({
|
|
|
data: body
|
|
|
})
|
|
|
if (code === 200) {
|
|
|
+ this.totalData[selectItem.id] = this.total
|
|
|
if (this.showType === 'cart') {
|
|
|
this.onGetCartCount()
|
|
|
this.$nextTick(() => {
|
|
@@ -138,15 +140,18 @@ export default defineComponent({
|
|
|
// 获取购物车当前产品的数量
|
|
|
async getProductAddCartCount(id?:any) {
|
|
|
id = id ? id : this.skuStockList.find((n: any) => n.id == this.radio)?.id
|
|
|
+ if (this.totalData[id]) {
|
|
|
+ this.total = this.totalData[id]
|
|
|
+ return
|
|
|
+ }
|
|
|
if (!id) return
|
|
|
try {
|
|
|
let res = await request.get(`/api-mall-portal/product/cart/${id}`)
|
|
|
- this.total = res.data || 1
|
|
|
+ this.totalData[id] = this.total = res.data || 1
|
|
|
} catch (err) {}
|
|
|
}
|
|
|
},
|
|
|
render() {
|
|
|
- const item = this.item
|
|
|
return (
|
|
|
<div class={styles.addGoodsCart}>
|
|
|
<Cell
|