✨ 下单界面
parent
7a15c9496c
commit
4ddf17e2df
|
@ -1,125 +1,146 @@
|
||||||
<template>
|
<template>
|
||||||
<s-layout title="确认订单">
|
<s-layout title="确认订单">
|
||||||
<!-- v-if="state.orderInfo.need_address === 1" -->
|
<!-- TODO:这个判断先删除 v-if="state.orderInfo.need_address === 1" -->
|
||||||
<!-- 这个判断先删除 -->
|
|
||||||
<view class="bg-white address-box ss-m-b-14 ss-r-b-10" @tap="onSelectAddress">
|
<view class="bg-white address-box ss-m-b-14 ss-r-b-10" @tap="onSelectAddress">
|
||||||
<s-address-item :item="state.addressInfo" :hasBorderBottom="false">
|
<s-address-item :item="state.addressInfo" :hasBorderBottom="false">
|
||||||
<view class="ss-rest-button"><text class="_icon-forward"></text></view>
|
<view class="ss-rest-button">
|
||||||
|
<text class="_icon-forward" />
|
||||||
|
</view>
|
||||||
</s-address-item>
|
</s-address-item>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-card-box ss-m-b-14">
|
|
||||||
<s-goods-item v-for="item in state.orderInfo.goods_list" :key="item.goods_id"
|
|
||||||
:img="item.current_sku_price.image || item.goods.image" :title="item.goods.title"
|
|
||||||
:skuText="item.current_sku_price?.goods_sku_text" :price="item.current_sku_price.price"
|
|
||||||
:num="item.goods_num" marginBottom="10">
|
|
||||||
<template #top>
|
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white">
|
|
||||||
<view class="item-title">配送方式</view>
|
|
||||||
<view class="ss-flex ss-col-center">
|
|
||||||
<text class="item-value">{{ item.dispatch_type_text }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
</s-goods-item>
|
|
||||||
|
|
||||||
|
<!-- 商品信息 -->
|
||||||
|
<view class="order-card-box ss-m-b-14">
|
||||||
|
<s-goods-item
|
||||||
|
v-for="item in state.orderInfo.items"
|
||||||
|
:key="item.skuId"
|
||||||
|
:img="item.picUrl"
|
||||||
|
:title="item.spuName"
|
||||||
|
:skuText="item.properties.map((property) => property.valueName).join(' ')"
|
||||||
|
:price="item.price"
|
||||||
|
:num="item.count"
|
||||||
|
marginBottom="10"
|
||||||
|
/>
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10">
|
<view 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 maxlength="20" placeholder="建议留言前先与商家沟通" v-model="state.orderPayload.remark"
|
<uni-easyinput
|
||||||
:inputBorder="false" :clearable="false"></uni-easyinput>
|
maxlength="20"
|
||||||
|
placeholder="建议留言前先与商家沟通"
|
||||||
|
v-model="state.orderPayload.remark"
|
||||||
|
:inputBorder="false"
|
||||||
|
:clearable="false"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 合计 -->
|
|
||||||
|
<!-- 价格信息 -->
|
||||||
<view class="bg-white total-card-box ss-p-20 ss-m-b-14 ss-r-10">
|
<view class="bg-white total-card-box ss-p-20 ss-m-b-14 ss-r-10">
|
||||||
<view class="total-box-content border-bottom">
|
<view class="total-box-content border-bottom">
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between">
|
<view class="order-item ss-flex ss-col-center ss-row-between">
|
||||||
<view class="item-title">商品金额</view>
|
<view class="item-title">商品金额</view>
|
||||||
<view class="ss-flex ss-col-center">
|
<view class="ss-flex ss-col-center">
|
||||||
<text class="item-value ss-m-r-24">¥{{ state.orderInfo.goods_amount }}</text>
|
<text class="item-value ss-m-r-24">
|
||||||
|
¥{{ fen2yuan(state.orderInfo.price.totalPrice) }}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between"
|
<!-- TODO 芋艿:接入积分 -->
|
||||||
v-if="state.orderPayload.order_type === 'score'">
|
<view
|
||||||
|
class="order-item ss-flex ss-col-center ss-row-between"
|
||||||
|
v-if="state.orderPayload.order_type === 'score'"
|
||||||
|
>
|
||||||
<view class="item-title">扣除积分</view>
|
<view class="item-title">扣除积分</view>
|
||||||
<view class="ss-flex ss-col-center">
|
<view class="ss-flex ss-col-center">
|
||||||
<image :src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="score-img"></image>
|
<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.orderInfo.score_amount }}</text>
|
||||||
</view>
|
</view>
|
||||||
</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">
|
||||||
<view class="item-title">运费</view>
|
<view class="item-title">运费</view>
|
||||||
<view class="ss-flex ss-col-center">
|
<view class="ss-flex ss-col-center">
|
||||||
<text class="item-value ss-m-r-24">+¥{{ state.orderInfo.dispatch_amount }}</text>
|
<text class="item-value ss-m-r-24">
|
||||||
|
+¥{{ fen2yuan(state.orderInfo.price.deliveryPrice) }}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between"
|
<!-- 优惠劵:只有 type = 0 普通订单(非拼团、秒杀、砍价),才可以使用优惠劵 -->
|
||||||
v-if="state.orderPayload.order_type != 'score'">
|
<view
|
||||||
<!-- <view v-if="state.orderInfo.coupon_discount_fee > 0" class="order-item ss-flex ss-col-center ss-row-between"> -->
|
class="order-item ss-flex ss-col-center ss-row-between"
|
||||||
|
v-if="state.orderInfo.type === 0"
|
||||||
|
>
|
||||||
<view class="item-title">优惠券</view>
|
<view class="item-title">优惠券</view>
|
||||||
<view class="ss-flex ss-col-center" @tap="state.showCoupon = true">
|
<view class="ss-flex ss-col-center" @tap="state.showCoupon = true">
|
||||||
<text class="item-value text-red"
|
<text class="item-value text-red" v-if="state.orderPayload.couponId > 0">
|
||||||
v-if="state.orderPayload.coupon_id">-¥{{ state.orderInfo.coupon_discount_fee }}</text>
|
-¥{{ fen2yuan(state.orderInfo.price.couponPrice) }}
|
||||||
<text class="item-value"
|
</text>
|
||||||
:class="state.couponInfo.can_use?.length > 0 ? 'text-red' : 'text-disabled'" v-else>{{
|
<text
|
||||||
state.couponInfo.can_use?.length > 0
|
class="item-value"
|
||||||
? state.couponInfo.can_use?.length + '张可用'
|
:class="state.couponInfo.length > 0 ? 'text-red' : 'text-disabled'"
|
||||||
: '暂无可用优惠券'
|
v-else
|
||||||
}}</text>
|
>
|
||||||
|
{{
|
||||||
<text class="_icon-forward item-icon"></text>
|
state.couponInfo.length > 0 ? state.couponInfo.length + ' 张可用' : '暂无可用优惠券'
|
||||||
|
}}
|
||||||
|
</text>
|
||||||
|
<text class="_icon-forward item-icon" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between"
|
<view
|
||||||
v-if="state.orderInfo.promo_infos?.length">
|
class="order-item ss-flex ss-col-center ss-row-between"
|
||||||
<!-- <view v-if="state.orderInfo.promo_discount_fee > 0" class="order-item ss-flex ss-col-center ss-row-between"> -->
|
v-if="state.orderInfo.price.discountPrice > 0"
|
||||||
|
>
|
||||||
<view class="item-title">活动优惠</view>
|
<view class="item-title">活动优惠</view>
|
||||||
<view class="ss-flex ss-col-center" @tap="state.showDiscount = true">
|
<view class="ss-flex ss-col-center">
|
||||||
<text class="item-value text-red"> -¥{{ state.orderInfo.promo_discount_fee }} </text>
|
<!-- @tap="state.showDiscount = true" TODO 芋艿:后续要把优惠信息打进去 -->
|
||||||
<text class="_icon-forward item-icon"></text>
|
<text class="item-value text-red">
|
||||||
|
-¥{{ fen2yuan(state.orderInfo.price.discountPrice) }}
|
||||||
|
</text>
|
||||||
|
<text class="_icon-forward item-icon" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="total-box-footer ss-font-28 ss-flex ss-row-right ss-col-center ss-m-r-28">
|
<view class="total-box-footer ss-font-28 ss-flex ss-row-right ss-col-center ss-m-r-28">
|
||||||
<view class="total-num ss-m-r-20">共{{ state.totalNumber }}件</view>
|
<view class="total-num ss-m-r-20">
|
||||||
|
共{{ state.orderInfo.items.reduce((acc, item) => acc + item.count, 0) }}件
|
||||||
|
</view>
|
||||||
<view>合计:</view>
|
<view>合计:</view>
|
||||||
<view class="total-num text-red"> ¥{{ state.orderInfo.pay_fee }} </view>
|
<view class="total-num text-red"> ¥{{ fen2yuan(state.orderInfo.price.payPrice) }} </view>
|
||||||
<view class="ss-flex" v-if="state.orderPayload.order_type === 'score'">
|
|
||||||
<view class="total-num ss-font-30 text-red ss-m-l-4"> + </view>
|
|
||||||
<image :src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="score-img"></image>
|
|
||||||
<view class="total-num ss-font-30 text-red">{{ state.orderInfo.score_amount }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<!-- 发票 -->
|
|
||||||
<view class="bg-white ss-p-20 ss-r-20">
|
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between">
|
|
||||||
<view class="item-title">发票申请</view>
|
|
||||||
<view class="ss-flex ss-col-center" @tap="onSelectInvoice">
|
|
||||||
<text class="item-value">{{ state.invoiceInfo.name || '无需开具发票' }}</text>
|
|
||||||
<text class="_icon-forward item-icon"></text>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 选择优惠券弹框 -->
|
<!-- 选择优惠券弹框 -->
|
||||||
<s-coupon-select v-model="state.couponInfo" :show="state.showCoupon" @confirm="onSelectCoupon"
|
<s-coupon-select
|
||||||
@close="state.showCoupon = false" />
|
v-model="state.couponInfo"
|
||||||
<!-- 满额折扣弹框 -->
|
:show="state.showCoupon"
|
||||||
<s-discount-list v-model="state.orderInfo" :show="state.showDiscount" @close="state.showDiscount = false" />
|
@confirm="onSelectCoupon"
|
||||||
|
@close="state.showCoupon = false"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 满额折扣弹框 TODO 芋艿:后续要把优惠信息打进去 -->
|
||||||
|
<s-discount-list
|
||||||
|
v-model="state.orderInfo"
|
||||||
|
:show="state.showDiscount"
|
||||||
|
@close="state.showDiscount = false"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
<su-fixed bottom :opacity="false" bg="bg-white" placeholder :noFixed="false" :index="200">
|
<su-fixed bottom :opacity="false" bg="bg-white" placeholder :noFixed="false" :index="200">
|
||||||
<view class="footer-box border-top ss-flex ss-row-between ss-p-x-20 ss-col-center">
|
<view class="footer-box border-top ss-flex ss-row-between ss-p-x-20 ss-col-center">
|
||||||
<view class="total-box-footer ss-flex ss-col-center">
|
<view class="total-box-footer ss-flex ss-col-center">
|
||||||
<view class="total-num ss-font-30 text-red"> ¥{{ state.orderInfo.pay_fee }} </view>
|
<view class="total-num ss-font-30 text-red">
|
||||||
<view v-if="state.orderPayload.order_type === 'score'" class="ss-flex">
|
¥{{ fen2yuan(state.orderInfo.price.payPrice) }}
|
||||||
<view class="total-num ss-font-30 text-red ss-m-l-4">+</view>
|
|
||||||
<image :src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="score-img"></image>
|
|
||||||
<view class="total-num ss-font-30 text-red">{{ state.orderInfo.score_amount }}</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<button
|
||||||
<button class="ss-reset-button ui-BG-Main-Gradient ss-r-40 submit-btn ui-Shadow-Main" @tap="onConfirm">
|
class="ss-reset-button ui-BG-Main-Gradient ss-r-40 submit-btn ui-Shadow-Main"
|
||||||
{{ exchangeNow ? '立即兑换' : '提交订单' }}
|
@tap="onConfirm"
|
||||||
|
>
|
||||||
|
提交订单
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</su-fixed>
|
</su-fixed>
|
||||||
|
@ -127,36 +148,26 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import { reactive } from 'vue';
|
||||||
reactive,
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
computed
|
|
||||||
} from 'vue';
|
|
||||||
import {
|
|
||||||
onLoad,
|
|
||||||
onPageScroll,
|
|
||||||
onShow
|
|
||||||
} from '@dcloudio/uni-app';
|
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import {
|
import { isEmpty } from 'lodash';
|
||||||
isEmpty
|
import OrderApi from '@/sheep/api/trade/order';
|
||||||
} from 'lodash';
|
import CouponApi from '@/sheep/api/promotion/coupon';
|
||||||
|
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
orderPayload: {},
|
orderPayload: {},
|
||||||
orderInfo: {},
|
orderInfo: {
|
||||||
addressInfo: {},
|
items: [], // 商品项列表
|
||||||
invoiceInfo: {},
|
price: {}, // 价格信息
|
||||||
totalNumber: 0,
|
},
|
||||||
showCoupon: false,
|
addressInfo: {}, // 选择的收货地址
|
||||||
couponInfo: [],
|
showCoupon: false, // 是否展示优惠劵
|
||||||
showDiscount: false,
|
couponInfo: [], // 优惠劵列表
|
||||||
|
showDiscount: false, // 是否展示营销活动
|
||||||
});
|
});
|
||||||
|
|
||||||
// 立即兑换(立即兑换无需跳转收银台)
|
|
||||||
const exchangeNow = computed(
|
|
||||||
() => state.orderPayload.order_type === 'score' && state.orderInfo.pay_fee == 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 选择地址
|
// 选择地址
|
||||||
function onSelectAddress() {
|
function onSelectAddress() {
|
||||||
uni.$once('SELECT_ADDRESS', (e) => {
|
uni.$once('SELECT_ADDRESS', (e) => {
|
||||||
|
@ -167,128 +178,91 @@
|
||||||
|
|
||||||
// 更改收货人地址&计算订单信息
|
// 更改收货人地址&计算订单信息
|
||||||
async function changeConsignee(addressInfo = {}) {
|
async function changeConsignee(addressInfo = {}) {
|
||||||
if (isEmpty(addressInfo)) {
|
|
||||||
const {
|
|
||||||
code,
|
|
||||||
data
|
|
||||||
} = await sheep.$api.user.address.default();
|
|
||||||
console.log(data, '默认收货地址');
|
|
||||||
if (code === 0 && !isEmpty(data)) {
|
|
||||||
console.log('执行赋值')
|
|
||||||
addressInfo = data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isEmpty(addressInfo)) {
|
if (!isEmpty(addressInfo)) {
|
||||||
state.addressInfo = addressInfo;
|
state.addressInfo = addressInfo;
|
||||||
state.orderPayload.address_id = state.addressInfo.id;
|
|
||||||
}
|
}
|
||||||
getOrderInfo();
|
await getOrderInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择优惠券
|
// 选择优惠券
|
||||||
async function onSelectCoupon(e) {
|
async function onSelectCoupon(couponId) {
|
||||||
state.orderPayload.coupon_id = e || 0;
|
state.orderPayload.couponId = couponId || 0;
|
||||||
getOrderInfo();
|
await getOrderInfo();
|
||||||
state.showCoupon = false;
|
state.showCoupon = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择发票信息
|
// 提交订单
|
||||||
function onSelectInvoice() {
|
|
||||||
uni.$once('SELECT_INVOICE', (e) => {
|
|
||||||
state.invoiceInfo = e.invoiceInfo;
|
|
||||||
state.orderPayload.invoice_id = e.invoiceInfo.id || 0;
|
|
||||||
});
|
|
||||||
sheep.$router.go('/pages/user/invoice/list');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 提交订单/立即兑换
|
|
||||||
function onConfirm() {
|
function onConfirm() {
|
||||||
if (!state.orderPayload.address_id && state.orderInfo.need_address === 1) {
|
if (!state.addressInfo.id) {
|
||||||
sheep.$helper.toast('请选择收货地址');
|
sheep.$helper.toast('请选择收货地址');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exchangeNow.value) {
|
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '确定使用积分立即兑换?',
|
|
||||||
cancelText: '再想想',
|
|
||||||
success: async function(res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
submitOrder();
|
submitOrder();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
submitOrder();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建订单&跳转
|
// 创建订单&跳转
|
||||||
async function submitOrder() {
|
async function submitOrder() {
|
||||||
const {
|
const { code, data } = await OrderApi.createOrder({
|
||||||
error,
|
items: state.orderPayload.items,
|
||||||
data
|
couponId: state.orderPayload.couponId,
|
||||||
} = await sheep.$api.order.create(state.orderPayload);
|
addressId: state.addressInfo.id,
|
||||||
if (error === 0) {
|
deliveryType: 1, // TODO 芋艿:需要支持【门店自提】
|
||||||
// 更新购物车列表
|
pointStatus: false, // TODO 芋艿:需要支持【积分选择】
|
||||||
if (state.orderPayload.from === 'cart') {
|
});
|
||||||
|
if (code !== 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 更新购物车列表,如果来自购物车
|
||||||
|
if (state.orderPayload.items[0].cartId > 0) {
|
||||||
sheep.$store('cart').getList();
|
sheep.$store('cart').getList();
|
||||||
}
|
}
|
||||||
if (exchangeNow.value) {
|
// 跳转到支付页面
|
||||||
sheep.$router.redirect('/pages/pay/result', {
|
|
||||||
orderSN: data.order_sn,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
sheep.$router.redirect('/pages/pay/index', {
|
sheep.$router.redirect('/pages/pay/index', {
|
||||||
orderSN: data.order_sn,
|
orderSN: data.payOrderId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查库存 & 计算订单价格
|
// 检查库存 & 计算订单价格
|
||||||
async function getOrderInfo() {
|
async function getOrderInfo() {
|
||||||
console.log(state.orderPayload, '计算价格传参')
|
// 计算价格
|
||||||
// let {code, data} = await sheep.$api.order.calc(state.orderPayload);
|
const { data, code } = await OrderApi.settlementOrder({
|
||||||
// let data = await sheep.$api.order.calc(state.orderPayload);
|
items: state.orderPayload.items,
|
||||||
console.log(state.orderPayload.items)
|
couponId: state.orderPayload.couponId,
|
||||||
let data = await sheep.$api.order.calc({
|
addressId: state.addressInfo.id,
|
||||||
deliveryType: 1,
|
deliveryType: 1, // TODO 芋艿:需要支持【门店自提】
|
||||||
pointStatus: false,
|
pointStatus: false, // TODO 芋艿:需要支持【积分选择】
|
||||||
items: state.orderPayload.items
|
|
||||||
});
|
});
|
||||||
console.log(data, '修改后的获取订单详细数据')
|
if (code !== 0) {
|
||||||
return;
|
return;
|
||||||
if (error === 0) {
|
}
|
||||||
state.totalNumber = 0;
|
|
||||||
state.orderInfo = data;
|
state.orderInfo = data;
|
||||||
state.orderInfo.goods_list.forEach((item) => {
|
// 设置收货地址
|
||||||
state.totalNumber += item.goods_num;
|
if (state.orderInfo.address) {
|
||||||
});
|
state.addressInfo = state.orderInfo.address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取可用优惠券
|
// 获取可用优惠券
|
||||||
async function getCoupons() {
|
async function getCoupons() {
|
||||||
const {
|
const { code, data } = await CouponApi.getMatchCouponList(
|
||||||
error,
|
state.orderInfo.price.payPrice,
|
||||||
data
|
state.orderInfo.items.map((item) => item.spuId),
|
||||||
} = await sheep.$api.order.coupons(state.orderPayload);
|
state.orderPayload.items.map((item) => item.skuId),
|
||||||
if (error === 0) {
|
state.orderPayload.items.map((item) => item.categoryId),
|
||||||
|
);
|
||||||
|
if (code === 0) {
|
||||||
state.couponInfo = data;
|
state.couponInfo = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
console.log(options)
|
if (!options.data) {
|
||||||
if (options.data) {
|
sheep.$helper.toast('参数不正确,请检查!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
state.orderPayload = JSON.parse(options.data);
|
state.orderPayload = JSON.parse(options.data);
|
||||||
changeConsignee();
|
await getOrderInfo();
|
||||||
if (state.orderPayload.order_type !== 'score') {
|
await getCoupons();
|
||||||
getCoupons();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -115,11 +115,13 @@ export default {
|
||||||
formData: {
|
formData: {
|
||||||
group,
|
group,
|
||||||
},
|
},
|
||||||
|
// TODO 芋艿:临时写死
|
||||||
header: {
|
header: {
|
||||||
// Accept: 'text/json',
|
// Accept: 'text/json',
|
||||||
// Authorization: token,
|
// Authorization: token,
|
||||||
Accept : '*/*',
|
Accept : '*/*',
|
||||||
'tenant-id' :'1',
|
'tenant-id' :'1',
|
||||||
|
'terminal': 20,
|
||||||
Authorization: 'Bearer test247',
|
Authorization: 'Bearer test247',
|
||||||
},
|
},
|
||||||
success: (uploadFileRes) => {
|
success: (uploadFileRes) => {
|
||||||
|
|
|
@ -65,27 +65,18 @@ export default {
|
||||||
// 解决 SpringMVC 接受 List<Item> 参数的问题
|
// 解决 SpringMVC 接受 List<Item> 参数的问题
|
||||||
delete data2.items
|
delete data2.items
|
||||||
for (let i = 0; i < data.items.length; i++) {
|
for (let i = 0; i < data.items.length; i++) {
|
||||||
// data2['items[' + i + '' + '].skuId'] = data.items[i].skuId + '';
|
data2[encodeURIComponent('items[' + i + '' + '].skuId')] = data.items[i].skuId + '';
|
||||||
// data2['items[' + i + '' + '].count'] = data.items[i].count + '';
|
data2[encodeURIComponent('items[' + i + '' + '].count')] = data.items[i].count + '';
|
||||||
// data2['items[' + i + '' + '].cartId'] = data.items[i].cartId + '';
|
if (data.items[i].cartId) {
|
||||||
data2['items' + `%5B${i}%5D` + '.skuId'] = data.items[i].skuId + '';
|
data2[encodeURIComponent('items[' + i + '' + '].cartId')] = data.items[i].cartId + '';
|
||||||
data2['items' + `%5B${i}%5D` + '.count'] = data.items[i].count + '';
|
|
||||||
data2['items' + `%5B${i}%5D` + '.cartId'] = data.items[i].cartId + '';
|
|
||||||
}
|
}
|
||||||
console.log(data2, '对比数据')
|
}
|
||||||
|
const queryString= Object.keys(data2).map(key => key + '=' + data2[key]).join('&')
|
||||||
return request2({
|
return request2({
|
||||||
url: 'trade/order/settlement',
|
url: `trade/order/settlement?${queryString}`,
|
||||||
method: 'GET',
|
method: 'GET'
|
||||||
// data,
|
|
||||||
params: data2
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// calc: (data) =>
|
|
||||||
// request({
|
|
||||||
// url: 'order/order/calc',
|
|
||||||
// method: 'POST',
|
|
||||||
// data,
|
|
||||||
// }),
|
|
||||||
// 创建订单
|
// 创建订单
|
||||||
create: (data) =>
|
create: (data) =>
|
||||||
request({
|
request({
|
||||||
|
|
|
@ -17,4 +17,17 @@ export default {
|
||||||
params: { spuId, productScope, count },
|
params: { spuId, productScope, count },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 获得匹配指定商品的优惠劵列表
|
||||||
|
getMatchCouponList: (price, spuIds, skuIds, categoryIds) => {
|
||||||
|
return request({
|
||||||
|
url: '/app-api/promotion/coupon/match-list',
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
price,
|
||||||
|
spuIds: spuIds.join(','),
|
||||||
|
skuIds: skuIds.join(','),
|
||||||
|
categoryIds: categoryIds.join(','),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
import request2 from '@/sheep/request2';
|
||||||
|
|
||||||
|
const OrderApi = {
|
||||||
|
// 计算订单信息
|
||||||
|
settlementOrder: (data) => {
|
||||||
|
const data2 = {
|
||||||
|
...data,
|
||||||
|
}
|
||||||
|
// 移除多余字段
|
||||||
|
if (!(data.couponId > 0)) {
|
||||||
|
delete data2.couponId
|
||||||
|
}
|
||||||
|
if (!(data.addressId > 0)) {
|
||||||
|
delete data2.addressId
|
||||||
|
}
|
||||||
|
// 解决 SpringMVC 接受 List<Item> 参数的问题
|
||||||
|
delete data2.items
|
||||||
|
for (let i = 0; i < data.items.length; i++) {
|
||||||
|
data2[encodeURIComponent('items[' + i + '' + '].skuId')] = data.items[i].skuId + '';
|
||||||
|
data2[encodeURIComponent('items[' + i + '' + '].count')] = data.items[i].count + '';
|
||||||
|
if (data.items[i].cartId) {
|
||||||
|
data2[encodeURIComponent('items[' + i + '' + '].cartId')] = data.items[i].cartId + '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const queryString= Object.keys(data2).map(key => key + '=' + data2[key]).join('&')
|
||||||
|
return request2({
|
||||||
|
url: `trade/order/settlement?${queryString}`,
|
||||||
|
method: 'GET'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 创建订单
|
||||||
|
createOrder: (data) => {
|
||||||
|
return request2({
|
||||||
|
url: `trade/order/create`,
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OrderApi;
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- 订单确认的优惠劵选择弹窗 -->
|
||||||
<template>
|
<template>
|
||||||
<su-popup
|
<su-popup
|
||||||
:show="show"
|
:show="show"
|
||||||
|
@ -16,20 +17,21 @@
|
||||||
:enable-back-to-top="true"
|
:enable-back-to-top="true"
|
||||||
>
|
>
|
||||||
<view class="subtitle ss-m-l-20">可使用优惠券</view>
|
<view class="subtitle ss-m-l-20">可使用优惠券</view>
|
||||||
<view v-for="(item, index) in state.couponInfo.can_use" :key="index">
|
<view v-for="(item, index) in state.couponInfo" :key="index">
|
||||||
<s-coupon-list :data="item" type="user" :disabled="false">
|
<s-coupon-list :data="item" type="user" :disabled="false">
|
||||||
<template #default>
|
<template #default>
|
||||||
<label class="ss-flex ss-col-center" @tap="radioChange(item.id)">
|
<label class="ss-flex ss-col-center" @tap="radioChange(item.id)">
|
||||||
<radio
|
<radio
|
||||||
color="var(--ui-BG-Main)"
|
color="var(--ui-BG-Main)"
|
||||||
style="transform: scale(0.8)"
|
style="transform: scale(0.8)"
|
||||||
:checked="state.couponId == item.id"
|
:checked="state.couponId === item.id"
|
||||||
@tap.stop="radioChange(item.id)"
|
@tap.stop="radioChange(item.id)"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</template>
|
</template>
|
||||||
</s-coupon-list>
|
</s-coupon-list>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- TODO 芋艿:未来接口需要支持下
|
||||||
<view class="subtitle ss-m-t-40 ss-m-l-20">不可使用优惠券</view>
|
<view class="subtitle ss-m-t-40 ss-m-l-20">不可使用优惠券</view>
|
||||||
<view v-for="item in state.couponInfo.cannot_use" :key="item.id">
|
<view v-for="item in state.couponInfo.cannot_use" :key="item.id">
|
||||||
<s-coupon-list :data="item" type="user" :disabled="true">
|
<s-coupon-list :data="item" type="user" :disabled="true">
|
||||||
|
@ -41,6 +43,7 @@
|
||||||
</template>
|
</template>
|
||||||
</s-coupon-list>
|
</s-coupon-list>
|
||||||
</view>
|
</view>
|
||||||
|
-->
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
<view class="modal-footer ss-flex">
|
<view class="modal-footer ss-flex">
|
||||||
|
@ -50,8 +53,9 @@
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive } from 'vue';
|
import { computed, reactive } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: { // 优惠劵列表
|
||||||
type: Object,
|
type: Object,
|
||||||
default() {},
|
default() {},
|
||||||
},
|
},
|
||||||
|
@ -60,21 +64,27 @@
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emits = defineEmits(['confirm', 'close']);
|
const emits = defineEmits(['confirm', 'close']);
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
couponInfo: computed(() => props.modelValue),
|
couponInfo: computed(() => props.modelValue), // 优惠劵列表
|
||||||
couponId: 0,
|
couponId: 0, // 选中的优惠劵编号
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 选中优惠劵
|
||||||
function radioChange(couponId) {
|
function radioChange(couponId) {
|
||||||
if (state.couponId == couponId) {
|
if (state.couponId === couponId) {
|
||||||
state.couponId = 0;
|
state.couponId = 0;
|
||||||
} else {
|
} else {
|
||||||
state.couponId = couponId;
|
state.couponId = couponId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 确认优惠劵
|
||||||
const onConfirm = () => {
|
const onConfirm = () => {
|
||||||
emits('confirm', state.couponId);
|
emits('confirm', state.couponId);
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
:deep() {
|
:deep() {
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
:style="[{ color: priceColor }]"
|
:style="[{ color: priceColor }]"
|
||||||
v-if="price && Number(price) > 0"
|
v-if="price && Number(price) > 0"
|
||||||
>
|
>
|
||||||
¥{{ price }}
|
¥{{ fen2yuan(price) }}
|
||||||
</view>
|
</view>
|
||||||
<view v-if="score && Number(price) > 0">+</view>
|
<view v-if="score && Number(price) > 0">+</view>
|
||||||
<view class="price-text ss-flex ss-col-center" v-if="score">
|
<view class="price-text ss-flex ss-col-center" v-if="score">
|
||||||
|
@ -54,6 +54,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
import { fen2yuan } from '../../hooks/useGoods';
|
||||||
/**
|
/**
|
||||||
* 订单卡片
|
* 订单卡片
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue