|
@@ -1,7 +1,7 @@
|
|
<template>
|
|
<template>
|
|
<s-layout title="确认订单">
|
|
<s-layout title="确认订单">
|
|
<!-- 头部地址选择【配送地址】【自提地址】 -->
|
|
<!-- 头部地址选择【配送地址】【自提地址】 -->
|
|
- <AddressSelection v-model="addressState" />
|
|
|
|
|
|
+ <AddressSelection v-if="spuType === '0'" v-model="addressState" />
|
|
|
|
|
|
<!-- 商品信息 -->
|
|
<!-- 商品信息 -->
|
|
<view class="order-card-box ss-m-b-14">
|
|
<view class="order-card-box ss-m-b-14">
|
|
@@ -27,7 +27,7 @@
|
|
/>
|
|
/>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
- <view v-if="state.orderInfo?.items.every(k => k.spuType !== '0')" class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10">
|
|
|
|
|
|
+ <view v-if="spuType !== '0'" class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10">
|
|
<view class="item-title">接收邮箱</view>
|
|
<view class="item-title">接收邮箱</view>
|
|
<view class="ss-flex ss-col-center">
|
|
<view class="ss-flex ss-col-center">
|
|
<uni-easyinput
|
|
<uni-easyinput
|
|
@@ -36,9 +36,11 @@
|
|
v-model="state.orderPayload.email"
|
|
v-model="state.orderPayload.email"
|
|
:inputBorder="false"
|
|
:inputBorder="false"
|
|
:clearable="false"
|
|
:clearable="false"
|
|
|
|
+ @blur="emailChange"
|
|
/>
|
|
/>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
+ <view v-if="spuType !== '0' && emailErrorMessage " class="emailErrorMessage ss-p-b-20 ss-p-r-20">邮箱格式不正确</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
<!-- 价格信息 -->
|
|
<!-- 价格信息 -->
|
|
@@ -238,8 +240,10 @@
|
|
import AddressSelection from '@/pages/order/addressSelection.vue';
|
|
import AddressSelection from '@/pages/order/addressSelection.vue';
|
|
import sheep from '@/sheep';
|
|
import sheep from '@/sheep';
|
|
import OrderApi from '@/sheep/api/trade/order';
|
|
import OrderApi from '@/sheep/api/trade/order';
|
|
|
|
+ import PrizeApi from '@/sheep/api/prizeDraw';
|
|
import TradeConfigApi from '@/sheep/api/trade/config';
|
|
import TradeConfigApi from '@/sheep/api/trade/config';
|
|
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
|
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
|
|
|
+ import test from '@/sheep/helper/test.js';
|
|
|
|
|
|
const state = reactive({
|
|
const state = reactive({
|
|
orderPayload: {},
|
|
orderPayload: {},
|
|
@@ -272,6 +276,13 @@
|
|
await getOrderInfo();
|
|
await getOrderInfo();
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ const emailErrorMessage = ref(false)
|
|
|
|
+ const emailChange = (e) => {
|
|
|
|
+ const email = e?.detail?.value
|
|
|
|
+ emailErrorMessage.value = Boolean(!email || !test.email(email))
|
|
|
|
+ if (emailErrorMessage.value) sheep.$helper.toast('邮箱格式不正确')
|
|
|
|
+ };
|
|
|
|
+
|
|
// 选择优惠券
|
|
// 选择优惠券
|
|
async function onSelectCoupon(couponId) {
|
|
async function onSelectCoupon(couponId) {
|
|
state.orderPayload.couponId = couponId;
|
|
state.orderPayload.couponId = couponId;
|
|
@@ -279,6 +290,20 @@
|
|
state.showCoupon = false;
|
|
state.showCoupon = false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 创建用户期望奖品所在城市记录
|
|
|
|
+ const setTargetData = async (orderId) => {
|
|
|
|
+ try {
|
|
|
|
+ await PrizeApi.luckTargetCreate({
|
|
|
|
+ orderId,
|
|
|
|
+ spuId: state.orderPayload.spuId,
|
|
|
|
+ skuId: state.orderInfo.items?.length && state.orderInfo.items[0].skuId,
|
|
|
|
+ target: state.orderPayload.city,
|
|
|
|
+ })
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log(error)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// 提交订单
|
|
// 提交订单
|
|
function onConfirm() {
|
|
function onConfirm() {
|
|
if (addressState.value.deliveryType === 1 && !addressState.value.addressInfo.id) {
|
|
if (addressState.value.deliveryType === 1 && !addressState.value.addressInfo.id) {
|
|
@@ -304,7 +329,8 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
console.log(state.orderPayload, 'submit-order-pay', state);
|
|
console.log(state.orderPayload, 'submit-order-pay', state);
|
|
- if (state.orderInfo.items.every(k => k.spuType !== '0') && !state.orderPayload.email) {
|
|
|
|
|
|
+ // if (spuType.value !== '0' && !state.orderPayload.email) state.orderPayload.email = '123@qq.com' // 测试
|
|
|
|
+ if (spuType.value !== '0' && !state.orderPayload.email) {
|
|
uni.showToast({ title: '请填写接收邮箱!', icon: 'none', duration: 2000 })
|
|
uni.showToast({ title: '请填写接收邮箱!', icon: 'none', duration: 2000 })
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -334,6 +360,9 @@
|
|
if (code !== 0) {
|
|
if (code !== 0) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (state.orderPayload?.city?.length) setTargetData(data.id)
|
|
|
|
+
|
|
// 更新购物车列表,如果来自购物车
|
|
// 更新购物车列表,如果来自购物车
|
|
if (state.orderPayload.items[0].cartId > 0) {
|
|
if (state.orderPayload.items[0].cartId > 0) {
|
|
sheep.$store('cart').getList();
|
|
sheep.$store('cart').getList();
|
|
@@ -343,6 +372,7 @@
|
|
if (data.payOrderId && data.payOrderId > 0) {
|
|
if (data.payOrderId && data.payOrderId > 0) {
|
|
sheep.$router.redirect('/pages/pay/index', {
|
|
sheep.$router.redirect('/pages/pay/index', {
|
|
id: data.payOrderId,
|
|
id: data.payOrderId,
|
|
|
|
+ salesLotterySpuId,
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
sheep.$router.redirect('/pages/order/detail', {
|
|
sheep.$router.redirect('/pages/order/detail', {
|
|
@@ -351,6 +381,8 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const spuType = ref('')
|
|
|
|
+ let salesLotterySpuId = ''
|
|
// 检查库存 & 计算订单价格
|
|
// 检查库存 & 计算订单价格
|
|
async function getOrderInfo() {
|
|
async function getOrderInfo() {
|
|
// 计算价格
|
|
// 计算价格
|
|
@@ -372,6 +404,9 @@
|
|
return code;
|
|
return code;
|
|
}
|
|
}
|
|
state.orderInfo = data;
|
|
state.orderInfo = data;
|
|
|
|
+ spuType.value = state.orderInfo?.items?.length && state.orderInfo.items.every(k => k.spuType === '0') ? '0' : ''
|
|
|
|
+ salesLotterySpuId = Boolean(!spuType.value) ? state.orderPayload?.spuId : ''
|
|
|
|
+
|
|
state.couponInfo = data.coupons || [];
|
|
state.couponInfo = data.coupons || [];
|
|
// 设置收货地址
|
|
// 设置收货地址
|
|
if (state.orderInfo.address) {
|
|
if (state.orderInfo.address) {
|
|
@@ -545,4 +580,10 @@
|
|
font-size: 36rpx;
|
|
font-size: 36rpx;
|
|
color: #999999;
|
|
color: #999999;
|
|
}
|
|
}
|
|
|
|
+ .emailErrorMessage {
|
|
|
|
+ background: #fff;
|
|
|
|
+ text-align: right;
|
|
|
|
+ color: #ff3000;
|
|
|
|
+ font-size: 24rpx;
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|