|
|
@@ -34,8 +34,8 @@ const model = reactive<{
|
|
|
const mobilePattern = /^1[3-9]\d{9}$/
|
|
|
const mobileRules = [{ required: true, pattern: mobilePattern, message: '请输入正确的手机号' }]
|
|
|
const deliveryType = ref(1)
|
|
|
+const isFreeShipping = ref(false) // isFreeShipping1免邮0不免邮
|
|
|
const isMemberGiftOrder = computed(() => !!orderInfo.value?.memberGiftItems?.length)
|
|
|
-const isSingleSkuOrder = computed(() => (orderInfo.value?.skuList?.length || 0) <= 1)
|
|
|
const isSelfPickup = computed(() => current.value === '自提')
|
|
|
const shopAddressInfo = computed(() => orderInfo.value?.shopAddressDTO)
|
|
|
const shopDistanceText = computed(() => {
|
|
|
@@ -70,7 +70,7 @@ const memberDiscountCents = computed(() => {
|
|
|
})
|
|
|
const offsetPoints = computed(() => {
|
|
|
const couponCents = Math.round(currentCouponDiscount.value * 100)
|
|
|
- const freightCents = isSelfPickup.value ? 0 : Math.round(Number(unref(orderInfo)?.transfee) * 100)
|
|
|
+ const freightCents = isFreeShipping.value || isSelfPickup.value ? 0 : Math.round(Number(unref(orderInfo)?.transfee) * 100)
|
|
|
const money = freightCents + Math.round(Number(unref(orderInfo)?.price) * 100) - couponCents - memberDiscountCents.value
|
|
|
const cap = Math.max(0, money)
|
|
|
if (Number(unref(orderInfo)?.offsetPoints) > cap) {
|
|
|
@@ -89,7 +89,7 @@ const displayTotalPrice = computed(() => {
|
|
|
return 0
|
|
|
}
|
|
|
const goodsPrice = Number(orderInfo.value.price || 0)
|
|
|
- const freight = Number(deliveryType.value !== 2 ? orderInfo.value.transfee : 0)
|
|
|
+ const freight = isFreeShipping.value || isSelfPickup.value ? 0 : Number(orderInfo.value.transfee || 0)
|
|
|
const couponDiscount = hasManualCouponSelection.value
|
|
|
? Number(confirmedCoupon.value?.discountMoney || 0)
|
|
|
: Number(orderInfo.value?.coupon || 0)
|
|
|
@@ -114,16 +114,13 @@ onLoad((options: any) => {
|
|
|
})
|
|
|
onShow(() => {
|
|
|
useUserStore().getuserAddresslist()
|
|
|
- if (orderInfo.value && current.value === '即时配送' && (isSingleSkuOrder.value || isMemberGiftOrder.value)) {
|
|
|
- getConfirmOrder()
|
|
|
- }
|
|
|
+ getConfirmOrder()
|
|
|
+ // checkAddressFreeShipping()
|
|
|
})
|
|
|
|
|
|
watch(current, async (value) => {
|
|
|
deliveryType.value = value === '自提' ? 2 : 3
|
|
|
- if (orderInfo.value && (isSingleSkuOrder.value || isMemberGiftOrder.value)) {
|
|
|
- await getConfirmOrder()
|
|
|
- }
|
|
|
+ await getConfirmOrder()
|
|
|
})
|
|
|
|
|
|
function getCouponDisplayName(coupon?: Partial<Api.AppMemberCouponVO> & Record<string, any>) {
|
|
|
@@ -138,19 +135,26 @@ function syncCouponState() {
|
|
|
}
|
|
|
|
|
|
function getOrderConfirmParams() {
|
|
|
- const firstSku = orderInfo.value?.skuList?.[0]
|
|
|
+ const skuList = orderInfo.value?.skuList || []
|
|
|
+ const firstSku = skuList[0]
|
|
|
return {
|
|
|
- skuId: firstSku?.skuId,
|
|
|
- num: Number(firstSku?.num || 1),
|
|
|
channelId: userInfo.value?.channelId,
|
|
|
shopId: Number(firstSku?.shopId || SelectShopInfo.value?.shopId || 2),
|
|
|
dvyType: deliveryType.value,
|
|
|
+ addressId: selectedAddress.value?.id,
|
|
|
+ shopSkuDTOList: skuList.map(it => ({
|
|
|
+ skuId: it.skuId,
|
|
|
+ num: Number(it.num || 1),
|
|
|
+ })),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async function getConfirmOrder() {
|
|
|
+ if (!orderInfo.value) {
|
|
|
+ return
|
|
|
+ }
|
|
|
const params: Record<string, any> = getOrderConfirmParams()
|
|
|
- if (!params.skuId) {
|
|
|
+ if (!params.shopSkuDTOList?.length) {
|
|
|
return
|
|
|
}
|
|
|
if (isSelfPickup.value) {
|
|
|
@@ -166,7 +170,6 @@ async function getConfirmOrder() {
|
|
|
data: params,
|
|
|
})
|
|
|
if (isMemberGiftOrder.value) {
|
|
|
- // 赠品订单仅更新配送费和店铺地址信息,保留原始商品数据
|
|
|
orderInfo.value = {
|
|
|
...orderInfo.value,
|
|
|
transfee: res.data.transfee ?? orderInfo.value?.transfee ?? 0,
|
|
|
@@ -174,15 +177,12 @@ async function getConfirmOrder() {
|
|
|
} as ConfirmOrderInfo
|
|
|
}
|
|
|
else {
|
|
|
- const originalSku = orderInfo.value?.skuList?.[0]
|
|
|
- const skuList = res.data.sku
|
|
|
- ? [{ ...res.data.sku, id: originalSku?.id, num: params.num, shopId: params.shopId }]
|
|
|
- : (orderInfo.value?.skuList || [])
|
|
|
orderInfo.value = {
|
|
|
...orderInfo.value,
|
|
|
...res.data,
|
|
|
- skuList,
|
|
|
+ skuList: res.data.sku || orderInfo.value?.skuList || [],
|
|
|
} as ConfirmOrderInfo
|
|
|
+ isFreeShipping.value = res.data.isFreeShipping === 1
|
|
|
syncCouponState()
|
|
|
}
|
|
|
}
|
|
|
@@ -196,6 +196,38 @@ function openShopLocation() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// async function checkAddressFreeShipping() {
|
|
|
+// if (isSelfPickup.value || !selectedAddress.value) {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if (selectedAddress.value.id === lastAddressId.value) {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// lastAddressId.value = selectedAddress.value.id
|
|
|
+// const res = await Apis.xsb.addressFreeShippingCheck({
|
|
|
+// params: { addressId: selectedAddress.value.id },
|
|
|
+// })
|
|
|
+// if (res.data.check) {
|
|
|
+// const freeShippingData = res.data.addressFreeShippingVo
|
|
|
+// if (freeShippingData) {
|
|
|
+// isFreeShipping.value = freeShippingData.isFreeShipping === 1
|
|
|
+// if (freeShippingData.totalPrice !== undefined) {
|
|
|
+// orderInfo.value = {
|
|
|
+// ...orderInfo.value!,
|
|
|
+// totalPrice: freeShippingData.totalPrice,
|
|
|
+// } as ConfirmOrderInfo
|
|
|
+// }
|
|
|
+// if (freeShippingData.transfee !== undefined) {
|
|
|
+// orderInfo.value = {
|
|
|
+// ...orderInfo.value!,
|
|
|
+// transfee: freeShippingData.transfee,
|
|
|
+// } as ConfirmOrderInfo
|
|
|
+// }
|
|
|
+// }
|
|
|
+// console.log(orderInfo.value, '===商品数据===')
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
async function openCouponPopup() {
|
|
|
draftCouponId.value = confirmedCouponId.value
|
|
|
couponPopup.value = true
|
|
|
@@ -287,6 +319,7 @@ async function handlePay() {
|
|
|
consigneeMobile: model.value2,
|
|
|
}
|
|
|
: undefined,
|
|
|
+ isFreeShipping.value,
|
|
|
)
|
|
|
const payMent = await useUserStore().getPayMent(orderNumber)
|
|
|
const skuList = orderInfo.value?.skuList || []
|
|
|
@@ -441,7 +474,7 @@ async function handlePay() {
|
|
|
¥{{ orderInfo?.price }}
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="mb28rpx flex items-center justify-between text-28rpx">
|
|
|
+ <view v-if="!isFreeShipping" class="mb28rpx flex items-center justify-between text-28rpx">
|
|
|
<view v-if="deliveryType == 3">
|
|
|
配送费(即时配送)
|
|
|
</view>
|