Fix:3880 【商城小程序】搜索界面-增加商品到购物车,红点提示未及时同步更新数量

This commit is contained in:
linxi
2025-07-30 14:54:47 +08:00
parent f8c348279f
commit 9870970d28
2 changed files with 15 additions and 14 deletions
+14 -2
View File
@@ -33,10 +33,22 @@ export default {
unique: ''
}
},
cart_num: 1
cart_num: 1,
CartCount: 0,
}
},
methods: {
// 获取购物车数量
getCartCount () {
const isLogin = this.isLogin
if (isLogin) {
getCartCount({
numType: 0
}).then(res => {
this.CartCount = res.data.count
})
}
},
getSkuActiveStatus(selectedSku) {
getProductSkuBySelected({ id: this.id, selectedSku }).then(res => {
const { success, data } = res
@@ -100,7 +112,7 @@ export default {
const onlyOne = Object.keys(data.productValue).length === 1
if(onlyOne) {
this.handleOk()
this.handleOk(this.getCartCount())
return
}
this.attr.cartAttr = !this.isOpen ? true : false
+1 -12
View File
@@ -201,7 +201,6 @@ export default {
mixins: [goCartMixin],
data () {
return {
CartCount: 0,
webUrl: this.$VUE_APP_RESOURCES_URL,
list: [],
query: {
@@ -232,17 +231,7 @@ export default {
!this.loading && this.getList()
},
methods: {
// 获取购物车数量
getCartCount () {
const isLogin = this.isLogin
if (isLogin) {
getCartCount({
numType: 0
}).then(res => {
this.CartCount = res.data.count
})
}
},
goShoppingCart() {
this.$yrouter.switchTab('/pages/cart')
},