From 1169e300dfa7b7ddc326831f351cf9b198992ab8 Mon Sep 17 00:00:00 2001 From: wwz <1144797966@qq.com> Date: Tue, 25 Mar 2025 10:05:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E8=B4=AD=E7=89=A9=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 10 ++++---- components/CustomNavbar.vue | 4 +--- components/paymentMethod.vue | 11 +++++++-- framework/0-conf.js | 2 +- pages/order/coupon.vue | 2 +- pages/order/detail.vue | 45 ++++++++++++++++++++++-------------- pages/user/member/index.vue | 1 + stores/order.js | 1 + 8 files changed, 47 insertions(+), 29 deletions(-) diff --git a/App.vue b/App.vue index a2647ed..4917f6e 100644 --- a/App.vue +++ b/App.vue @@ -23,14 +23,14 @@ const store = useNavbarStore(); await store.initNavbarHeight(); // #ifndef H5 - try { + // try { const storelogin = Storelogin(); await storelogin.actionslogin() proxy.$isResolve() - } catch (error) { - proxy.$isResolve() - console.log(error) - } + // } catch (error) { + // proxy.$isResolve() + // console.log(error) + // } // #endif }); // export default { diff --git a/components/CustomNavbar.vue b/components/CustomNavbar.vue index 64c6f3e..11e04ad 100644 --- a/components/CustomNavbar.vue +++ b/components/CustomNavbar.vue @@ -54,9 +54,7 @@ const goBack = () => { try { - uni.navigateBack({ - delta: 1 - }); + uni.pro.switchTab('index/index') } catch (error) { uni.pro.switchTab('index/index') //TODO handle the exception diff --git a/components/paymentMethod.vue b/components/paymentMethod.vue index fbf554f..a985e1f 100644 --- a/components/paymentMethod.vue +++ b/components/paymentMethod.vue @@ -63,9 +63,15 @@ }); - const orderVIP = ref(uni.cache.get('orderVIP')) + const orderVIP = ref(null) const emits = defineEmits(['customevent', 'groupChange']); + watchEffect(() => { + orderVIP.value = uni.cache.get('orderVIP') + }) + const orderVIPfun = (data) => { + orderVIP.value = data + } const paymentMethodList = ref([{ name: "余额支付", @@ -140,7 +146,8 @@ } // 将方法暴露给父组件 defineExpose({ - groupChanges + groupChanges, + orderVIPfun }); diff --git a/framework/0-conf.js b/framework/0-conf.js index 83b9d7b..b44fa65 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -1,5 +1,5 @@ // const debug = process.env.NODE_ENV == 'development' ? true : false; -const debug = true; +const debug = false; // #ifdef H5 const proxyApi = "/api" // #endif diff --git a/pages/order/coupon.vue b/pages/order/coupon.vue index f0ec5c2..b5c9453 100644 --- a/pages/order/coupon.vue +++ b/pages/order/coupon.vue @@ -272,7 +272,7 @@ shopUserId: Orderinfo.shopUserId, }) - if (Orderinfo.typeOrder == 2) { + if (Orderinfo.typeOrder == 2 && res.length>0) { res.forEach((item) => { item.Selected = false }) diff --git a/pages/order/detail.vue b/pages/order/detail.vue index 4506518..87205d2 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -119,6 +119,7 @@ import rechargeFree from './components/rechargeFree.vue' import paymentMethodes from '@/components/paymentMethod.vue'; //支付方式 import { + onShow, onBackPress } from '@dcloudio/uni-app'; @@ -221,8 +222,7 @@ // 打包费packFeess 计算购物车商品费用totalPrices 餐位费Seatcharge try { let sum = (is_type.value != 0 ? listinfo.packFeess : 0) + listinfo.totalPrices + (is_type - .value == - 0 ? listinfo.Seatcharge : 0); + .value == 0 ? listinfo.Seatcharge : 0); listinfo.originAmount = Math.round(sum * 100) / 100; // 打包费packFeess 计算购物车商品费用totalPrices 餐位费Seatcharge 商品卷Productroll 优惠卷coupondiscountAmount 积分listinfo.pointsDiscountAmount @@ -232,11 +232,15 @@ .coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0); listinfo.totalCost = Math.round(sums * 100) / 100; // 霸王餐 - console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value) - if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) { - listinfo.totalCost = (parseFloat(listinfo.totalCost) * parseFloat(orderVIP.value - .freeDineConfig - .rechargeTimes)).toFixed(2) + try { + console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value) + if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) { + listinfo.totalCost = (parseFloat(listinfo.totalCost) * parseFloat(orderVIP.value + .freeDineConfig + .rechargeTimes)).toFixed(2) + } + } catch (error) { + //TODO handle the exception } // 积分 if (listinfo.totalCost && listinfo.status == 'unpaid') { @@ -258,7 +262,6 @@ orderInfoAfterRef.value.bwcclear() uniqueIds.value = [] // 筛选出商品卷的id listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额 - listinfo.Productroll = 0 // 商品卷总价价格 listinfo.pointsNum = 0 // 商品卷总价价格 // 支付方式切换 // #ifdef MP-WEIXIN @@ -330,23 +333,28 @@ } } else { // 筛选出商品卷的id - uniqueIds.value = [...uniqueIds.value, ...new Set(data.map(item => item.id))] // 商品卷总价价格 - listinfo.Productroll = await cartStore.getTotalProductroll(data) + // uniqueIds.value = [...uniqueIds.value, ...new Set(data.map(item => item.id))] + uniqueIds.value = [...uniqueIds.value, ...data.map(item => item.id)] + listinfo.Productroll = cartStore.getTotalProductroll(data).value + // TODO handle the exception let res = { Productroll: listinfo.Productroll, uniqueIds: uniqueIds.value.length } orderInfoAfterRef.value.dataprocessing(res) + } }; const learcoupons = (data) => { if (data == 'product') { + console.log(listinfo) uniqueIds.value = [] // 筛选出商品卷的id listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额 listinfo.Productroll = 0 // 商品卷总价价格 + listinfo.pointsNum = 0 // 积分总价格 } else { // 每次点击优惠卷删除优惠卷里的id if (listinfo.coupondiscountAmount != 0) { @@ -539,6 +547,16 @@ uni.$off('returnData', handleReturnData); }); + + onShow(() => { + console.log(uni.cache.get('orderVIP')) + try { + paymentMethodref.value.orderVIPfun(uni.cache.get('orderVIP')) + } catch (error) { + //TODO handle the exception + } + }); + // 监听页面返回事件 onMounted(async () => { // 获取当前页面栈 @@ -552,13 +570,6 @@ // 每次进来全局更新shopId uni.cache.set('shopId', options.shopId, 30) uni.$on('returnData', handleReturnData); - // let res = await APIshopUserInfo({ - // shopId: options.shopId - // }) - // uni.cache.set('orderVIP', res) - // uni.cache.set('ordershopUserInfo', res.shopInfo) - // orderVIP.value = res - // ordershopUserInfo.value = res.shopInfo } try { // * 获取会员信息 diff --git a/pages/user/member/index.vue b/pages/user/member/index.vue index 39e82e2..e092048 100644 --- a/pages/user/member/index.vue +++ b/pages/user/member/index.vue @@ -327,6 +327,7 @@ returnUrl: '', //跳转地址 buyerRemark: '' }) + asyncshopUserInfo() } diff --git a/stores/order.js b/stores/order.js index 9f3cf70..2813b78 100644 --- a/stores/order.js +++ b/stores/order.js @@ -100,6 +100,7 @@ export const useCartStore = defineStore('cart', () => { }, 0); // 向下取整并保留两位小数 let result = roundUpToTwoDecimals(total, 'downward') + console.log(result) return result; // return Math.floor(total * 100) / 100; });