diff --git a/yshop-drink-uniapp-vue3/pages/menu/menu.vue b/yshop-drink-uniapp-vue3/pages/menu/menu.vue index 0861d72..437a958 100644 --- a/yshop-drink-uniapp-vue3/pages/menu/menu.vue +++ b/yshop-drink-uniapp-vue3/pages/menu/menu.vue @@ -137,7 +137,7 @@ {{ getCartGoodsNumber }} - + ¥{{ getCartGoodsPrice }} {{ deliveryTipText }} @@ -462,14 +462,12 @@ onHide(() => { }) onShow(() => { //init(); + isCartShow.value = true refreshCart() shopAd.value = uni.getStorageSync('shopAd') loadAddressesForDelivery() }) -const openCartShow = () =>{ - isCartShow.value = false -} const in_array = (search, array) => { for (var i in array) { if (array[i] == search) { @@ -751,6 +749,7 @@ const calcSize = () => { sizeCalcState.value = true } const handleAddToCart = (cate, newGood, num) =>{ //添加到购物车 + isCartShow.value = true const valueStr = newGood.valueStr || '' const index = cart.value.findIndex(item => item.id === newGood.id && item.valueStr === valueStr) if (index > -1) { @@ -769,6 +768,7 @@ const handleAddToCart = (cate, newGood, num) =>{ //添加到购物车 uni.setStorageSync('cart', JSON.parse(JSON.stringify(cart.value))) } const adjustSimpleGood = (cate, newGood, num) => { + isCartShow.value = true const valueStr = defaultSpec(newGood) const index = cart.value.findIndex(item => item.id === newGood.id && item.valueStr === valueStr) if (num > 0) { @@ -848,6 +848,8 @@ const handleAddToCartInModal = () => { closeGoodDetailModal() } const openCartPopup = () => { //打开/关闭购物车列表popup + isCartShow.value = true + if (!cart.value.length) return popup.value.open() } const handleCartClear = () => { //清空购物车 @@ -866,10 +868,12 @@ const handleCartClear = () => { //清空购物车 }) } const handleCartItemAdd = (index) => { + isCartShow.value = true cart.value[index].number += 1 uni.setStorageSync('cart', JSON.parse(JSON.stringify(cart.value))) } const handleCartItemReduce = (index) => { + isCartShow.value = true if (cart.value[index].number === 1) { cart.value.splice(index, 1) } else { @@ -877,6 +881,7 @@ const handleCartItemReduce = (index) => { } if (!cart.value.length) { cartPopupVisible.value = false + popup.value?.close?.() } uni.setStorageSync('cart', JSON.parse(JSON.stringify(cart.value))) }