|
@@ -1,13 +1,7 @@
|
|
|
<template>
|
|
|
<s-layout title="确认订单">
|
|
|
- <!-- TODO:这个判断先删除 v-if="state.orderInfo.need_address === 1" -->
|
|
|
- <view class="bg-white address-box ss-m-b-14 ss-r-b-10" @tap="onSelectAddress">
|
|
|
- <s-address-item :item="state.addressInfo" :hasBorderBottom="false">
|
|
|
- <view class="ss-rest-button">
|
|
|
- <text class="_icon-forward" />
|
|
|
- </view>
|
|
|
- </s-address-item>
|
|
|
- </view>
|
|
|
+ <!-- 头部地址选择【配送地址】【自提地址】 -->
|
|
|
+ <AddressSelection v-model="addressState"></AddressSelection>
|
|
|
|
|
|
<!-- 商品信息 -->
|
|
|
<view class="order-card-box ss-m-b-14">
|
|
@@ -47,25 +41,58 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- TODO 芋艿:接入积分 -->
|
|
|
+ <!-- TODO puhui999: v-if="state.orderInfo.type === 0 && state.orderPayload.order_type === 'normal'" -->
|
|
|
+ <!-- TODO puhui999: 没有搞懂 order_type 和 orderInfo.type 的区别和作用暂时不考虑 order_type 条件-->
|
|
|
<view
|
|
|
class="order-item ss-flex ss-col-center ss-row-between"
|
|
|
- v-if="state.orderPayload.order_type === 'score'"
|
|
|
+ v-if="state.orderInfo.type === 0"
|
|
|
>
|
|
|
- <view class="item-title">扣除积分</view>
|
|
|
+ <view class="item-title">积分抵扣</view>
|
|
|
<view class="ss-flex ss-col-center">
|
|
|
+ {{ state.pointStatus ? '剩余积分' : '当前积分' }}
|
|
|
<image
|
|
|
:src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
|
|
|
class="score-img"
|
|
|
/>
|
|
|
- <text class="item-value ss-m-r-24">{{ state.orderInfo.score_amount }}</text>
|
|
|
+ <text class="item-value ss-m-r-24">
|
|
|
+ {{ state.pointStatus ? state.orderInfo.totalPoint - state.orderInfo.usePoint : (state.orderInfo.totalPoint || 0) }}
|
|
|
+ </text>
|
|
|
+ <checkbox-group @change="changeIntegral">
|
|
|
+ <checkbox :checked='state.pointStatus' :disabled="!state.orderInfo.totalPoint || state.orderInfo.totalPoint <= 0" />
|
|
|
+ </checkbox-group>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="order-item ss-flex ss-col-center ss-row-between">
|
|
|
+ <view class="order-item ss-flex ss-col-center ss-row-between" v-if='addressState.deliveryType === 1'>
|
|
|
<view class="item-title">运费</view>
|
|
|
<view class="ss-flex ss-col-center">
|
|
|
- <text class="item-value ss-m-r-24">
|
|
|
+ <text class="item-value ss-m-r-24" v-if="state.orderInfo.price.deliveryPrice > 0">
|
|
|
+¥{{ fen2yuan(state.orderInfo.price.deliveryPrice) }}
|
|
|
</text>
|
|
|
+ <view class='item-value ss-m-r-24' v-else>免运费</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="order-item ss-flex ss-col-center ss-row-between" v-if='addressState.deliveryType === 2'>
|
|
|
+ <view class="item-title">联系人</view>
|
|
|
+ <view class="ss-flex ss-col-center">
|
|
|
+ <uni-easyinput
|
|
|
+ maxlength="20"
|
|
|
+ placeholder="请填写您的联系姓名"
|
|
|
+ v-model="addressState.receiverName"
|
|
|
+ :inputBorder="false"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="order-item ss-flex ss-col-center ss-row-between" v-if='addressState.deliveryType === 2'>
|
|
|
+ <view class="item-title">联系电话</view>
|
|
|
+ <view class="ss-flex ss-col-center">
|
|
|
+ <uni-easyinput
|
|
|
+ maxlength="20"
|
|
|
+ placeholder="请填写您的联系电话"
|
|
|
+ v-model="addressState.receiverMobile"
|
|
|
+ :inputBorder="false"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 优惠劵:只有 type = 0 普通订单(非拼团、秒杀、砍价),才可以使用优惠劵 -->
|
|
@@ -120,7 +147,7 @@
|
|
|
共{{ state.orderInfo.items.reduce((acc, item) => acc + item.count, 0) }}件
|
|
|
</view>
|
|
|
<view>合计:</view>
|
|
|
- <view class="total-num text-red"> ¥{{ fen2yuan(state.orderInfo.price.payPrice) }} </view>
|
|
|
+ <view class="total-num text-red"> ¥{{ fen2yuan(state.orderInfo.price.payPrice) }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
@@ -159,14 +186,13 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
- import { reactive } from 'vue';
|
|
|
+ import { reactive, ref } from 'vue';
|
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
|
+ import AddressSelection from '@/pages/order/addressSelection.vue';
|
|
|
import sheep from '@/sheep';
|
|
|
- import { isEmpty } from 'lodash';
|
|
|
import OrderApi from '@/sheep/api/trade/order';
|
|
|
import CouponApi from '@/sheep/api/promotion/coupon';
|
|
|
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
|
|
- import { WxaSubscribeTemplate } from '@/sheep/util/const';
|
|
|
|
|
|
const state = reactive({
|
|
|
orderPayload: {},
|
|
@@ -174,27 +200,30 @@
|
|
|
items: [], // 商品项列表
|
|
|
price: {}, // 价格信息
|
|
|
},
|
|
|
- addressInfo: {}, // 选择的收货地址
|
|
|
showCoupon: false, // 是否展示优惠劵
|
|
|
couponInfo: [], // 优惠劵列表
|
|
|
showDiscount: false, // 是否展示营销活动
|
|
|
+ // ========== 积分 ==========
|
|
|
+ pointStatus: false, //是否使用积分
|
|
|
});
|
|
|
|
|
|
- // 选择地址
|
|
|
- function onSelectAddress() {
|
|
|
- uni.$once('SELECT_ADDRESS', (e) => {
|
|
|
- changeConsignee(e.addressInfo);
|
|
|
- });
|
|
|
- sheep.$router.go('/pages/user/address/list');
|
|
|
- }
|
|
|
+ const addressState = ref({
|
|
|
+ addressInfo: {}, // 选择的收货地址
|
|
|
+ deliveryType: 1, // 收货方式 1 - 快递配送;2 - 门店自提
|
|
|
+ isPickUp: true, // 门店自提是否开启 TODO puhui999: 默认开启,看看后端有开关的话接入
|
|
|
+ pickUpInfo: {}, // 选择的自提门店信息
|
|
|
+ receiverName: '', // 收件人名称
|
|
|
+ receiverMobile: '', // 收件人手机
|
|
|
+ });
|
|
|
|
|
|
- // 更改收货人地址&计算订单信息
|
|
|
- async function changeConsignee(addressInfo = {}) {
|
|
|
- if (!isEmpty(addressInfo)) {
|
|
|
- state.addressInfo = addressInfo;
|
|
|
- }
|
|
|
+ // ========== 积分 ==========
|
|
|
+ /**
|
|
|
+ * 使用积分抵扣
|
|
|
+ */
|
|
|
+ const changeIntegral = async () => {
|
|
|
+ state.pointStatus = !state.pointStatus;
|
|
|
await getOrderInfo();
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
// 选择优惠券
|
|
|
async function onSelectCoupon(couponId) {
|
|
@@ -205,10 +234,28 @@
|
|
|
|
|
|
// 提交订单
|
|
|
function onConfirm() {
|
|
|
- if (!state.addressInfo.id) {
|
|
|
+ if (addressState.value.deliveryType === 1 && !addressState.value.addressInfo.id) {
|
|
|
sheep.$helper.toast('请选择收货地址');
|
|
|
return;
|
|
|
}
|
|
|
+ if (addressState.value.deliveryType === 2) {
|
|
|
+ if (!addressState.value.pickUpInfo.id) {
|
|
|
+ sheep.$helper.toast('请选择自提门店地址');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (addressState.value.receiverName === '' || addressState.value.receiverMobile === '') {
|
|
|
+ sheep.$helper.toast('请填写联系人或联系人电话');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(addressState.value.receiverName)) {
|
|
|
+ sheep.$helper.toast('请填写您的真实姓名');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(addressState.value.receiverMobile)) {
|
|
|
+ sheep.$helper.toast('请填写正确的手机号');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
submitOrder();
|
|
|
}
|
|
|
|
|
@@ -218,12 +265,15 @@
|
|
|
items: state.orderPayload.items,
|
|
|
couponId: state.orderPayload.couponId,
|
|
|
remark: state.orderPayload.remark,
|
|
|
- addressId: state.addressInfo.id,
|
|
|
- deliveryType: 1, // TODO 芋艿:需要支持【门店自提】
|
|
|
- pointStatus: false, // TODO 芋艿:需要支持【积分选择】
|
|
|
+ deliveryType: addressState.value.deliveryType,
|
|
|
+ addressId: addressState.value.addressInfo.id, // 收件地址编号
|
|
|
+ pickUpStoreId: addressState.value.pickUpInfo.id,//自提门店编号
|
|
|
+ receiverName: addressState.value.receiverName,// 选择门店自提时,该字段为联系人名
|
|
|
+ receiverMobile: addressState.value.receiverMobile,// 选择门店自提时,该字段为联系人手机
|
|
|
+ pointStatus: state.pointStatus,
|
|
|
combinationActivityId: state.orderPayload.combinationActivityId,
|
|
|
combinationHeadId: state.orderPayload.combinationHeadId,
|
|
|
- seckillActivityId: state.orderPayload.seckillActivityId
|
|
|
+ seckillActivityId: state.orderPayload.seckillActivityId,
|
|
|
});
|
|
|
if (code !== 0) {
|
|
|
return;
|
|
@@ -245,12 +295,15 @@
|
|
|
const { data, code } = await OrderApi.settlementOrder({
|
|
|
items: state.orderPayload.items,
|
|
|
couponId: state.orderPayload.couponId,
|
|
|
- addressId: state.addressInfo.id,
|
|
|
- deliveryType: 1, // TODO 芋艿:需要支持【门店自提】
|
|
|
- pointStatus: false, // TODO 芋艿:需要支持【积分选择】
|
|
|
+ deliveryType: addressState.value.deliveryType,
|
|
|
+ addressId: addressState.value.addressInfo.id, // 收件地址编号
|
|
|
+ pickUpStoreId: addressState.value.pickUpInfo.id,//自提门店编号
|
|
|
+ receiverName: addressState.value.receiverName,// 选择门店自提时,该字段为联系人名
|
|
|
+ receiverMobile: addressState.value.receiverMobile,// 选择门店自提时,该字段为联系人手机
|
|
|
+ pointStatus: state.pointStatus,
|
|
|
combinationActivityId: state.orderPayload.combinationActivityId,
|
|
|
combinationHeadId: state.orderPayload.combinationHeadId,
|
|
|
- seckillActivityId: state.orderPayload.seckillActivityId
|
|
|
+ seckillActivityId: state.orderPayload.seckillActivityId,
|
|
|
});
|
|
|
if (code !== 0) {
|
|
|
return;
|
|
@@ -258,7 +311,7 @@
|
|
|
state.orderInfo = data;
|
|
|
// 设置收货地址
|
|
|
if (state.orderInfo.address) {
|
|
|
- state.addressInfo = state.orderInfo.address;
|
|
|
+ addressState.value.addressInfo = state.orderInfo.address;
|
|
|
}
|
|
|
}
|
|
|
|