From 789ec69933dcad7c0f6ec56d9e16017025fbe242 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 13 Oct 2024 21:30:14 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E8=AE=A2=E5=8D=95=E7=A1=AE=E8=AE=A4=E9=A1=B5=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=89=E7=85=A7=E9=A1=BA=E5=BA=8F=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=80=89=E6=8B=A9=E7=89=A9=E6=B5=81=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E6=9B=BF=E4=BB=A3=E5=8E=9F=E6=9C=89=E5=8F=AA=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E2=80=9C=E5=BF=AB=E9=80=92=E9=85=8D=E9=80=81=E2=80=9D?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/order/addressSelection.vue | 12 ++++++++---- pages/order/confirm.vue | 27 ++++++++++++++++++++++++--- sheep/api/trade/config.js | 3 +++ sheep/api/trade/order.js | 3 +++ 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/pages/order/addressSelection.vue b/pages/order/addressSelection.vue index d54c68d3..d4789ea0 100644 --- a/pages/order/addressSelection.vue +++ b/pages/order/addressSelection.vue @@ -29,9 +29,9 @@ [默认] - {{ state.addressInfo.areaName }} {{ state.addressInfo.detailAddress }} + + {{ state.addressInfo.areaName }} {{ state.addressInfo.detailAddress }} + @@ -44,7 +44,11 @@ - + {{ state.pickUpInfo.name }} diff --git a/pages/order/confirm.vue b/pages/order/confirm.vue index 426df6d9..5e8e2ba4 100644 --- a/pages/order/confirm.vue +++ b/pages/order/confirm.vue @@ -244,7 +244,7 @@ const addressState = ref({ addressInfo: {}, // 选择的收货地址 - deliveryType: 1, // 收货方式:1-快递配送,2-门店自提 + deliveryType: undefined, // 收货方式:1-快递配送,2-门店自提 isPickUp: true, // 门店自提是否开启 pickUpInfo: {}, // 选择的自提门店信息 receiverName: '', // 收件人名称 @@ -349,7 +349,7 @@ pointActivityId: state.orderPayload.pointActivityId, }); if (code !== 0) { - return; + return code; } state.orderInfo = data; state.couponInfo = data.coupons || []; @@ -357,20 +357,41 @@ if (state.orderInfo.address) { addressState.value.addressInfo = state.orderInfo.address; } + return code; } onLoad(async (options) => { + // 解析参数 if (!options.data) { sheep.$helper.toast('参数不正确,请检查!'); return; } state.orderPayload = JSON.parse(options.data); - await getOrderInfo(); + // 获取交易配置 const { data, code } = await TradeConfigApi.getTradeConfig(); if (code === 0) { addressState.value.isPickUp = data.deliveryPickUpEnabled; } + + // 价格计算 + // 情况一:先自动选择“快递物流” + addressState.value.deliveryType = 1; + let orderCode = await getOrderInfo(); + if (orderCode === 0) { + return; + } + // 情况二:失败,再自动选择“门店自提” + if (addressState.value.isPickUp) { + addressState.value.deliveryType = 2; + let orderCode = await getOrderInfo(); + if (orderCode === 0) { + return; + } + } + // 情况三:都失败,则不选择 + addressState.value.deliveryType = undefined; + await getOrderInfo(); }); // 使用 watch 监听地址和配送方式的变化 diff --git a/sheep/api/trade/config.js b/sheep/api/trade/config.js index 16806ed8..d49235e4 100644 --- a/sheep/api/trade/config.js +++ b/sheep/api/trade/config.js @@ -6,6 +6,9 @@ const TradeConfigApi = { return request({ url: `/trade/config/get`, method: 'GET', + custom: { + showLoading: false, + }, }); }, }; diff --git a/sheep/api/trade/order.js b/sheep/api/trade/order.js index 4091c0dc..10cb6352 100644 --- a/sheep/api/trade/order.js +++ b/sheep/api/trade/order.js @@ -35,6 +35,9 @@ const OrderApi = { if (!(data.pointActivityId > 0)) { delete data2.pointActivityId; } + if (!(data.deliveryType > 0)) { + delete data2.deliveryType; + } // 解决 SpringMVC 接受 List 参数的问题 delete data2.items; for (let i = 0; i < data.items.length; i++) {