From 2f55b0bfb8bb90fae61437e32f5bc50a96cd0022 Mon Sep 17 00:00:00 2001 From: lifizer <913626195@qq.com> Date: Tue, 15 Apr 2025 15:33:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Refactor(=E8=B4=AD=E7=89=A9=E8=BD=A6&?= =?UTF-8?q?=E6=88=91=E7=9A=84):=E5=A2=9E=E5=8A=A0=E6=9C=AA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=88=96=E8=80=85=E7=99=BB=E5=BD=95=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BB=A5=E4=BE=BF=E5=BE=AE=E4=BF=A1=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/cart.vue | 611 ++++++++++++++++++++------------------ pages/user/User/index.vue | 89 +++++- utils/request.js | 13 +- 3 files changed, 411 insertions(+), 302 deletions(-) diff --git a/pages/cart.vue b/pages/cart.vue index 5dbc241..7c6825b 100644 --- a/pages/cart.vue +++ b/pages/cart.vue @@ -10,293 +10,303 @@ title="购物车" fixed /> - - - - - {{ addressInfo.city }} - - + + + + + + + {{ addressInfo.city }} + + + + + {{ isEdit ? '完成' : '管理' }} + + + + + + + + + + {{ isEdit ? '完成' : '管理' }} - - - - - - - - - - - - - - - - - - {{ item['merName'] }} - - - 进店逛逛> - - - - - - - + + + - + {{ item['merName'] }} - - {{ good['productInfo']['storeName'] }} - - 规格:{{ good['productInfo']['attrInfo']['sku'] }} - - - - + 进店逛逛> + + + + + + + + - - {{ good['truePrice'] }} - - - - - - + /> + - - - - - - - - 全选({{ selectCount }}) - - - - 合计: - - {{ total }} - - 结算 - - - - - 清空 - - 删除 - - - - - - - - - - - - - - {{ currGood.productInfo.storeName }} - - - {{ currGoodAttr.price }} - - - - - - - {{ item.attrName }} - + {{ good['productInfo']['storeName'] }} + - {{ attr.attr }} - 缺货 + 规格:{{ good['productInfo']['attrInfo']['sku'] }} + + + + + + {{ good['truePrice'] }} + + + + + + - - - 确认 + + + + + 全选({{ selectCount }}) + + + + 合计: + + {{ total }} + + 结算 + + + + + 清空 + + 删除 + + + + + + + + + + + + + + {{ currGood.productInfo.storeName }} + + + {{ currGoodAttr.price }} + + + + + + + {{ item.attrName }} + + + {{ attr.attr }} + 缺货 + + + + + + + 确认 + @@ -374,7 +384,9 @@ export default { isEdit: false, addressList:[], addressInfo: {}, - userLikeList: [] + userLikeList: [], + // 是否已登录 + isNoLogin: false } }, computed: { @@ -450,21 +462,26 @@ export default { }, getAddress() { getAddressList({page: 1, limit: 9999}).then(res => { - const { data = [] } = res - this.addressList = data - this.addressInfo = data.find(e => e.isDefault == 1) || uni.getStorageSync('cartChooseAddress') || (data && data[0]) || null - if (!this.addressInfo.id) { - this.addressInfo = data.find(e => e.isDefault == 1) || (data && data[0]) || null + if (res.isNoLogin) { + this.isNoLogin = true + return } else { - let isExist = false - data.map(item => { - if (item.id === this.addressInfo.id) { - isExist = true - } - }) - console.log(2, isExist); - if (!isExist) { + const { data = [] } = res + this.addressList = data + this.addressInfo = data.find(e => e.isDefault == 1) || uni.getStorageSync('cartChooseAddress') || (data && data[0]) || null + if (!this.addressInfo.id) { this.addressInfo = data.find(e => e.isDefault == 1) || (data && data[0]) || null + } else { + let isExist = false + data.map(item => { + if (item.id === this.addressInfo.id) { + isExist = true + } + }) + console.log(2, isExist); + if (!isExist) { + this.addressInfo = data.find(e => e.isDefault == 1) || (data && data[0]) || null + } } } }) @@ -500,6 +517,11 @@ export default { }, async getCart() { const res = await getCartGroup() + if (res.isNoLogin) { + this.isNoLogin = true + this.isLoad = true + return + } if (res.success) { this.isLoad = true const invalid = res.data['invalid'].map(e => { @@ -1093,4 +1115,25 @@ view { overflow: hidden; border-radius: 20rpx; } +.no-login-wrap { + display: flex; + flex-direction: column; + align-items: center; + padding: 20vh 0; + .txt { + font-size: 36rpx; + line-height: 56rpx; + color: #333; + } + .btn { + height: 60rpx; + margin: 40rpx 0 0 0; + padding: 0 30rpx; + border-radius: 8rpx; + border: 1px solid #C52733; + line-height: 56rpx; + color: #C52733; + font-size: 28rpx; + } +} \ No newline at end of file diff --git a/pages/user/User/index.vue b/pages/user/User/index.vue index b851d0c..ea9d43b 100644 --- a/pages/user/User/index.vue +++ b/pages/user/User/index.vue @@ -1,9 +1,6 @@