improve: 优化接口调用

This commit is contained in:
From-wh 2023-04-27 16:45:22 +08:00
parent 4520bec03e
commit 2b15d4b547

View File

@ -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