feat: 选品广场/会员优选添加自提模块

This commit is contained in:
2026-07-15 13:41:16 +08:00
parent 26c8f721f7
commit ea5b1c2532
4 changed files with 308 additions and 67 deletions
+118 -20
View File
@@ -1,7 +1,7 @@
<template>
<s-pages title="确认订单" :pink_bg="true">
<view class="p-b-132">
<AddressSelection v-model="addressState" theme="2" @getSettlementInfo="getSettlementInfo" />
<AddressSelection v-model="addressState" theme="2" />
<view class="p-x-32 m-t-24">
<view class="bg24 p-x-20 p-t-20 radius16">
<view v-if="settlementInfo.items && settlementInfo.items.length">
@@ -14,10 +14,41 @@
<view class="c25 size28">商品金额</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.totalPrice || 0) }}</view>
</view>
<view class="flex-row ju-between m-b-36">
<view
class="flex-row ju-between m-b-36"
v-if="addressState.deliveryType === DeliveryTypeEnum.EXPRESS.type"
>
<view class="c25 size28">运费</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.deliveryPrice || 0) }}</view>
</view>
<view
class="flex-row ju-between m-b-36"
v-if="addressState.deliveryType === DeliveryTypeEnum.PICK_UP.type"
>
<view class="c25 size28">联系人</view>
<uni-easyinput
class="order-input"
maxlength="20"
placeholder="请填写您的联系姓名"
v-model="addressState.receiverName"
:inputBorder="false"
:clearable="false"
/>
</view>
<view
class="flex-row ju-between m-b-36"
v-if="addressState.deliveryType === DeliveryTypeEnum.PICK_UP.type"
>
<view class="c25 size28">联系电话</view>
<uni-easyinput
class="order-input"
maxlength="20"
placeholder="请填写您的联系电话"
v-model="addressState.receiverMobile"
:inputBorder="false"
:clearable="false"
/>
</view>
<view class="flex-center ju-flex-end borderTop">
<span class="size26 line96">合计: </span>
<span class="c13 size28 m-l-12 line96 weight900"
@@ -35,38 +66,51 @@
</s-pages>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance } from 'vue';
import { ref, getCurrentInstance, watch } from 'vue';
import AddressSelection from '@/pages/order/addressSelection.vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import aiOrder from '@/components/ai_order/ai_order';
let { proxy } = getCurrentInstance();
import api from '@/sheep/api/member/address';
import * as SpuApi from '@/sheep/api/ai/index';
import { DeliveryTypeEnum } from '@/sheep/helper/const';
const addressState = ref({
addressInfo: {},
deliveryType: 1,
isPickUp: false,
deliveryType: DeliveryTypeEnum.EXPRESS.type,
isPickUp: true,
pickUpInfo: {},
receiverName: '',
receiverMobile: '',
});
let remark_value = ref();
let spuId = ref();
let spuPrice = ref();
const isSubmitting = ref(false);
const settlementInfo = ref<any>({});
let addressId = ref('');
const getSettlementInfo = (id = '') => {
addressId.value = id;
SpuApi.getGiftSettlementInfo({
id: id,
const lastSettlementQuery = ref('');
const getSettlementRequestId = () => String(addressState.value.addressInfo?.id || '');
const getSettlementInfo = () => {
const query = {
id: getSettlementRequestId(),
spuId: spuId.value,
deliveryType: addressState.value.deliveryType,
pickUpStoreId:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? String(addressState.value.pickUpInfo?.id || '')
: undefined,
};
const queryKey = JSON.stringify(query);
if (queryKey === lastSettlementQuery.value) {
return;
}
lastSettlementQuery.value = queryKey;
SpuApi.getGiftSettlementInfo({
...query,
}).then((res: any) => {
settlementInfo.value = res.data || {};
// 设置收货地址
if (res.data.address) {
if (!addressState.value.addressInfo?.id && res.data.address) {
addressState.value.addressInfo = res.data.address;
}
// if (settlementInfo.value?.items?.length) {
@@ -88,12 +132,44 @@
if (isSubmitting.value) {
return;
}
if (!addressId.value) return proxy.utils.toast('请选择地址');
if (
addressState.value.deliveryType === DeliveryTypeEnum.EXPRESS.type &&
!addressState.value.addressInfo?.id
) {
return proxy.utils.toast('请选择收货地址');
}
if (addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type) {
if (!addressState.value.pickUpInfo?.id) {
return proxy.utils.toast('请选择自提门店');
}
if (addressState.value.receiverName === '' || addressState.value.receiverMobile === '') {
return proxy.utils.toast('请填写联系人或联系人电话');
}
if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(addressState.value.receiverName)) {
return proxy.utils.toast('请填写您的真实姓名');
}
if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(addressState.value.receiverMobile)) {
return proxy.utils.toast('请填写正确的手机号');
}
}
isSubmitting.value = true;
try {
let res: any = await SpuApi.createOrderOpen({
id: addressId.value,
id: getSettlementRequestId(),
spuId: spuId.value,
deliveryType: addressState.value.deliveryType,
pickUpStoreId:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.pickUpInfo?.id
: undefined,
receiverName:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverName
: undefined,
receiverPhone:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverMobile
: undefined,
userRemark: remark_value.value,
});
if (res.code === 0) {
@@ -115,12 +191,10 @@
const getAddress = () => {
api.getAddressList().then((res: any) => {
if (res.code === 0 && res.data?.length) {
// addressState.value.addressInfo = res.data[0];
// getSettlementInfo(res.data[0].id);
let index = res.data.findIndex((e) => e.defaultStatus);
let index = res.data.findIndex((e: any) => e.defaultStatus);
if (index !== -1) {
addressState.value.addressInfo = res.data[index];
getSettlementInfo(res.data[index].id);
getSettlementInfo();
} else {
getSettlementInfo();
}
@@ -134,15 +208,27 @@
// spuId.value = options.id;
// }
// if (options.price) {
// spuPrice.value = options.price;
// }
// getSettlementInfo();
// });
onLoad((e) => {
onLoad((e: any) => {
// getCartList();
spuId.value = e.id;
// console.log(e.id);
});
watch(
() => [
addressState.value.deliveryType,
addressState.value.addressInfo?.id,
addressState.value.pickUpInfo?.id,
spuId.value,
],
() => {
getSettlementInfo();
},
);
onShow(() => {
getAddress();
});
@@ -171,6 +257,18 @@
border-top: 1rpx solid #dfdfdf;
padding: 12rpx 0;
}
:deep(.order-input) {
width: 320rpx;
}
:deep(.order-input .uni-easyinput__content) {
background: transparent !important;
}
:deep(.order-input .uni-easyinput__content-input) {
text-align: right !important;
font-size: 26rpx;
height: 56rpx;
padding-right: 0 !important;
}
.ai-button2--disabled {
opacity: 0.6;
pointer-events: none;
+14 -1
View File
@@ -45,6 +45,13 @@
@getOrderDetail="getOrderDetail"
></card_order>
<PickUpVerify
v-if="Number(state.orderInfo.deliveryType) === 2"
ref="pickUpVerifyRef"
:orderInfo="state.orderInfo"
:systemStore="systemStore"
/>
<!-- 价格信息 -->
<view class="order-price-box bg24">
<view class="notice-item ss-flex ss-row-between" v-for="(v, i) in priceArr" :key="i">
@@ -130,7 +137,7 @@
handleOrderButtons,
} from '@/sheep/hooks/useGoods';
import * as OrderApi from '@/sheep/api/ai/index';
import DeliveryApi from '@/sheep/api/trade/delivery';
import StoreApi from '@/sheep/api/trade/store';
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
import card_order from '@/components/orderItem/card_order.vue';
@@ -190,6 +197,12 @@
if (res.code === 0) {
state.orderInfo = res.data;
handleOrderButtons(state.orderInfo);
if (res.data.pickUpStoreId) {
const { data } = await StoreApi.getStoreById(res.data.pickUpStoreId);
systemStore.value = data || {};
} else {
systemStore.value = {};
}
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
}
+129 -42
View File
@@ -1,7 +1,7 @@
<template>
<s-pages title="确认订单" :pink_bg="true">
<view class="p-b-132">
<AddressSelection v-model="addressState" theme="2" @getSettlementInfo="getSettlementInfo" />
<AddressSelection v-model="addressState" theme="2" />
<view class="p-x-32 m-t-24">
<view class="bg24 p-x-20 p-t-20 radius16">
<view v-if="settlementInfo.items && settlementInfo.items.length">
@@ -11,12 +11,34 @@
</view>
<view class="flex-row ju-between m-b-36">
<view class="c25 size28">商品金额</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.payPrice || 0) }}</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.totalPrice || 0) }}</view>
</view>
<view class="flex-row ju-between m-b-36">
<view class="flex-row ju-between m-b-36" v-if="addressState.deliveryType === DeliveryTypeEnum.EXPRESS.type">
<view class="c25 size28">运费</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.deliveryPrice || 0) }}</view>
</view>
<view class="flex-row ju-between m-b-36" v-if="addressState.deliveryType === DeliveryTypeEnum.PICK_UP.type">
<view class="c25 size28">联系人</view>
<uni-easyinput
class="order-input"
maxlength="20"
placeholder="请填写您的联系姓名"
v-model="addressState.receiverName"
:inputBorder="false"
:clearable="false"
/>
</view>
<view class="flex-row ju-between m-b-36" v-if="addressState.deliveryType === DeliveryTypeEnum.PICK_UP.type">
<view class="c25 size28">联系电话</view>
<uni-easyinput
class="order-input"
maxlength="20"
placeholder="请填写您的联系电话"
v-model="addressState.receiverMobile"
:inputBorder="false"
:clearable="false"
/>
</view>
<view class="flex-center ju-flex-end borderTop">
<span class="size26 line96">合计: </span>
<span class="c13 size28 m-l-12 line96 weight900"
@@ -32,54 +54,69 @@
</s-pages>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import { ref, getCurrentInstance, watch } from 'vue';
import AddressSelection from '@/pages/order/addressSelection.vue';
import { onLoad } from '@dcloudio/uni-app';
import aiOrder from '@/components/ai_order/ai_order';
import api from '@/sheep/api/member/address';
let { proxy } = getCurrentInstance();
import * as SpuApi from '@/sheep/api/ai/index';
import { DeliveryTypeEnum } from '@/sheep/helper/const';
const addressState = ref({
addressInfo: {}, // 选择的收货地址
deliveryType: 1, // 收货方式:1-快递配送,2-门店自提
isPickUp: false, // 门店自提是否开启
deliveryType: DeliveryTypeEnum.EXPRESS.type, // 收货方式:1-快递配送,2-门店自提
isPickUp: true, // 门店自提是否开启
pickUpInfo: {}, // 选择的自提门店信息
receiverName: '', // 收件人名称
receiverMobile: '', // 收件人手机
});
const cartList = ref([]);
const getCartList = () => {
SpuApi.getShopCartList({}).then((res) => {
let list = res.data || [];
if (list.length) {
list.forEach((e) => {
e.skuArr = JSON.parse(e.specification);
});
}
cartList.value = list;
});
};
// 获取订单结算信息
const settlementInfo = ref({});
let addressId = ref('');
const getSettlementInfo = (id = '') => {
addressId.value = id;
SpuApi.getSettlementInfo({
id: id,
}).then((res) => {
const settlementInfo = ref<any>({});
const lastSettlementQuery = ref('');
const getSettlementRequestId = () => String(addressState.value.addressInfo?.id || '');
const getSettlementInfo = () => {
const query = {
id: getSettlementRequestId(),
deliveryType: addressState.value.deliveryType,
pickUpStoreId:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? String(addressState.value.pickUpInfo?.id || '')
: undefined,
receiverName:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverName
: undefined,
receiverPhone:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverMobile
: undefined,
};
const queryKey = JSON.stringify(query);
if (queryKey === lastSettlementQuery.value) {
return;
}
lastSettlementQuery.value = queryKey;
SpuApi.getSettlementInfo(query).then((res: any) => {
settlementInfo.value = res.data || {};
if (
!addressState.value.addressInfo?.id &&
res.data?.address &&
addressState.value.deliveryType === DeliveryTypeEnum.EXPRESS.type
) {
addressState.value.addressInfo = res.data.address;
}
// if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
// proxy.utils.toast('订单金额不能超过5000元');
// }
if (settlementInfo.value?.items?.length) {
settlementInfo.value.items.forEach((e) => {
settlementInfo.value.items.forEach((e: any) => {
e.skuArr = e.items;
e.skuArr.forEach((item) => {
e.skuArr.forEach((item: any) => {
item.propertyText = '';
item.properties.forEach((e1) => {
item.properties.forEach((e1: any) => {
item.propertyText += e1.valueName + ' ';
});
});
@@ -87,13 +124,45 @@
}
});
};
const sub = async () => {
// if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
// proxy.utils.toast('订单金额不能超过5000元, 请重新选择商品');
// return;
// }
if (!addressId.value) return proxy.utils.toast('请选择地址');
let res: any = await SpuApi.createOrder({ id: addressId.value });
if (addressState.value.deliveryType === DeliveryTypeEnum.EXPRESS.type && !addressState.value.addressInfo?.id) {
return proxy.utils.toast('请选择收货地址');
}
if (addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type) {
if (!addressState.value.pickUpInfo?.id) {
return proxy.utils.toast('请选择自提门店');
}
if (addressState.value.receiverName === '' || addressState.value.receiverMobile === '') {
return proxy.utils.toast('请填写联系人或联系人电话');
}
if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(addressState.value.receiverName)) {
return proxy.utils.toast('请填写您的真实姓名');
}
if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(addressState.value.receiverMobile)) {
return proxy.utils.toast('请填写正确的手机号');
}
}
let res: any = await SpuApi.createOrder({
id: getSettlementRequestId(),
deliveryType: addressState.value.deliveryType,
pickUpStoreId:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.pickUpInfo?.id
: undefined,
receiverName:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverName
: undefined,
receiverPhone:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverMobile
: undefined,
});
if (res.code === 0) {
// proxy.utils.toast('下单成功');
setTimeout(() => {
@@ -114,14 +183,12 @@
}
};
const getAddress = () => {
api.getAddressList().then((res) => {
api.getAddressList().then((res: any) => {
if (res.code === 0 && res.data?.length) {
// addressState.value.addressInfo = res.data[0];
// getSettlementInfo(res.data[0].id);
let index = res.data.findIndex((e) => e.defaultStatus);
let index = res.data.findIndex((e: any) => e.defaultStatus);
if (index !== -1) {
addressState.value.addressInfo = res.data[index];
getSettlementInfo(res.data[index].id);
getSettlementInfo();
} else {
getSettlementInfo();
}
@@ -130,22 +197,42 @@
}
});
};
watch(
() => [
addressState.value.deliveryType,
addressState.value.addressInfo?.id,
addressState.value.pickUpInfo?.id,
],
() => {
getSettlementInfo();
},
);
onLoad(() => {
// getCartList();
getAddress();
});
</script>
<style lang="scss" scoped>
.pages {
}
.bottom {
}
.borderTop {
border-top: 1px solid #d4d4d4;
}
:deep(.order-input) {
width: 320rpx;
}
:deep(.order-input .uni-easyinput__content) {
background: transparent !important;
}
:deep(.order-input .uni-easyinput__content-input) {
text-align: right !important;
font-size: 26rpx;
height: 56rpx;
padding-right: 0 !important;
}
.btn {
width: 100%;
position: fixed;