From f852b6768178ed7c19464407cd1079a9239b91bf Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Sat, 22 Jun 2024 19:14:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/goodPopup.vue | 2 +- pages/cart/cart.vue | 28 ++++++++++++++++++++-------- pages/index/index.vue | 13 +++++++++++++ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/components/goodPopup.vue b/components/goodPopup.vue index a62cc98..3075fd9 100644 --- a/components/goodPopup.vue +++ b/components/goodPopup.vue @@ -14,7 +14,7 @@ 商品价格 - ¥ {{datas.price}} + ¥ {{datas.price || datas.sell}} 小计 diff --git a/pages/cart/cart.vue b/pages/cart/cart.vue index be64ca6..13f6a8b 100644 --- a/pages/cart/cart.vue +++ b/pages/cart/cart.vue @@ -206,14 +206,22 @@ // 购物车相关 const addCart = (id, cart_num) => { //加入购物车 - cartCreateApi({ - cart_num: +cart_num, - product_id: id, - store_id: 1 - // store_id: - }).then(res => { - getcartList(); - }) + if (uni.getStorageSync('STORE_INFO').length) { + let data = JSON.parse(uni.getStorageSync('STORE_INFO')) + let STORE_INFO = {}; + for (let key in data) { + STORE_INFO[key] = data[key] + } + cartCreateApi({ + cart_num: +cart_num, + product_id: id, + store_id: STORE_INFO.id + // store_id: + }).then(res => { + getcartList(); + }) + } + } const isAdmin = ref(false); //是否管理 @@ -245,6 +253,10 @@ } else { checkAll.value = 0 } + res.data.lists = res.data.lists.map(item => { + if(!item.price) item.price = item.sell; // 兼容旧数据,新数据已经添加了price字段 + return item; + }) cartList.value = res.data.lists; cartInfo.value = { total_price: res.data?.extend.total_price || '0.00', diff --git a/pages/index/index.vue b/pages/index/index.vue index 7e4c2c4..e5bd703 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -48,6 +48,7 @@ 我的订单 + {{ userStore.userInfo.no_writeoff }} @@ -658,11 +659,23 @@ flex-direction: column; align-items: center; justify-content: center; + position: relative; image { height: 40rpx; width: 40rpx; } + + .badge{ + position: absolute; + top: -10rpx; + right: 0; + background-color: #FF0000; + color: #FFFFFF; + padding: 0 5rpx; + border-radius: 50rpx; + font-size: 18rpx; + } } }