From 2b15d4b54724832cc6b1bdeb985139180bef2f9a Mon Sep 17 00:00:00 2001 From: From-wh Date: Thu, 27 Apr 2023 16:45:22 +0800 Subject: [PATCH] =?UTF-8?q?improve:=20=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/order_addcart/order_addcart.vue | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/template/uni-app/pages/order_addcart/order_addcart.vue b/template/uni-app/pages/order_addcart/order_addcart.vue index 63ed85267..cdeed1abd 100644 --- a/template/uni-app/pages/order_addcart/order_addcart.vue +++ b/template/uni-app/pages/order_addcart/order_addcart.vue @@ -258,18 +258,18 @@ this.canShow = false if (this.isLogin == true) { this.hotPage = 1; - this.hostProduct = [], - this.hotScroll = false, - this.getHostProduct(); + this.hostProduct = [] + this.hotScroll = false + this.getHostProduct(); this.loadend = false; this.page = 1; this.cartList.valid = []; - this.getCartList(); + this.getCartList(1); this.loadendInvalid = false; this.pageInvalid = 1; this.cartList.invalid = []; this.getInvalidList(); - this.getCartNum(); + // this.getCartNum(); this.goodsHidden = true; this.footerswitch = true; this.hostProduct = []; @@ -769,7 +769,7 @@ }) }); }, - async getCartList() { + async getCartList(init) { uni.showLoading({ title: this.$t(`加载中`), mask: true @@ -782,6 +782,21 @@ } getCartCounts().then(async c => { that.cartCount = c.data.count; + if (init) { + this.adding = false + this.$store.commit('indexData/setCartNum', c.data.count > 99 ? '..' : c.data + .count) + if (c.data.count > 0) { + wx.setTabBarBadge({ + index: 2, + text: c.data.count + '' + }) + } else { + wx.hideTabBarRedDot({ + index: 2 + }) + } + } for (let i = 0; i < Math.ceil(c.data.ids.length / that.limit); i++) { let cartList = await this.getCartData(data) let valid = cartList.valid