积分兑换详情页替换与接口对接
This commit is contained in:
parent
deee0ca751
commit
54f8adf15e
@ -2,13 +2,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<s-layout title="兑换详情" navbar="normal" :leftWidth="0" :rightWidth="0">
|
<s-layout title="兑换详情" navbar="normal" :leftWidth="0" :rightWidth="0">
|
||||||
<view class="main">
|
<view class="main">
|
||||||
|
<!-- 收货地址 -->
|
||||||
<view class="t-address">
|
<view class="t-address">
|
||||||
<view class="t">
|
<view class="t">
|
||||||
<text class="l">TEST TQQQ</text>
|
<text class="l">{{ state.orderInfo.receiverName }}</text>
|
||||||
<text class="r">13615935246</text>
|
<text class="r">{{ state.orderInfo.receiverMobile }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="b">
|
<view class="b">
|
||||||
北京市 北京市 北京市 北京市
|
{{ state.orderInfo.receiverAreaName }} {{ state.orderInfo.receiverDetailAddress }}
|
||||||
</view>
|
</view>
|
||||||
<image
|
<image
|
||||||
src="https://zysc.fjptzykj.com:3000/shangcheng/0f01dda22fb349c40c4659d73cb346a1423fee44c9d53eb07bdae1a1e11b5299.png"
|
src="https://zysc.fjptzykj.com:3000/shangcheng/0f01dda22fb349c40c4659d73cb346a1423fee44c9d53eb07bdae1a1e11b5299.png"
|
||||||
@ -17,22 +18,23 @@
|
|||||||
|
|
||||||
<view class="c-goods">
|
<view class="c-goods">
|
||||||
<view class="t">
|
<view class="t">
|
||||||
共1件商品
|
共{{item.count}}件商品
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="b-detail">
|
<view class="b-detail" v-for="(item,index) in state.orderInfo.items" :key="item.goods_id">
|
||||||
<image
|
<image :src="item.picUrl" class="img" mode=""></image>
|
||||||
src="https://zysc.fjptzykj.com:3000/shangcheng/21cf998c40ecd9d506f884bbd7540afc2e7928ab0e4ab54afede1fcc48a10972.png"
|
|
||||||
class="img" mode=""></image>
|
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<view class="t">
|
<view class="t">
|
||||||
Xiaomi Citi 2 冰冰蓝 8GB + 128GB <text class="r">x1</text>
|
<view class="ss-line-2" style=" width: 88%;">
|
||||||
|
{{item.spuName}}
|
||||||
|
</view>
|
||||||
|
<text class="r">x{{item.count}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="c">
|
<view class="c">
|
||||||
冰冰蓝,8+128
|
{{item.properties.map((property) => property.valueName).join(' ')}}
|
||||||
</view>
|
</view>
|
||||||
<view class="b">
|
<view class="b">
|
||||||
10积分
|
10积分(待对接接口)
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -44,8 +46,8 @@
|
|||||||
订单编号:
|
订单编号:
|
||||||
</view>
|
</view>
|
||||||
<view class="r">
|
<view class="r">
|
||||||
wx23556151561321321351213
|
{{ state.orderInfo.no }}
|
||||||
<view class="copy-btn">
|
<view class="copy-btn" @click="onCopy">
|
||||||
复制
|
复制
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -56,7 +58,7 @@
|
|||||||
订单状态:
|
订单状态:
|
||||||
</view>
|
</view>
|
||||||
<view class="r">
|
<view class="r">
|
||||||
未发货
|
{{ formatOrderStatus(state.orderInfo) }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="ddxx">
|
<view class="ddxx">
|
||||||
@ -64,7 +66,7 @@
|
|||||||
下单时间:
|
下单时间:
|
||||||
</view>
|
</view>
|
||||||
<view class="r">
|
<view class="r">
|
||||||
2024-10-18 15:46:03
|
{{ sheep.$helper.timeFormat(state.orderInfo.createTime, 'yyyy-mm-dd hh:MM:ss') }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="ddxx">
|
<view class="ddxx">
|
||||||
@ -72,7 +74,7 @@
|
|||||||
支付积分
|
支付积分
|
||||||
</view>
|
</view>
|
||||||
<view class="r">
|
<view class="r">
|
||||||
10
|
10(待接口对接)
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -82,61 +84,189 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import {
|
import {
|
||||||
onLoad,
|
onLoad
|
||||||
onReachBottom
|
|
||||||
} from '@dcloudio/uni-app';
|
} from '@dcloudio/uni-app';
|
||||||
import {
|
import {
|
||||||
reactive,
|
reactive,
|
||||||
ref
|
ref
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import PointApi from '@/sheep/api/promotion/point';
|
import {
|
||||||
import SLayout from '@/sheep/components/s-layout/s-layout.vue';
|
isEmpty
|
||||||
|
} from 'lodash-es';
|
||||||
|
import {
|
||||||
|
fen2yuan,
|
||||||
|
formatOrderStatus,
|
||||||
|
formatOrderStatusDescription,
|
||||||
|
handleOrderButtons,
|
||||||
|
} from '@/sheep/hooks/useGoods';
|
||||||
|
import OrderApi from '@/sheep/api/trade/order';
|
||||||
|
import DeliveryApi from '@/sheep/api/trade/delivery';
|
||||||
|
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
|
||||||
|
|
||||||
// 计算页面高度
|
|
||||||
const {
|
|
||||||
safeAreaInsets,
|
|
||||||
safeArea
|
|
||||||
} = sheep.$platform.device;
|
|
||||||
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
|
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
|
||||||
const pageHeight =
|
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
|
||||||
(safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sheep.$platform.navbar - 350;
|
|
||||||
|
|
||||||
const sPointCardRef = ref();
|
const state = reactive({
|
||||||
// 查询活动列表
|
orderInfo: {},
|
||||||
const activityPageParams = reactive({
|
merchantTradeNo: '', // 商户订单号
|
||||||
pageNo: 1, // 页码
|
comeinType: '', // 进入订单详情的来源类型
|
||||||
pageSize: 5, // 每页数量
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const activityTotal = ref(0); // 活动总数
|
// ========== 门店自提(核销) ==========
|
||||||
const activityCount = ref(0); // 已加载活动数量
|
const systemStore = ref({}); // 门店信息
|
||||||
const loadStatus = ref(''); // 页面加载状态
|
|
||||||
async function getActivityList() {
|
|
||||||
loadStatus.value = 'loading';
|
|
||||||
const {
|
|
||||||
data
|
|
||||||
} = await PointApi.getPointActivityPage(activityPageParams);
|
|
||||||
await sPointCardRef.value.concatActivity(data.list);
|
|
||||||
activityCount.value = sPointCardRef.value.getActivityCount();
|
|
||||||
activityTotal.value = data.total;
|
|
||||||
|
|
||||||
loadStatus.value = activityCount.value < activityTotal.value ? 'more' : 'noMore';
|
// 复制
|
||||||
|
const onCopy = () => {
|
||||||
|
sheep.$helper.copyText(state.orderInfo.no);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 去支付
|
||||||
|
function onPay(payOrderId) {
|
||||||
|
sheep.$router.go('/pages/pay/index', {
|
||||||
|
id: payOrderId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载更多
|
// 查看商品
|
||||||
function loadMore() {
|
function onGoodsDetail(id) {
|
||||||
if (state.loadStatus !== 'noMore') {
|
sheep.$router.go('/pages/goods/index', {
|
||||||
activityPageParams.pageNo += 1;
|
id,
|
||||||
getActivityList();
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消订单
|
||||||
|
async function onCancel(orderId) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要取消订单吗?',
|
||||||
|
success: async function(res) {
|
||||||
|
if (!res.confirm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const {
|
||||||
|
code
|
||||||
|
} = await OrderApi.cancelOrder(orderId);
|
||||||
|
if (code === 0) {
|
||||||
|
await getOrderDetail(orderId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查看物流
|
||||||
|
async function onExpress(id) {
|
||||||
|
sheep.$router.go('/pages/order/express/log', {
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认收货 TODO 芋艿:待测试
|
||||||
|
async function onConfirm(orderId, ignore = false) {
|
||||||
|
// 需开启确认收货组件
|
||||||
|
// todo: 芋艿:待接入微信
|
||||||
|
// 1.怎么检测是否开启了发货组件功能?如果没有开启的话就不能在这里return出去
|
||||||
|
// 2.如果开启了走mpConfirm方法,需要在App.vue的show方法中拿到确认收货结果
|
||||||
|
let isOpenBusinessView = true;
|
||||||
|
if (
|
||||||
|
sheep.$platform.name === 'WechatMiniProgram' &&
|
||||||
|
!isEmpty(state.orderInfo.wechat_extra_data) &&
|
||||||
|
isOpenBusinessView &&
|
||||||
|
!ignore
|
||||||
|
) {
|
||||||
|
mpConfirm(orderId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 正常的确认收货流程
|
||||||
|
const {
|
||||||
|
code
|
||||||
|
} = await OrderApi.receiveOrder(orderId);
|
||||||
|
if (code === 0) {
|
||||||
|
await getOrderDetail(orderId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上拉加载更多
|
// #ifdef MP-WEIXIN
|
||||||
onReachBottom(() => {
|
// 小程序确认收货组件
|
||||||
loadMore();
|
function mpConfirm(orderId) {
|
||||||
});
|
if (!wx.openBusinessView) {
|
||||||
onLoad(() => {
|
sheep.$helper.toast(`请升级微信版本`);
|
||||||
getActivityList();
|
return;
|
||||||
|
}
|
||||||
|
wx.openBusinessView({
|
||||||
|
businessType: 'weappOrderConfirm',
|
||||||
|
extraData: {
|
||||||
|
merchant_trade_no: state.orderInfo.wechat_extra_data.merchant_trade_no,
|
||||||
|
transaction_id: state.orderInfo.wechat_extra_data.transaction_id,
|
||||||
|
},
|
||||||
|
success(response) {
|
||||||
|
console.log('success:', response);
|
||||||
|
if (response.errMsg === 'openBusinessView:ok') {
|
||||||
|
if (response.extraData.status === 'success') {
|
||||||
|
onConfirm(orderId, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail(error) {
|
||||||
|
console.log('error:', error);
|
||||||
|
},
|
||||||
|
complete(result) {
|
||||||
|
console.log('result:', result);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// 评价
|
||||||
|
function onComment(id) {
|
||||||
|
sheep.$router.go('/pages/goods/comment/add', {
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const pickUpVerifyRef = ref();
|
||||||
|
|
||||||
|
async function getOrderDetail(id) {
|
||||||
|
// 对详情数据进行适配
|
||||||
|
let res;
|
||||||
|
if (state.comeinType === 'wechat') {
|
||||||
|
// TODO 芋艿:微信场景下
|
||||||
|
res = await OrderApi.getOrder(id, {
|
||||||
|
merchant_trade_no: state.merchantTradeNo,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res = await OrderApi.getOrder(id);
|
||||||
|
}
|
||||||
|
if (res.code === 0) {
|
||||||
|
state.orderInfo = res.data;
|
||||||
|
handleOrderButtons(state.orderInfo);
|
||||||
|
// 配送方式:门店自提
|
||||||
|
if (res.data.pickUpStoreId) {
|
||||||
|
const {
|
||||||
|
data
|
||||||
|
} = await DeliveryApi.getDeliveryPickUpStore(res.data.pickUpStoreId);
|
||||||
|
systemStore.value = data || {};
|
||||||
|
}
|
||||||
|
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
|
||||||
|
pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sheep.$router.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad(async (options) => {
|
||||||
|
let id = 0;
|
||||||
|
if (options.id) {
|
||||||
|
id = options.id;
|
||||||
|
}
|
||||||
|
// TODO 芋艿:下面两个变量,后续接入
|
||||||
|
state.comeinType = options.comein_type;
|
||||||
|
if (state.comeinType === 'wechat') {
|
||||||
|
state.merchantTradeNo = options.merchant_trade_no;
|
||||||
|
}
|
||||||
|
await getOrderDetail(id);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -149,7 +279,7 @@
|
|||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
|
|
||||||
.t {
|
.t {
|
||||||
font-size: 19px;
|
font-size: 30rpx;
|
||||||
color: black;
|
color: black;
|
||||||
display: flex;
|
display: flex;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@ -161,7 +291,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.b {
|
.b {
|
||||||
font-size: 17px;
|
font-size: 26rpx;
|
||||||
color: rgba(156, 143, 114);
|
color: rgba(156, 143, 114);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +307,7 @@
|
|||||||
background: white;
|
background: white;
|
||||||
|
|
||||||
&>.t {
|
&>.t {
|
||||||
font-size: 19px;
|
font-size: 30rpx;
|
||||||
border-bottom: 1px solid rgba(240, 240, 240);
|
border-bottom: 1px solid rgba(240, 240, 240);
|
||||||
padding-bottom: 15px;
|
padding-bottom: 15px;
|
||||||
}
|
}
|
||||||
@ -194,57 +324,81 @@
|
|||||||
|
|
||||||
.right {
|
.right {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
||||||
.t {
|
.t {
|
||||||
font-size: 14px;
|
font-size: 26rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
.r{
|
|
||||||
color:rgba(134,139,151);
|
.r {
|
||||||
|
color: rgba(134, 139, 151);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.c {
|
.c {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
color:rgba(134,139,151);
|
color: rgba(134, 139, 151);
|
||||||
}
|
}
|
||||||
|
|
||||||
.b {
|
.b {
|
||||||
color:rgba(254,94,51);
|
color: rgba(254, 94, 51);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.b-goodsDetail {
|
.b-goodsDetail {
|
||||||
margin: 9px 0;
|
margin: 9px 0;
|
||||||
padding: 15px 10px;
|
padding: 7px 10px;
|
||||||
background: white;
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ddxx {
|
.ddxx {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: 10px 0;
|
margin: 8px 0;
|
||||||
|
|
||||||
.l {
|
.l {
|
||||||
font-size: 17px;
|
font-size: 15px;
|
||||||
.r{
|
|
||||||
}
|
.r {}
|
||||||
}
|
}
|
||||||
|
|
||||||
.r {
|
.r {
|
||||||
font-size: 16px;
|
font-size: 14px;
|
||||||
color: rgba(102, 102, 102);
|
color: rgba(102, 102, 102);
|
||||||
display:flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
.copy-btn{
|
|
||||||
margin-left:10px;
|
.copy-btn {
|
||||||
padding:3px 5px;
|
width: 3.125rem;
|
||||||
border:1px solid black;
|
line-height: 1.5625rem;
|
||||||
|
border-radius: 0.78125rem;
|
||||||
|
padding: 0;
|
||||||
|
background: #eeeeee;
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #333333;
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
margin-left: 10px;
|
||||||
|
&:after {
|
||||||
|
content: ' ';
|
||||||
|
width: 200%;
|
||||||
|
height: 200%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
// border: 1px solid rgba(0, 0, 0, 0.2);
|
||||||
|
transform: scale(0.5);
|
||||||
|
transform-origin: 0 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -166,6 +166,7 @@
|
|||||||
count: sku.count,
|
count: sku.count,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
point: true,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,528 +1,486 @@
|
|||||||
<template>
|
<template>
|
||||||
<s-layout title="确认订单">
|
<s-layout title="确认订单">
|
||||||
<!-- 头部地址选择【配送地址】【自提地址】 -->
|
<!-- 头部地址选择【配送地址】【自提地址】 -->
|
||||||
<AddressSelection v-model="addressState" />
|
<AddressSelection v-model="addressState" />
|
||||||
|
|
||||||
<!-- 商品信息 -->
|
<!-- 商品信息 -->
|
||||||
<view class="order-card-box ss-m-b-14">
|
<view class="order-card-box ss-m-b-14">
|
||||||
<s-goods-item
|
<s-goods-item v-for="item in state.orderInfo.items" :key="item.skuId" :img="item.picUrl"
|
||||||
v-for="item in state.orderInfo.items"
|
:title="item.spuName" :skuText="item.properties.map((property) => property.valueName).join(' ')"
|
||||||
:key="item.skuId"
|
:price="item.price" :num="item.count" marginBottom="10" />
|
||||||
:img="item.picUrl"
|
<view class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10">
|
||||||
:title="item.spuName"
|
<view class="item-title">订单备注</view>
|
||||||
:skuText="item.properties.map((property) => property.valueName).join(' ')"
|
<view class="ss-flex ss-col-center">
|
||||||
:price="item.price"
|
<uni-easyinput maxlength="20" placeholder="建议留言前先与商家沟通" v-model="state.orderPayload.remark"
|
||||||
:num="item.count"
|
:inputBorder="false" :clearable="false" />
|
||||||
marginBottom="10"
|
</view>
|
||||||
/>
|
</view>
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10">
|
</view>
|
||||||
<view class="item-title">订单备注</view>
|
|
||||||
<view class="ss-flex ss-col-center">
|
|
||||||
<uni-easyinput
|
|
||||||
maxlength="20"
|
|
||||||
placeholder="建议留言前先与商家沟通"
|
|
||||||
v-model="state.orderPayload.remark"
|
|
||||||
:inputBorder="false"
|
|
||||||
:clearable="false"
|
|
||||||
/>
|
|
||||||
</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">
|
<text class="item-value ss-m-r-24">
|
||||||
¥{{ fen2yuan(state.orderInfo.price.totalPrice) }}
|
¥{{ fen2yuan(state.orderInfo.price.totalPrice) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view v-if="state.orderPayload.pointActivityId" class="order-item ss-flex ss-col-center ss-row-between">
|
||||||
v-if="state.orderPayload.pointActivityId"
|
<view class="item-title">兑换积分</view>
|
||||||
class="order-item ss-flex ss-col-center ss-row-between"
|
<view class="ss-flex ss-col-center">
|
||||||
>
|
<image
|
||||||
<view class="item-title">兑换积分</view>
|
src="https://zysc.fjptzykj.com:3000/shangcheng/b0c400b1b30a9ca45031093595e42533de267823285c702fed250061920debf0.png"
|
||||||
<view class="ss-flex ss-col-center">
|
class="score-img" />
|
||||||
<image
|
<text class="item-value ss-m-r-24">
|
||||||
src="https://zysc.fjptzykj.com:3000/shangcheng/b0c400b1b30a9ca45031093595e42533de267823285c702fed250061920debf0.png"
|
{{ state.orderInfo.usePoint }}
|
||||||
class="score-img"
|
</text>
|
||||||
/>
|
</view>
|
||||||
<text class="item-value ss-m-r-24">
|
</view>
|
||||||
{{ state.orderInfo.usePoint }}
|
<view class="order-item ss-flex ss-col-center ss-row-between"
|
||||||
</text>
|
v-if="state.orderInfo.type === 0 || state.orderPayload.pointActivityId">
|
||||||
</view>
|
<view class="item-title">积分抵扣</view>
|
||||||
</view>
|
<view class="ss-flex ss-col-center">
|
||||||
<view
|
{{ state.pointStatus || state.orderPayload.pointActivityId ? '剩余积分' : '当前积分' }}
|
||||||
class="order-item ss-flex ss-col-center ss-row-between"
|
<image
|
||||||
v-if="state.orderInfo.type === 0 || state.orderPayload.pointActivityId"
|
src="https://zysc.fjptzykj.com:3000/shangcheng/b0c400b1b30a9ca45031093595e42533de267823285c702fed250061920debf0.png"
|
||||||
>
|
class="score-img" />
|
||||||
<view class="item-title">积分抵扣</view>
|
<text class="item-value ss-m-r-24">
|
||||||
<view class="ss-flex ss-col-center">
|
{{
|
||||||
{{ state.pointStatus || state.orderPayload.pointActivityId ? '剩余积分' : '当前积分' }}
|
|
||||||
<image
|
|
||||||
src="https://zysc.fjptzykj.com:3000/shangcheng/b0c400b1b30a9ca45031093595e42533de267823285c702fed250061920debf0.png"
|
|
||||||
class="score-img"
|
|
||||||
/>
|
|
||||||
<text class="item-value ss-m-r-24">
|
|
||||||
{{
|
|
||||||
state.pointStatus || state.orderPayload.pointActivityId
|
state.pointStatus || state.orderPayload.pointActivityId
|
||||||
? state.orderInfo.totalPoint - state.orderInfo.usePoint
|
? state.orderInfo.totalPoint - state.orderInfo.usePoint
|
||||||
: state.orderInfo.totalPoint || 0
|
: state.orderInfo.totalPoint || 0
|
||||||
}}
|
}}
|
||||||
</text>
|
</text>
|
||||||
<checkbox-group @change="changeIntegral" v-if="!state.orderPayload.pointActivityId">
|
<checkbox-group @change="changeIntegral" v-if="!state.orderPayload.pointActivityId">
|
||||||
<checkbox
|
<checkbox :checked="state.pointStatus"
|
||||||
:checked="state.pointStatus"
|
:disabled="!state.orderInfo.totalPoint || state.orderInfo.totalPoint <= 0" />
|
||||||
:disabled="!state.orderInfo.totalPoint || state.orderInfo.totalPoint <= 0"
|
</checkbox-group>
|
||||||
/>
|
</view>
|
||||||
</checkbox-group>
|
</view>
|
||||||
</view>
|
<!-- 快递配置时,信息的展示 -->
|
||||||
</view>
|
<view class="order-item ss-flex ss-col-center ss-row-between" v-if="addressState.deliveryType === 1">
|
||||||
<!-- 快递配置时,信息的展示 -->
|
<view class="item-title">运费</view>
|
||||||
<view
|
<view class="ss-flex ss-col-center">
|
||||||
class="order-item ss-flex ss-col-center ss-row-between"
|
<text class="item-value ss-m-r-24" v-if="state.orderInfo.price.deliveryPrice > 0">
|
||||||
v-if="addressState.deliveryType === 1"
|
+¥{{ fen2yuan(state.orderInfo.price.deliveryPrice) }}
|
||||||
>
|
</text>
|
||||||
<view class="item-title">运费</view>
|
<view class="item-value ss-m-r-24" v-else>免运费</view>
|
||||||
<view class="ss-flex ss-col-center">
|
</view>
|
||||||
<text class="item-value ss-m-r-24" v-if="state.orderInfo.price.deliveryPrice > 0">
|
</view>
|
||||||
+¥{{ fen2yuan(state.orderInfo.price.deliveryPrice) }}
|
<!-- 门店自提时,需要填写姓名和手机号 -->
|
||||||
</text>
|
<view class="order-item ss-flex ss-col-center ss-row-between" v-if="addressState.deliveryType === 2">
|
||||||
<view class="item-value ss-m-r-24" v-else>免运费</view>
|
<view class="item-title">联系人</view>
|
||||||
</view>
|
<view class="ss-flex ss-col-center">
|
||||||
</view>
|
<uni-easyinput maxlength="20" placeholder="请填写您的联系姓名" v-model="addressState.receiverName"
|
||||||
<!-- 门店自提时,需要填写姓名和手机号 -->
|
:inputBorder="false" :clearable="false" />
|
||||||
<view
|
</view>
|
||||||
class="order-item ss-flex ss-col-center ss-row-between"
|
</view>
|
||||||
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="item-title">联系人</view>
|
<view class="ss-flex ss-col-center">
|
||||||
<view class="ss-flex ss-col-center">
|
<uni-easyinput maxlength="20" placeholder="请填写您的联系电话" v-model="addressState.receiverMobile"
|
||||||
<uni-easyinput
|
:inputBorder="false" :clearable="false" />
|
||||||
maxlength="20"
|
</view>
|
||||||
placeholder="请填写您的联系姓名"
|
</view>
|
||||||
v-model="addressState.receiverName"
|
<!-- 优惠劵:只有 type = 0 普通订单(非拼团、秒杀、砍价),才可以使用优惠劵 -->
|
||||||
:inputBorder="false"
|
<view class="order-item ss-flex ss-col-center ss-row-between" v-if="state.orderInfo.type === 0">
|
||||||
:clearable="false"
|
<view class="item-title">优惠券</view>
|
||||||
/>
|
<view class="ss-flex ss-col-center" @tap="state.showCoupon = true">
|
||||||
</view>
|
<text class="item-value text-red" v-if="state.orderPayload.couponId > 0">
|
||||||
</view>
|
-¥{{ fen2yuan(state.orderInfo.price.couponPrice) }}
|
||||||
<view
|
</text>
|
||||||
class="order-item ss-flex ss-col-center ss-row-between"
|
<text class="item-value" :class="
|
||||||
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 普通订单(非拼团、秒杀、砍价),才可以使用优惠劵 -->
|
|
||||||
<view
|
|
||||||
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" @tap="state.showCoupon = true">
|
|
||||||
<text class="item-value text-red" v-if="state.orderPayload.couponId > 0">
|
|
||||||
-¥{{ fen2yuan(state.orderInfo.price.couponPrice) }}
|
|
||||||
</text>
|
|
||||||
<text
|
|
||||||
class="item-value"
|
|
||||||
:class="
|
|
||||||
state.couponInfo.filter((coupon) => coupon.match).length > 0
|
state.couponInfo.filter((coupon) => coupon.match).length > 0
|
||||||
? 'text-red'
|
? 'text-red'
|
||||||
: 'text-disabled'
|
: 'text-disabled'
|
||||||
"
|
" v-else>
|
||||||
v-else
|
{{
|
||||||
>
|
|
||||||
{{
|
|
||||||
state.couponInfo.filter((coupon) => coupon.match).length > 0
|
state.couponInfo.filter((coupon) => coupon.match).length > 0
|
||||||
? state.couponInfo.filter((coupon) => coupon.match).length + ' 张可用'
|
? state.couponInfo.filter((coupon) => coupon.match).length + ' 张可用'
|
||||||
: '暂无可用优惠券'
|
: '暂无可用优惠券'
|
||||||
}}
|
}}
|
||||||
</text>
|
</text>
|
||||||
<text class="_icon-forward item-icon" />
|
<text class="_icon-forward item-icon" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view 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.price.discountPrice > 0">
|
||||||
v-if="state.orderInfo.price.discountPrice > 0"
|
<view class="item-title">活动优惠</view>
|
||||||
>
|
<view class="ss-flex ss-col-center" @tap="state.showDiscount = true">
|
||||||
<view class="item-title">活动优惠</view>
|
<text class="item-value text-red">
|
||||||
<view class="ss-flex ss-col-center" @tap="state.showDiscount = true">
|
-¥{{ fen2yuan(state.orderInfo.price.discountPrice) }}
|
||||||
<text class="item-value text-red">
|
</text>
|
||||||
-¥{{ fen2yuan(state.orderInfo.price.discountPrice) }}
|
<text class="_icon-forward item-icon" />
|
||||||
</text>
|
</view>
|
||||||
<text class="_icon-forward item-icon" />
|
</view>
|
||||||
</view>
|
<view class="order-item ss-flex ss-col-center ss-row-between" v-if="state.orderInfo.price.vipPrice > 0">
|
||||||
</view>
|
<view class="item-title">会员优惠</view>
|
||||||
<view
|
<view class="ss-flex ss-col-center">
|
||||||
class="order-item ss-flex ss-col-center ss-row-between"
|
<text class="item-value text-red">
|
||||||
v-if="state.orderInfo.price.vipPrice > 0"
|
-¥{{ fen2yuan(state.orderInfo.price.vipPrice) }}
|
||||||
>
|
</text>
|
||||||
<view class="item-title">会员优惠</view>
|
</view>
|
||||||
<view class="ss-flex ss-col-center">
|
</view>
|
||||||
<text class="item-value text-red">
|
</view>
|
||||||
-¥{{ fen2yuan(state.orderInfo.price.vipPrice) }}
|
<view class="total-box-footer ss-font-28 ss-flex ss-row-right ss-col-center ss-m-r-28">
|
||||||
</text>
|
<view class="total-num ss-m-r-20">
|
||||||
</view>
|
共{{ state.orderInfo.items.reduce((acc, item) => acc + item.count, 0) }}件
|
||||||
</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-num text-red"> ¥{{ fen2yuan(state.orderInfo.price.payPrice) }}</view>
|
||||||
<view class="total-num ss-m-r-20">
|
</view>
|
||||||
共{{ state.orderInfo.items.reduce((acc, item) => acc + item.count, 0) }}件
|
</view>
|
||||||
</view>
|
|
||||||
<view>合计:</view>
|
|
||||||
<view class="total-num text-red"> ¥{{ fen2yuan(state.orderInfo.price.payPrice) }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 选择优惠券弹框 -->
|
<!-- 选择优惠券弹框 -->
|
||||||
<s-coupon-select
|
<s-coupon-select v-model="state.couponInfo" :show="state.showCoupon" @confirm="onSelectCoupon"
|
||||||
v-model="state.couponInfo"
|
@close="state.showCoupon = false" />
|
||||||
:show="state.showCoupon"
|
|
||||||
@confirm="onSelectCoupon"
|
|
||||||
@close="state.showCoupon = false"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 满额折扣弹框 TODO @puhui999:【折扣】后续要把优惠信息打进去 -->
|
<!-- 满额折扣弹框 TODO @puhui999:【折扣】后续要把优惠信息打进去 -->
|
||||||
<s-discount-list
|
<s-discount-list v-model="state.orderInfo" :show="state.showDiscount" @close="state.showDiscount = false" />
|
||||||
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">
|
<view class="total-num ss-font-30 text-red">
|
||||||
¥{{ fen2yuan(state.orderInfo.price.payPrice) }}
|
¥{{ fen2yuan(state.orderInfo.price.payPrice) }}
|
||||||
</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"
|
提交订单
|
||||||
@tap="onConfirm"
|
</button>
|
||||||
>
|
</view>
|
||||||
提交订单
|
</su-fixed>
|
||||||
</button>
|
</s-layout>
|
||||||
</view>
|
|
||||||
</su-fixed>
|
|
||||||
</s-layout>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, watch } from 'vue';
|
import {
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
reactive,
|
||||||
import AddressSelection from '@/pages/order/addressSelection.vue';
|
ref,
|
||||||
import sheep from '@/sheep';
|
watch
|
||||||
import OrderApi from '@/sheep/api/trade/order';
|
} from 'vue';
|
||||||
import TradeConfigApi from '@/sheep/api/trade/config';
|
import {
|
||||||
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
onLoad
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import AddressSelection from '@/pages/order/addressSelection.vue';
|
||||||
|
import sheep from '@/sheep';
|
||||||
|
import OrderApi from '@/sheep/api/trade/order';
|
||||||
|
import TradeConfigApi from '@/sheep/api/trade/config';
|
||||||
|
import {
|
||||||
|
fen2yuan
|
||||||
|
} from '@/sheep/hooks/useGoods';
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
orderPayload: {},
|
orderPayload: {},
|
||||||
orderInfo: {
|
orderInfo: {
|
||||||
items: [], // 商品项列表
|
items: [], // 商品项列表
|
||||||
price: {}, // 价格信息
|
price: {}, // 价格信息
|
||||||
},
|
},
|
||||||
showCoupon: false, // 是否展示优惠劵
|
showCoupon: false, // 是否展示优惠劵
|
||||||
couponInfo: [], // 优惠劵列表
|
couponInfo: [], // 优惠劵列表
|
||||||
showDiscount: false, // 是否展示营销活动
|
showDiscount: false, // 是否展示营销活动
|
||||||
// ========== 积分 ==========
|
// ========== 积分 ==========
|
||||||
pointStatus: false, //是否使用积分
|
pointStatus: false, //是否使用积分
|
||||||
});
|
});
|
||||||
|
|
||||||
const addressState = ref({
|
const addressState = ref({
|
||||||
addressInfo: {}, // 选择的收货地址
|
addressInfo: {}, // 选择的收货地址
|
||||||
deliveryType: 1, // 收货方式:1-快递配送,2-门店自提
|
deliveryType: 1, // 收货方式:1-快递配送,2-门店自提
|
||||||
isPickUp: true, // 门店自提是否开启
|
isPickUp: true, // 门店自提是否开启
|
||||||
pickUpInfo: {}, // 选择的自提门店信息
|
pickUpInfo: {}, // 选择的自提门店信息
|
||||||
receiverName: '', // 收件人名称
|
receiverName: '', // 收件人名称
|
||||||
receiverMobile: '', // 收件人手机
|
receiverMobile: '', // 收件人手机
|
||||||
});
|
});
|
||||||
|
|
||||||
// ========== 积分 ==========
|
// ========== 积分 ==========
|
||||||
/**
|
/**
|
||||||
* 使用积分抵扣
|
* 使用积分抵扣
|
||||||
*/
|
*/
|
||||||
const changeIntegral = async () => {
|
const changeIntegral = async () => {
|
||||||
state.pointStatus = !state.pointStatus;
|
state.pointStatus = !state.pointStatus;
|
||||||
await getOrderInfo();
|
await getOrderInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 选择优惠券
|
// 选择优惠券
|
||||||
async function onSelectCoupon(couponId) {
|
async function onSelectCoupon(couponId) {
|
||||||
state.orderPayload.couponId = couponId;
|
state.orderPayload.couponId = couponId;
|
||||||
await getOrderInfo();
|
await getOrderInfo();
|
||||||
state.showCoupon = false;
|
state.showCoupon = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交订单
|
// 提交订单
|
||||||
function onConfirm() {
|
function onConfirm() {
|
||||||
if (addressState.value.deliveryType === 1 && !addressState.value.addressInfo.id) {
|
if (addressState.value.deliveryType === 1 && !addressState.value.addressInfo.id) {
|
||||||
sheep.$helper.toast('请选择收货地址');
|
sheep.$helper.toast('请选择收货地址');
|
||||||
return;
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建订单&跳转
|
|
||||||
async function submitOrder() {
|
|
||||||
const { code, data } = await OrderApi.createOrder({
|
|
||||||
items: state.orderPayload.items,
|
|
||||||
couponId: state.orderPayload.couponId,
|
|
||||||
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, // 选择门店自提时,该字段为联系人手机
|
|
||||||
pointStatus: state.pointStatus,
|
|
||||||
combinationActivityId: state.orderPayload.combinationActivityId,
|
|
||||||
combinationHeadId: state.orderPayload.combinationHeadId,
|
|
||||||
seckillActivityId: state.orderPayload.seckillActivityId,
|
|
||||||
pointActivityId: state.orderPayload.pointActivityId,
|
|
||||||
});
|
|
||||||
if (code !== 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 更新购物车列表,如果来自购物车
|
|
||||||
if (state.orderPayload.items[0].cartId > 0) {
|
|
||||||
sheep.$store('cart').getList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 跳转到支付页面
|
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查库存 & 计算订单价格
|
|
||||||
async function getOrderInfo() {
|
|
||||||
// 计算价格
|
|
||||||
let parm = {};
|
|
||||||
console.log(state.orderPayload.pointActivityId,'state.orderPayload.pointActivityId')
|
|
||||||
if(state.orderPayload.pointActivityId){
|
|
||||||
parm = {
|
|
||||||
items: state.orderPayload.items,
|
|
||||||
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, // 选择门店自提时,该字段为联系人手机
|
|
||||||
pointStatus: state.pointStatus,
|
|
||||||
combinationActivityId: state.orderPayload.combinationActivityId,
|
|
||||||
combinationHeadId: state.orderPayload.combinationHeadId,
|
|
||||||
seckillActivityId: state.orderPayload.seckillActivityId,
|
|
||||||
pointActivityId: state.orderPayload.pointActivityId,
|
|
||||||
}
|
}
|
||||||
}else{
|
if (addressState.value.deliveryType === 2) {
|
||||||
parm = {
|
if (!addressState.value.pickUpInfo.id) {
|
||||||
items: state.orderPayload.items,
|
sheep.$helper.toast('请选择自提门店地址');
|
||||||
couponId: state.orderPayload.couponId,
|
return;
|
||||||
deliveryType: addressState.value.deliveryType,
|
}
|
||||||
addressId: addressState.value.addressInfo.id, // 收件地址编号
|
if (addressState.value.receiverName === '' || addressState.value.receiverMobile === '') {
|
||||||
pickUpStoreId: addressState.value.pickUpInfo.id, //自提门店编号
|
sheep.$helper.toast('请填写联系人或联系人电话');
|
||||||
receiverName: addressState.value.receiverName, // 选择门店自提时,该字段为联系人名
|
return;
|
||||||
receiverMobile: addressState.value.receiverMobile, // 选择门店自提时,该字段为联系人手机
|
}
|
||||||
pointStatus: state.pointStatus,
|
if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(addressState.value.receiverName)) {
|
||||||
combinationActivityId: state.orderPayload.combinationActivityId,
|
sheep.$helper.toast('请填写您的真实姓名');
|
||||||
combinationHeadId: state.orderPayload.combinationHeadId,
|
return;
|
||||||
seckillActivityId: state.orderPayload.seckillActivityId,
|
}
|
||||||
|
if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(addressState.value.receiverMobile)) {
|
||||||
|
sheep.$helper.toast('请填写正确的手机号');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
submitOrder();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建订单&跳转
|
||||||
|
async function submitOrder() {
|
||||||
|
const {
|
||||||
|
code,
|
||||||
|
data
|
||||||
|
} = await OrderApi.createOrder({
|
||||||
|
items: state.orderPayload.items,
|
||||||
|
couponId: state.orderPayload.couponId,
|
||||||
|
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, // 选择门店自提时,该字段为联系人手机
|
||||||
|
pointStatus: state.pointStatus,
|
||||||
|
combinationActivityId: state.orderPayload.combinationActivityId,
|
||||||
|
combinationHeadId: state.orderPayload.combinationHeadId,
|
||||||
|
seckillActivityId: state.orderPayload.seckillActivityId,
|
||||||
|
pointActivityId: state.orderPayload.pointActivityId,
|
||||||
|
});
|
||||||
|
if (code !== 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 更新购物车列表,如果来自购物车
|
||||||
|
if (state.orderPayload.items[0].cartId > 0) {
|
||||||
|
sheep.$store('cart').getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 跳转到支付页面
|
||||||
|
if (data.payOrderId && data.payOrderId > 0) {
|
||||||
|
sheep.$router.redirect('/pages/pay/index', {
|
||||||
|
id: data.payOrderId,
|
||||||
|
});
|
||||||
|
} else if(!state.orderPayload.point) {
|
||||||
|
sheep.$router.redirect('/pages/order/detail', {
|
||||||
|
id: data.id,
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
sheep.$router.redirect('/pages/activity/point/exchange_detail', {
|
||||||
|
id: data.id,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const { data, code } = await OrderApi.settlementOrder(parm);
|
|
||||||
if (code !== 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
state.orderInfo = data;
|
|
||||||
state.couponInfo = data.coupons || [];
|
|
||||||
// 设置收货地址
|
|
||||||
if (state.orderInfo.address) {
|
|
||||||
addressState.value.addressInfo = state.orderInfo.address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onLoad(async (options) => {
|
// 检查库存 & 计算订单价格
|
||||||
if (!options.data) {
|
async function getOrderInfo() {
|
||||||
sheep.$helper.toast('参数不正确,请检查!');
|
// 计算价格
|
||||||
return;
|
let parm = {};
|
||||||
}
|
console.log(state.orderPayload.pointActivityId, 'state.orderPayload.pointActivityId')
|
||||||
state.orderPayload = JSON.parse(options.data);
|
if (state.orderPayload.pointActivityId) {
|
||||||
await getOrderInfo();
|
parm = {
|
||||||
// 获取交易配置
|
items: state.orderPayload.items,
|
||||||
const { data, code } = await TradeConfigApi.getTradeConfig();
|
couponId: state.orderPayload.couponId,
|
||||||
if (code === 0) {
|
deliveryType: addressState.value.deliveryType,
|
||||||
addressState.value.isPickUp = data.deliveryPickUpEnabled;
|
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,
|
||||||
|
pointActivityId: state.orderPayload.pointActivityId,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
parm = {
|
||||||
|
items: state.orderPayload.items,
|
||||||
|
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, // 选择门店自提时,该字段为联系人手机
|
||||||
|
pointStatus: state.pointStatus,
|
||||||
|
combinationActivityId: state.orderPayload.combinationActivityId,
|
||||||
|
combinationHeadId: state.orderPayload.combinationHeadId,
|
||||||
|
seckillActivityId: state.orderPayload.seckillActivityId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 使用 watch 监听地址和配送方式的变化
|
|
||||||
watch(addressState, async (newAddress, oldAddress) => {
|
const {
|
||||||
// 如果收货地址或配送方式有变化,则重新计算价格
|
data,
|
||||||
if (
|
code
|
||||||
newAddress.addressInfo.id !== oldAddress.addressInfo.id ||
|
} = await OrderApi.settlementOrder(parm);
|
||||||
newAddress.deliveryType !== oldAddress.deliveryType
|
if (code !== 0) {
|
||||||
) {
|
return;
|
||||||
await getOrderInfo();
|
}
|
||||||
}
|
state.orderInfo = data;
|
||||||
});
|
state.couponInfo = data.coupons || [];
|
||||||
|
// 设置收货地址
|
||||||
|
if (state.orderInfo.address) {
|
||||||
|
addressState.value.addressInfo = state.orderInfo.address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad(async (options) => {
|
||||||
|
if (!options.data) {
|
||||||
|
sheep.$helper.toast('参数不正确,请检查!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.orderPayload = JSON.parse(options.data);
|
||||||
|
await getOrderInfo();
|
||||||
|
// 获取交易配置
|
||||||
|
const {
|
||||||
|
data,
|
||||||
|
code
|
||||||
|
} = await TradeConfigApi.getTradeConfig();
|
||||||
|
if (code === 0) {
|
||||||
|
addressState.value.isPickUp = data.deliveryPickUpEnabled;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 使用 watch 监听地址和配送方式的变化
|
||||||
|
watch(addressState, async (newAddress, oldAddress) => {
|
||||||
|
// 如果收货地址或配送方式有变化,则重新计算价格
|
||||||
|
if (
|
||||||
|
newAddress.addressInfo.id !== oldAddress.addressInfo.id ||
|
||||||
|
newAddress.deliveryType !== oldAddress.deliveryType
|
||||||
|
) {
|
||||||
|
await getOrderInfo();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
:deep() {
|
:deep() {
|
||||||
.uni-input-wrapper {
|
.uni-input-wrapper {
|
||||||
width: 320rpx;
|
width: 320rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-easyinput__content-input {
|
.uni-easyinput__content-input {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
height: 72rpx;
|
height: 72rpx;
|
||||||
text-align: right !important;
|
text-align: right !important;
|
||||||
padding-right: 0 !important;
|
padding-right: 0 !important;
|
||||||
|
|
||||||
.uni-input-input {
|
.uni-input-input {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
height: 32rpx;
|
height: 32rpx;
|
||||||
margin-top: 4rpx;
|
margin-top: 4rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-easyinput__content {
|
.uni-easyinput__content {
|
||||||
display: flex !important;
|
display: flex !important;
|
||||||
align-items: center !important;
|
align-items: center !important;
|
||||||
justify-content: right !important;
|
justify-content: right !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.score-img {
|
.score-img {
|
||||||
width: 36rpx;
|
width: 36rpx;
|
||||||
height: 36rpx;
|
height: 36rpx;
|
||||||
margin: 0 4rpx;
|
margin: 0 4rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.order-item {
|
.order-item {
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
|
|
||||||
.item-title {
|
.item-title {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-value {
|
.item-value {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-family: OPPOSANS;
|
font-family: OPPOSANS;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-disabled {
|
.text-disabled {
|
||||||
color: #bbbbbb;
|
color: #bbbbbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-icon {
|
.item-icon {
|
||||||
color: $dark-9;
|
color: $dark-9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remark-input {
|
.remark-input {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-placeholder {
|
.item-placeholder {
|
||||||
color: $dark-9;
|
color: $dark-9;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.total-box-footer {
|
.total-box-footer {
|
||||||
height: 90rpx;
|
height: 90rpx;
|
||||||
|
|
||||||
.total-num {
|
.total-num {
|
||||||
color: #333333;
|
color: #333333;
|
||||||
font-family: OPPOSANS;
|
font-family: OPPOSANS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer-box {
|
.footer-box {
|
||||||
height: 100rpx;
|
height: 100rpx;
|
||||||
|
|
||||||
.submit-btn {
|
.submit-btn {
|
||||||
width: 240rpx;
|
width: 240rpx;
|
||||||
height: 70rpx;
|
height: 70rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|
||||||
.goto-pay-text {
|
.goto-pay-text {
|
||||||
line-height: 28rpx;
|
line-height: 28rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cancel-btn {
|
.cancel-btn {
|
||||||
width: 240rpx;
|
width: 240rpx;
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
background-color: #e5e5e5;
|
background-color: #e5e5e5;
|
||||||
color: $dark-9;
|
color: $dark-9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtitle {
|
.subtitle {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #999999;
|
color: #999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cicon-checkbox {
|
.cicon-checkbox {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
color: var(--ui-BG-Main);
|
color: var(--ui-BG-Main);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cicon-box {
|
.cicon-box {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
color: #999999;
|
color: #999999;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -138,8 +138,13 @@
|
|||||||
},
|
},
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
console.log(res,"-----------试用---------------")
|
console.log(res,"-----------试用---------------")
|
||||||
sheep.$helper.toast('试用开通成功');
|
if(res.code == 200){
|
||||||
sheep.$router.go('/pages/index/user')
|
sheep.$helper.toast('试用开通成功');
|
||||||
|
sheep.$router.go('/pages/index/user')
|
||||||
|
}else{
|
||||||
|
sheep.$helper.toast(res.msg);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user