【功能优化】订单确认页,增加按照顺序自动选择物流方式,替代原有只选择“快递配送”的方式
parent
4dd6e82309
commit
789ec69933
|
@ -29,9 +29,9 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="flex flex-wrap">
|
<view class="flex flex-wrap">
|
||||||
<text class="default font-color" v-if="state.addressInfo.defaultStatus">[默认]</text>
|
<text class="default font-color" v-if="state.addressInfo.defaultStatus">[默认]</text>
|
||||||
<text class="line2"
|
<text class="line2">
|
||||||
>{{ state.addressInfo.areaName }} {{ state.addressInfo.detailAddress }}</text
|
{{ state.addressInfo.areaName }} {{ state.addressInfo.detailAddress }}
|
||||||
>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="addressCon" v-else>
|
<view class="addressCon" v-else>
|
||||||
|
@ -44,7 +44,11 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 情况二:门店的选择 -->
|
<!-- 情况二:门店的选择 -->
|
||||||
<view class="address flex flex-wrap flex-center ss-row-between" v-else @tap="onSelectAddress">
|
<view
|
||||||
|
class="address flex flex-wrap flex-center ss-row-between"
|
||||||
|
v-if="state.deliveryType === 2"
|
||||||
|
@tap="onSelectAddress"
|
||||||
|
>
|
||||||
<view class="addressCon" v-if="state.pickUpInfo.name">
|
<view class="addressCon" v-if="state.pickUpInfo.name">
|
||||||
<view class="name"
|
<view class="name"
|
||||||
>{{ state.pickUpInfo.name }}
|
>{{ state.pickUpInfo.name }}
|
||||||
|
|
|
@ -244,7 +244,7 @@
|
||||||
|
|
||||||
const addressState = ref({
|
const addressState = ref({
|
||||||
addressInfo: {}, // 选择的收货地址
|
addressInfo: {}, // 选择的收货地址
|
||||||
deliveryType: 1, // 收货方式:1-快递配送,2-门店自提
|
deliveryType: undefined, // 收货方式:1-快递配送,2-门店自提
|
||||||
isPickUp: true, // 门店自提是否开启
|
isPickUp: true, // 门店自提是否开启
|
||||||
pickUpInfo: {}, // 选择的自提门店信息
|
pickUpInfo: {}, // 选择的自提门店信息
|
||||||
receiverName: '', // 收件人名称
|
receiverName: '', // 收件人名称
|
||||||
|
@ -349,7 +349,7 @@
|
||||||
pointActivityId: state.orderPayload.pointActivityId,
|
pointActivityId: state.orderPayload.pointActivityId,
|
||||||
});
|
});
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
return;
|
return code;
|
||||||
}
|
}
|
||||||
state.orderInfo = data;
|
state.orderInfo = data;
|
||||||
state.couponInfo = data.coupons || [];
|
state.couponInfo = data.coupons || [];
|
||||||
|
@ -357,20 +357,41 @@
|
||||||
if (state.orderInfo.address) {
|
if (state.orderInfo.address) {
|
||||||
addressState.value.addressInfo = state.orderInfo.address;
|
addressState.value.addressInfo = state.orderInfo.address;
|
||||||
}
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
|
// 解析参数
|
||||||
if (!options.data) {
|
if (!options.data) {
|
||||||
sheep.$helper.toast('参数不正确,请检查!');
|
sheep.$helper.toast('参数不正确,请检查!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.orderPayload = JSON.parse(options.data);
|
state.orderPayload = JSON.parse(options.data);
|
||||||
await getOrderInfo();
|
|
||||||
// 获取交易配置
|
// 获取交易配置
|
||||||
const { data, code } = await TradeConfigApi.getTradeConfig();
|
const { data, code } = await TradeConfigApi.getTradeConfig();
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
addressState.value.isPickUp = data.deliveryPickUpEnabled;
|
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 监听地址和配送方式的变化
|
// 使用 watch 监听地址和配送方式的变化
|
||||||
|
|
|
@ -6,6 +6,9 @@ const TradeConfigApi = {
|
||||||
return request({
|
return request({
|
||||||
url: `/trade/config/get`,
|
url: `/trade/config/get`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
custom: {
|
||||||
|
showLoading: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,6 +35,9 @@ const OrderApi = {
|
||||||
if (!(data.pointActivityId > 0)) {
|
if (!(data.pointActivityId > 0)) {
|
||||||
delete data2.pointActivityId;
|
delete data2.pointActivityId;
|
||||||
}
|
}
|
||||||
|
if (!(data.deliveryType > 0)) {
|
||||||
|
delete data2.deliveryType;
|
||||||
|
}
|
||||||
// 解决 SpringMVC 接受 List<Item> 参数的问题
|
// 解决 SpringMVC 接受 List<Item> 参数的问题
|
||||||
delete data2.items;
|
delete data2.items;
|
||||||
for (let i = 0; i < data.items.length; i++) {
|
for (let i = 0; i < data.items.length; i++) {
|
||||||
|
|
Loading…
Reference in New Issue