|
@@ -41,36 +41,64 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view
|
|
|
+ v-if="state.orderPayload.pointActivityId"
|
|
|
class="order-item ss-flex ss-col-center ss-row-between"
|
|
|
- v-if="state.orderInfo.type === 0"
|
|
|
+ >
|
|
|
+ <view class="item-title">兑换积分</view>
|
|
|
+ <view class="ss-flex ss-col-center">
|
|
|
+ <image
|
|
|
+ :src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
|
|
|
+ class="score-img"
|
|
|
+ />
|
|
|
+ <text class="item-value ss-m-r-24">
|
|
|
+ {{ state.orderInfo.usePoint }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ class="order-item ss-flex ss-col-center ss-row-between"
|
|
|
+ v-if="state.orderInfo.type === 0 || state.orderPayload.pointActivityId"
|
|
|
>
|
|
|
<view class="item-title">积分抵扣</view>
|
|
|
<view class="ss-flex ss-col-center">
|
|
|
- {{ state.pointStatus ? '剩余积分' : '当前积分' }}
|
|
|
+ {{ state.pointStatus || state.orderPayload.pointActivityId ? '剩余积分' : '当前积分' }}
|
|
|
<image
|
|
|
:src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
|
|
|
class="score-img"
|
|
|
/>
|
|
|
<text class="item-value ss-m-r-24">
|
|
|
- {{ state.pointStatus ? state.orderInfo.totalPoint - state.orderInfo.usePoint : (state.orderInfo.totalPoint || 0) }}
|
|
|
+ {{
|
|
|
+ state.pointStatus || state.orderPayload.pointActivityId
|
|
|
+ ? 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 @change="changeIntegral" v-if="!state.orderPayload.pointActivityId">
|
|
|
+ <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" v-if='addressState.deliveryType === 1'>
|
|
|
+ <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" 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 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="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
|
|
@@ -82,7 +110,10 @@
|
|
|
/>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="order-item ss-flex ss-col-center ss-row-between" v-if='addressState.deliveryType === 2'>
|
|
|
+ <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
|
|
@@ -106,11 +137,17 @@
|
|
|
</text>
|
|
|
<text
|
|
|
class="item-value"
|
|
|
- :class="state.couponInfo.length > 0 ? 'text-red' : 'text-disabled'"
|
|
|
+ :class="
|
|
|
+ state.couponInfo.filter((coupon) => coupon.match).length > 0
|
|
|
+ ? 'text-red'
|
|
|
+ : 'text-disabled'
|
|
|
+ "
|
|
|
v-else
|
|
|
>
|
|
|
{{
|
|
|
- state.couponInfo.length > 0 ? state.couponInfo.length + ' 张可用' : '暂无可用优惠券'
|
|
|
+ state.couponInfo.filter((coupon) => coupon.match).length > 0
|
|
|
+ ? state.couponInfo.filter((coupon) => coupon.match).length + ' 张可用'
|
|
|
+ : '暂无可用优惠券'
|
|
|
}}
|
|
|
</text>
|
|
|
<text class="_icon-forward item-icon" />
|
|
@@ -121,8 +158,7 @@
|
|
|
v-if="state.orderInfo.price.discountPrice > 0"
|
|
|
>
|
|
|
<view class="item-title">活动优惠</view>
|
|
|
- <view class="ss-flex ss-col-center">
|
|
|
- <!-- @tap="state.showDiscount = true" TODO 芋艿:后续要把优惠信息打进去 -->
|
|
|
+ <view class="ss-flex ss-col-center" @tap="state.showDiscount = true">
|
|
|
<text class="item-value text-red">
|
|
|
-¥{{ fen2yuan(state.orderInfo.price.discountPrice) }}
|
|
|
</text>
|
|
@@ -158,7 +194,7 @@
|
|
|
@close="state.showCoupon = false"
|
|
|
/>
|
|
|
|
|
|
- <!-- 满额折扣弹框 TODO 芋艿:后续要把优惠信息打进去 -->
|
|
|
+ <!-- 满额折扣弹框 TODO @puhui999:【折扣】后续要把优惠信息打进去 -->
|
|
|
<s-discount-list
|
|
|
v-model="state.orderInfo"
|
|
|
:show="state.showDiscount"
|
|
@@ -190,7 +226,7 @@
|
|
|
import AddressSelection from '@/pages/order/addressSelection.vue';
|
|
|
import sheep from '@/sheep';
|
|
|
import OrderApi from '@/sheep/api/trade/order';
|
|
|
- import CouponApi from '@/sheep/api/promotion/coupon';
|
|
|
+ import TradeConfigApi from '@/sheep/api/trade/config';
|
|
|
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
|
|
|
|
|
const state = reactive({
|
|
@@ -208,8 +244,8 @@
|
|
|
|
|
|
const addressState = ref({
|
|
|
addressInfo: {}, // 选择的收货地址
|
|
|
- deliveryType: 1, // 收货方式:1-快递配送,2-门店自提
|
|
|
- isPickUp: true, // 门店自提是否开启 TODO puhui999: 默认开启,看看后端有开关的话接入
|
|
|
+ deliveryType: undefined, // 收货方式:1-快递配送,2-门店自提
|
|
|
+ isPickUp: true, // 门店自提是否开启
|
|
|
pickUpInfo: {}, // 选择的自提门店信息
|
|
|
receiverName: '', // 收件人名称
|
|
|
receiverMobile: '', // 收件人手机
|
|
@@ -226,19 +262,11 @@
|
|
|
|
|
|
// 选择优惠券
|
|
|
async function onSelectCoupon(couponId) {
|
|
|
- state.orderPayload.couponId = couponId
|
|
|
+ state.orderPayload.couponId = couponId;
|
|
|
await getOrderInfo();
|
|
|
state.showCoupon = false;
|
|
|
}
|
|
|
|
|
|
- // 使用 watch 监听地址和配送方式的变化
|
|
|
- watch(addressState, async (newAddress, oldAddress) => {
|
|
|
- // 如果收货地址或配送方式有变化,则重新计算价格
|
|
|
- if (newAddress.addressInfo.id !== oldAddress.addressInfo.id || newAddress.deliveryType !== oldAddress.deliveryType) {
|
|
|
- await getOrderInfo();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
// 提交订单
|
|
|
function onConfirm() {
|
|
|
if (addressState.value.deliveryType === 1 && !addressState.value.addressInfo.id) {
|
|
@@ -274,13 +302,14 @@
|
|
|
remark: state.orderPayload.remark,
|
|
|
deliveryType: addressState.value.deliveryType,
|
|
|
addressId: addressState.value.addressInfo.id, // 收件地址编号
|
|
|
- pickUpStoreId: addressState.value.pickUpInfo.id,//自提门店编号
|
|
|
- receiverName: addressState.value.receiverName,// 选择门店自提时,该字段为联系人名
|
|
|
- receiverMobile: addressState.value.receiverMobile,// 选择门店自提时,该字段为联系人手机
|
|
|
+ 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,
|
|
|
+ pointActivityId: state.orderPayload.pointActivityId,
|
|
|
});
|
|
|
if (code !== 0) {
|
|
|
return;
|
|
@@ -291,9 +320,15 @@
|
|
|
}
|
|
|
|
|
|
// 跳转到支付页面
|
|
|
- sheep.$router.redirect('/pages/pay/index', {
|
|
|
- id: data.payOrderId,
|
|
|
- });
|
|
|
+ if (data.payOrderId && data.payOrderId > 0) {
|
|
|
+ sheep.$router.redirect('/pages/pay/index', {
|
|
|
+ id: data.payOrderId,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ sheep.$router.redirect('/pages/order/detail', {
|
|
|
+ id: data.id,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 检查库存 & 计算订单价格
|
|
@@ -304,45 +339,70 @@
|
|
|
couponId: state.orderPayload.couponId,
|
|
|
deliveryType: addressState.value.deliveryType,
|
|
|
addressId: addressState.value.addressInfo.id, // 收件地址编号
|
|
|
- pickUpStoreId: addressState.value.pickUpInfo.id,//自提门店编号
|
|
|
- receiverName: addressState.value.receiverName,// 选择门店自提时,该字段为联系人名
|
|
|
- receiverMobile: addressState.value.receiverMobile,// 选择门店自提时,该字段为联系人手机
|
|
|
+ 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,
|
|
|
+ pointActivityId: state.orderPayload.pointActivityId,
|
|
|
});
|
|
|
if (code !== 0) {
|
|
|
- return;
|
|
|
+ return code;
|
|
|
}
|
|
|
state.orderInfo = data;
|
|
|
+ state.couponInfo = data.coupons || [];
|
|
|
// 设置收货地址
|
|
|
if (state.orderInfo.address) {
|
|
|
addressState.value.addressInfo = state.orderInfo.address;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // 获取可用优惠券
|
|
|
- async function getCoupons() {
|
|
|
- const { code, data } = await CouponApi.getMatchCouponList(
|
|
|
- state.orderInfo.price.payPrice,
|
|
|
- state.orderInfo.items.map((item) => item.spuId),
|
|
|
- state.orderPayload.items.map((item) => item.skuId),
|
|
|
- state.orderPayload.items.map((item) => item.categoryId),
|
|
|
- );
|
|
|
- if (code === 0) {
|
|
|
- state.couponInfo = data;
|
|
|
- }
|
|
|
+ return code;
|
|
|
}
|
|
|
|
|
|
onLoad(async (options) => {
|
|
|
+ // 解析参数
|
|
|
if (!options.data) {
|
|
|
sheep.$helper.toast('参数不正确,请检查!');
|
|
|
return;
|
|
|
}
|
|
|
state.orderPayload = JSON.parse(options.data);
|
|
|
+
|
|
|
+ // 获取交易配置
|
|
|
+ const { data, code } = await TradeConfigApi.getTradeConfig();
|
|
|
+ if (code === 0) {
|
|
|
+ addressState.value.isPickUp = data.deliveryPickUpEnabled;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 价格计算
|
|
|
+ // 情况一:先自动选择“快递物流”
|
|
|
+ addressState.value.deliveryType = 1;
|
|
|
+ let orderCode = await getOrderInfo();
|
|
|
+ if (orderCode === 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 情况二:失败,再自动选择“门店自提”
|
|
|
+ if (addressState.value.isPickUp) {
|
|
|
+ addressState.value.deliveryType = 2;
|
|
|
+ let orderCode = await getOrderInfo();
|
|
|
+ if (orderCode === 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 情况三:都失败,则不选择
|
|
|
+ addressState.value.deliveryType = undefined;
|
|
|
await getOrderInfo();
|
|
|
- await getCoupons();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 使用 watch 监听地址和配送方式的变化
|
|
|
+ watch(addressState, async (newAddress, oldAddress) => {
|
|
|
+ // 如果收货地址或配送方式有变化,则重新计算价格
|
|
|
+ if (
|
|
|
+ newAddress.addressInfo.id !== oldAddress.addressInfo.id ||
|
|
|
+ newAddress.deliveryType !== oldAddress.deliveryType
|
|
|
+ ) {
|
|
|
+ await getOrderInfo();
|
|
|
+ }
|
|
|
});
|
|
|
</script>
|
|
|
|