feat: 选品广场/会员优选添加自提模块
This commit is contained in:
+118
-20
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user