feat: 增加现金支付
This commit is contained in:
+353
-307
@@ -1,213 +1,259 @@
|
||||
<template>
|
||||
<s-pages title="收银台" :pink_bg="true" :goLeft="false" @onClickLeft="onClickLeft">
|
||||
<view class="p-x-32">
|
||||
<view class="center p-t-96 weight500 size100"><span class="size48">¥</span>
|
||||
{{ fen2yuan(state.orderInfo.payPrice) }}
|
||||
</view>
|
||||
<view class="center size22 c_money">
|
||||
已优惠{{ fen2yuan(state.orderInfo.randomDiscountPrice) }}元
|
||||
</view>
|
||||
<view class="center m-t-20 m-b-66">{{ payDescText }}</view>
|
||||
<view>
|
||||
<radio-group @change="onTapPay">
|
||||
<label class="" v-for="item in state.payMethods" :key="item.title">
|
||||
<view class="flex-center ju-between m-b-40" :class="{ 'disabled-pay-item': item.disabled }">
|
||||
<view class="flex-center">
|
||||
<image class="h_64 w_64" v-if="item.disabled"
|
||||
:src="sheep.$url.static('/static/img/shop/pay/cod_disabled.png')"
|
||||
mode="aspectFit" />
|
||||
<image class="h_64 w_64" v-else :src="sheep.$url.static(item.icon)" mode="aspectFit" />
|
||||
<text class="pay-title m-l-12">{{ item.title }}</text>
|
||||
</view>
|
||||
<view class="check-box ss-flex ss-col-center ss-p-l-10">
|
||||
<view class="userInfo-money ss-m-r-10" v-if="item.value === 'wallet'">
|
||||
余额: {{ fen2yuan(totalRecharge) }}元
|
||||
</view>
|
||||
<view class="">
|
||||
<radio :value="item.value" color="var(--ui-BG-Main)"
|
||||
backgroundColor="rgba(255, 255, 255, 0)" :disabled="item.disabled"
|
||||
:checked="state.payment === item.value" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
<s-pages title="收银台" :pink_bg="true" :goLeft="false" @onClickLeft="onClickLeft">
|
||||
<view class="p-x-32">
|
||||
<view class="center p-t-96 weight500 size100"
|
||||
><span class="size48">¥</span>
|
||||
{{ fen2yuan(state.orderInfo.payPrice) }}
|
||||
</view>
|
||||
<view class="center size22 c_money">
|
||||
已优惠{{ fen2yuan(state.orderInfo.randomDiscountPrice) }}元
|
||||
</view>
|
||||
<view class="center m-t-20 m-b-66">{{ payDescText }}</view>
|
||||
<view>
|
||||
<radio-group @change="onTapPay">
|
||||
<label class="" v-for="item in state.payMethods" :key="item.title">
|
||||
<view
|
||||
class="flex-center ju-between m-b-40"
|
||||
:class="{ 'disabled-pay-item': item.disabled }"
|
||||
>
|
||||
<view class="flex-center">
|
||||
<image
|
||||
class="h_64 w_64"
|
||||
v-if="item.disabled"
|
||||
:src="sheep.$url.static('/static/img/shop/pay/cod_disabled.png')"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<image
|
||||
class="h_64 w_64"
|
||||
v-else
|
||||
:src="sheep.$url.static(item.icon)"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="pay-title m-l-12">{{ item.title }}</text>
|
||||
</view>
|
||||
<view class="check-box ss-flex ss-col-center ss-p-l-10">
|
||||
<view class="userInfo-money ss-m-r-10" v-if="item.value === 'wallet'">
|
||||
余额: {{ fen2yuan(totalRecharge) }}元
|
||||
</view>
|
||||
<view class="">
|
||||
<radio
|
||||
:value="item.value"
|
||||
color="var(--ui-BG-Main)"
|
||||
backgroundColor="rgba(255, 255, 255, 0)"
|
||||
:disabled="item.disabled"
|
||||
:checked="state.payment === item.value"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
|
||||
<!-- 工具 -->
|
||||
<view class="modal-footer ss-flex ss-row-center ss-col-center ss-m-t-80 ss-m-b-40">
|
||||
<button v-if="state.payStatus === 0" class="ss-reset-button past-due-btn">
|
||||
检测支付环境中
|
||||
</button>
|
||||
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
|
||||
支付已过期
|
||||
</button>
|
||||
<button v-else class="ai-button2" @tap="onPay" :disabled="state.payStatus !== 1"
|
||||
:class="{ 'disabled-btn': state.payStatus !== 1 }">
|
||||
立即支付
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</s-pages>
|
||||
<!-- 工具 -->
|
||||
<view class="modal-footer ss-flex ss-row-center ss-col-center ss-m-t-80 ss-m-b-40">
|
||||
<button v-if="state.payStatus === 0" class="ss-reset-button past-due-btn">
|
||||
检测支付环境中
|
||||
</button>
|
||||
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
|
||||
支付已过期
|
||||
</button>
|
||||
<button v-else-if="state.payStatus === 3" class="ai-button2" @tap="onPay">
|
||||
切换支付方式
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="ai-button2"
|
||||
@tap="onPay"
|
||||
:disabled="state.payStatus !== 1"
|
||||
:class="{ 'disabled-btn': state.payStatus !== 1 }"
|
||||
>
|
||||
立即支付
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</s-pages>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
getCurrentInstance,
|
||||
watch,
|
||||
nextTick,
|
||||
computed,
|
||||
} from 'vue';
|
||||
let { proxy } = getCurrentInstance();
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import * as api from '@/sheep/api/ai/index';
|
||||
import sheep from '@/sheep';
|
||||
import PayChannelApi from '@/sheep/api/pay/channel';
|
||||
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
|
||||
import { getPayMethods, goPayResult } from '@/sheep/platform/pay';
|
||||
import { SYSCONST } from '@/sheep/helper/const';
|
||||
import { getWallet } from '@/sheep/api/home/pay';
|
||||
let id = ref('');
|
||||
let payOrderId = ref('');
|
||||
let orderInfo = ref({});
|
||||
const userWallet = ref();
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
getCurrentInstance,
|
||||
watch,
|
||||
nextTick,
|
||||
computed,
|
||||
} from 'vue';
|
||||
let { proxy } = getCurrentInstance();
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import * as api from '@/sheep/api/ai/index';
|
||||
import sheep from '@/sheep';
|
||||
import PayChannelApi from '@/sheep/api/pay/channel';
|
||||
import PayOrderApi from '@/sheep/api/pay/order';
|
||||
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
|
||||
import { getPayMethods, goPayResult } from '@/sheep/platform/pay';
|
||||
import { SYSCONST } from '@/sheep/helper/const';
|
||||
import { getWallet } from '@/sheep/api/home/pay';
|
||||
let id = ref('');
|
||||
let payOrderId = ref('');
|
||||
let orderInfo = ref({});
|
||||
const userWallet = ref();
|
||||
const returnTo = ref('');
|
||||
|
||||
let totalRecharge = ref();
|
||||
// 检测支付环境
|
||||
const state = reactive({
|
||||
orderType: 'aiGoods', // 订单类型; goods - 商品订单, recharge - 充值订单 aiRecharge
|
||||
orderInfo: {}, // 支付单信息
|
||||
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
|
||||
payMethods: [], // 可选的支付方式
|
||||
payment: '', // 选中的支付方式
|
||||
});
|
||||
const getOrderDetail = async () => {
|
||||
let { code, data } = await api.getOrderDetail({ id: id.value });
|
||||
console.log('订单详情', code, data);
|
||||
if (code !== 0 || !data) {
|
||||
state.payStatus = -2;
|
||||
return;
|
||||
}
|
||||
state.orderInfo = data || {};
|
||||
// 设置支付状态
|
||||
checkPayStatus();
|
||||
// 获得支付方式
|
||||
await setPayMethods();
|
||||
};
|
||||
let totalRecharge = ref();
|
||||
// 检测支付环境
|
||||
const state = reactive({
|
||||
orderType: 'aiGoods', // 订单类型; goods - 商品订单, recharge - 充值订单 aiRecharge
|
||||
orderInfo: {}, // 支付单信息
|
||||
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付,3=现金待确认
|
||||
payMethods: [], // 可选的支付方式
|
||||
payment: '', // 选中的支付方式
|
||||
});
|
||||
const getOrderDetail = async () => {
|
||||
let { code, data } = await api.getOrderDetail({ id: id.value });
|
||||
console.log('订单详情', code, data);
|
||||
if (code !== 0 || !data) {
|
||||
state.payStatus = -2;
|
||||
return;
|
||||
}
|
||||
state.orderInfo = data || {};
|
||||
// 设置支付状态
|
||||
checkPayStatus();
|
||||
// 获得支付方式
|
||||
await setPayMethods();
|
||||
};
|
||||
|
||||
// 获得支付方式
|
||||
async function setPayMethods() {
|
||||
const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId || 1);
|
||||
// console.log('支付方式', code, data);
|
||||
if (code !== 0) {
|
||||
return;
|
||||
}
|
||||
state.payMethods = getPayMethods(data);
|
||||
console.log('支付方式', state.payMethods);
|
||||
// 金额超出阈值,仅允许余额支付
|
||||
if (state.orderInfo?.totalPrice >= SYSCONST.MAX_PRICE) {
|
||||
state.payMethods = state.payMethods.map((item) => ({
|
||||
...item,
|
||||
disabled: item.value !== 'wallet' ? true : item.disabled,
|
||||
}));
|
||||
state.payment = 'wallet';
|
||||
}
|
||||
state.payMethods.find((item) => {
|
||||
if (item.value && !item.disabled) {
|
||||
state.payment = item.value;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 支付文案提示
|
||||
const payDescText = computed(() => {
|
||||
if (state.payStatus === 2) {
|
||||
return '该订单已支付';
|
||||
}
|
||||
if (state.payStatus === 1 && state.orderInfo?.payExpireTime) {
|
||||
const time = useDurationTime(state.orderInfo.payExpireTime);
|
||||
if (time?.ms <= 0) {
|
||||
state.payStatus = -1;
|
||||
return '';
|
||||
}
|
||||
return `剩余支付时间 ${time?.h}:${time?.m}:${time?.s} `;
|
||||
}
|
||||
if (state.payStatus === -2) {
|
||||
return '未查询到支付单信息';
|
||||
}
|
||||
return '';
|
||||
});
|
||||
// 获得支付方式
|
||||
async function setPayMethods() {
|
||||
// 业务订单详情不含支付应用编号,拆分后需从支付单获取真实 appId,避免误用商城应用渠道
|
||||
let appId = Number(state.orderInfo.appId);
|
||||
if (!appId && payOrderId.value) {
|
||||
const payOrderRes = await PayOrderApi.getOrder(payOrderId.value, false);
|
||||
appId = Number(payOrderRes?.data?.appId);
|
||||
}
|
||||
if (!appId) {
|
||||
sheep.$helper.toast('支付应用信息异常');
|
||||
state.payMethods = [];
|
||||
return;
|
||||
}
|
||||
const { data, code } = await PayChannelApi.getEnableChannelCodeList(appId);
|
||||
// console.log('支付方式', code, data);
|
||||
if (code !== 0) {
|
||||
return;
|
||||
}
|
||||
// 现金待确认状态下去除现金渠道,仅展示可切换的线上渠道
|
||||
state.payMethods = getPayMethods(data).filter(
|
||||
(item) => item.value !== 'cash' || state.payStatus !== 3,
|
||||
);
|
||||
console.log('支付方式', state.payMethods);
|
||||
// 金额超出阈值,仅允许余额支付
|
||||
if (state.orderInfo?.totalPrice >= SYSCONST.MAX_PRICE) {
|
||||
state.payMethods = state.payMethods.map((item) => ({
|
||||
...item,
|
||||
disabled: item.value !== 'wallet' ? true : item.disabled,
|
||||
}));
|
||||
state.payment = 'wallet';
|
||||
}
|
||||
state.payMethods.find((item) => {
|
||||
if (item.value && !item.disabled) {
|
||||
state.payment = item.value;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 支付文案提示
|
||||
const payDescText = computed(() => {
|
||||
if (state.payStatus === 2) {
|
||||
return '该订单已支付';
|
||||
}
|
||||
if (state.payStatus === 3) {
|
||||
return '现金待确认';
|
||||
}
|
||||
if (state.payStatus === 1 && state.orderInfo?.payExpireTime) {
|
||||
const time = useDurationTime(state.orderInfo.payExpireTime);
|
||||
if (time?.ms <= 0) {
|
||||
state.payStatus = -1;
|
||||
return '';
|
||||
}
|
||||
return `剩余支付时间 ${time?.h}:${time?.m}:${time?.s} `;
|
||||
}
|
||||
if (state.payStatus === -2) {
|
||||
return '未查询到支付单信息';
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
// 状态转换:payOrder.status => payStatus
|
||||
function checkPayStatus() {
|
||||
if (state.orderInfo.status === 10 || state.orderInfo.status === 20) {
|
||||
// 支付成功
|
||||
state.payStatus = 2;
|
||||
// 跳转回支付成功页
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '订单已支付',
|
||||
confirmColor: '#FA7E31',
|
||||
showCancel: false,
|
||||
success: function () {
|
||||
goPayResult(state.orderInfo.id, state.orderType);
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (state.orderInfo.status === 30) {
|
||||
// 支付关闭
|
||||
state.payStatus = -1;
|
||||
return;
|
||||
}
|
||||
state.payStatus = 1; // 待支付
|
||||
}
|
||||
// 状态转换:payOrder.status => payStatus
|
||||
function checkPayStatus() {
|
||||
if (state.orderInfo.status === 10 || state.orderInfo.status === 20) {
|
||||
// 支付成功
|
||||
state.payStatus = 2;
|
||||
// 跳转回支付成功页
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '订单已支付',
|
||||
confirmColor: '#FA7E31',
|
||||
showCancel: false,
|
||||
success: function () {
|
||||
goPayResult(state.orderInfo.id, state.orderType);
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (state.orderInfo.status === 30) {
|
||||
// 支付关闭
|
||||
state.payStatus = -1;
|
||||
return;
|
||||
}
|
||||
if (Number(state.orderInfo.status) === 70) {
|
||||
state.payStatus = 3;
|
||||
return;
|
||||
}
|
||||
state.payStatus = 1; // 待支付
|
||||
}
|
||||
|
||||
// 切换支付方式
|
||||
function onTapPay(e) {
|
||||
state.payment = e.detail.value;
|
||||
}
|
||||
let type = ref(); //2充值
|
||||
onLoad(async (options) => {
|
||||
id.value = options.id || '';
|
||||
payOrderId.value = options.payOrderId || '';
|
||||
type.value = options.type || '';
|
||||
// 切换支付方式
|
||||
function onTapPay(e) {
|
||||
state.payment = e.detail.value;
|
||||
}
|
||||
let type = ref(); //2充值
|
||||
onLoad(async (options) => {
|
||||
id.value = options.id || '';
|
||||
payOrderId.value = options.payOrderId || '';
|
||||
type.value = options.type || '';
|
||||
returnTo.value = options.returnTo || '';
|
||||
|
||||
if (type.value == 2) {
|
||||
state.orderType = 'aiRecharge';
|
||||
state.orderInfo.totalPrice = options.price * 100;
|
||||
// state.orderInfo.price = options.price || '';
|
||||
if (type.value == 2) {
|
||||
state.orderType = 'aiRecharge';
|
||||
state.orderInfo.totalPrice = options.price * 100;
|
||||
// state.orderInfo.price = options.price || '';
|
||||
|
||||
// 设置支付状态
|
||||
checkPayStatus();
|
||||
// 获得支付方式
|
||||
await setPayMethods();
|
||||
} else {
|
||||
getOrderDetail();
|
||||
}
|
||||
});
|
||||
onShow(() => {
|
||||
getWallet().then((res) => {
|
||||
if (res.code === 0) {
|
||||
totalRecharge.value = res.data.totalRecharge;
|
||||
}
|
||||
});
|
||||
});
|
||||
const onPay = () => {
|
||||
// console.log(userWallet.value.totalRecharge);
|
||||
if (state.payment === '') {
|
||||
sheep.$helper.toast('请选择支付方式');
|
||||
return;
|
||||
}
|
||||
if (state.orderInfo.totalPrice >= SYSCONST.MAX_PRICE && state.payment !== 'wallet') {
|
||||
sheep.$helper.toast('请选择余额支付');
|
||||
return;
|
||||
}
|
||||
// 设置支付状态
|
||||
checkPayStatus();
|
||||
// 获得支付方式
|
||||
await setPayMethods();
|
||||
} else {
|
||||
getOrderDetail();
|
||||
}
|
||||
});
|
||||
onShow(() => {
|
||||
getWallet().then((res) => {
|
||||
if (res.code === 0) {
|
||||
totalRecharge.value = res.data.totalRecharge;
|
||||
}
|
||||
});
|
||||
});
|
||||
const onPay = () => {
|
||||
// console.log(userWallet.value.totalRecharge);
|
||||
if (state.payment === '') {
|
||||
sheep.$helper.toast('请选择支付方式');
|
||||
return;
|
||||
}
|
||||
if (state.orderInfo.totalPrice >= SYSCONST.MAX_PRICE && state.payment !== 'wallet') {
|
||||
sheep.$helper.toast('请选择余额支付');
|
||||
return;
|
||||
}
|
||||
if (returnTo.value) {
|
||||
uni.setStorageSync('pay_return_to', returnTo.value);
|
||||
} else if (String(type.value) === '2') {
|
||||
@@ -215,130 +261,130 @@
|
||||
} else if (state.orderType === 'aiGoods') {
|
||||
uni.setStorageSync('pay_return_to', 'aiStore_myshop');
|
||||
}
|
||||
if (state.payment === 'wallet') {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要支付吗?',
|
||||
confirmColor: '#FA7E31',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
// sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
|
||||
if (totalRecharge.value < state.orderInfo.totalPrice) {
|
||||
uni.showToast({
|
||||
title: '余额不足请充值',
|
||||
icon: 'none',
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/home/recharge',
|
||||
});
|
||||
}, 1000);
|
||||
} else {
|
||||
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
|
||||
}
|
||||
};
|
||||
const onClickLeft = () => {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
};
|
||||
if (state.payment === 'wallet') {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要支付吗?',
|
||||
confirmColor: '#FA7E31',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
// sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
|
||||
if (totalRecharge.value < state.orderInfo.totalPrice) {
|
||||
uni.showToast({
|
||||
title: '余额不足请充值',
|
||||
icon: 'none',
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/home/recharge',
|
||||
});
|
||||
}, 1000);
|
||||
} else {
|
||||
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
|
||||
}
|
||||
};
|
||||
const onClickLeft = () => {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.pay-icon {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 26rpx;
|
||||
}
|
||||
.pay-icon {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 26rpx;
|
||||
}
|
||||
|
||||
.ss-modal-box {
|
||||
// max-height: 1000rpx;
|
||||
.ss-modal-box {
|
||||
// max-height: 1000rpx;
|
||||
|
||||
.modal-header {
|
||||
position: relative;
|
||||
padding: 60rpx 20rpx 40rpx;
|
||||
.modal-header {
|
||||
position: relative;
|
||||
padding: 60rpx 20rpx 40rpx;
|
||||
|
||||
.money-text {
|
||||
color: $red;
|
||||
font-size: 46rpx;
|
||||
font-weight: bold;
|
||||
font-family: OPPOSANS;
|
||||
.money-text {
|
||||
color: $red;
|
||||
font-size: 46rpx;
|
||||
font-weight: bold;
|
||||
font-family: OPPOSANS;
|
||||
|
||||
&::before {
|
||||
content: '¥';
|
||||
font-size: 30rpx;
|
||||
}
|
||||
}
|
||||
&::before {
|
||||
content: '¥';
|
||||
font-size: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.time-text {
|
||||
font-size: 26rpx;
|
||||
color: $gray-b;
|
||||
}
|
||||
.time-text {
|
||||
font-size: 26rpx;
|
||||
color: $gray-b;
|
||||
}
|
||||
|
||||
.close-icon {
|
||||
position: absolute;
|
||||
top: 10rpx;
|
||||
right: 20rpx;
|
||||
font-size: 46rpx;
|
||||
opacity: 0.2;
|
||||
}
|
||||
}
|
||||
.close-icon {
|
||||
position: absolute;
|
||||
top: 10rpx;
|
||||
right: 20rpx;
|
||||
font-size: 46rpx;
|
||||
opacity: 0.2;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
overflow-y: auto;
|
||||
.modal-content {
|
||||
overflow-y: auto;
|
||||
|
||||
.pay-title {
|
||||
font-size: 26rpx;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
}
|
||||
.pay-title {
|
||||
font-size: 26rpx;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.pay-tip {
|
||||
font-size: 26rpx;
|
||||
color: #bbbbbb;
|
||||
}
|
||||
.pay-tip {
|
||||
font-size: 26rpx;
|
||||
color: #bbbbbb;
|
||||
}
|
||||
|
||||
.pay-item {
|
||||
height: 86rpx;
|
||||
}
|
||||
.pay-item {
|
||||
height: 86rpx;
|
||||
}
|
||||
|
||||
.disabled-pay-item {
|
||||
.pay-title {
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
.disabled-pay-item {
|
||||
.pay-title {
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
.userInfo-money {
|
||||
font-size: 26rpx;
|
||||
color: #bbbbbb;
|
||||
line-height: normal;
|
||||
}
|
||||
}
|
||||
.userInfo-money {
|
||||
font-size: 26rpx;
|
||||
color: #bbbbbb;
|
||||
line-height: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
width: 710rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
|
||||
color: $white;
|
||||
}
|
||||
.save-btn {
|
||||
width: 710rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
|
||||
color: $white;
|
||||
}
|
||||
|
||||
.disabled-btn {
|
||||
background: #e5e5e5;
|
||||
color: #999999;
|
||||
}
|
||||
.disabled-btn {
|
||||
background: #e5e5e5;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.past-due-btn {
|
||||
width: 710rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
background-color: #999;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
.past-due-btn {
|
||||
width: 710rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
background-color: #999;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -60,6 +60,9 @@
|
||||
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
|
||||
支付已过期
|
||||
</button>
|
||||
<button v-else-if="state.payStatus === 3" class="ai-button2" @tap="onPay">
|
||||
切换支付方式
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="ai-button2"
|
||||
@@ -89,6 +92,7 @@
|
||||
import * as api from '@/sheep/api/ai/index';
|
||||
import sheep from '@/sheep';
|
||||
import PayChannelApi from '@/sheep/api/pay/channel';
|
||||
import PayOrderApi from '@/sheep/api/pay/order';
|
||||
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
|
||||
import { getPayMethods, goPayResult } from '@/sheep/platform/pay';
|
||||
import { SYSCONST } from '@/sheep/helper/const';
|
||||
@@ -104,7 +108,7 @@
|
||||
const state = reactive({
|
||||
orderType: 'aiGoods', // 订单类型; goods - 商品订单, recharge - 充值订单 aiRecharge
|
||||
orderInfo: {}, // 支付单信息
|
||||
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
|
||||
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付,3=现金待确认
|
||||
payMethods: [], // 可选的支付方式
|
||||
payment: '', // 选中的支付方式
|
||||
});
|
||||
@@ -123,11 +127,25 @@
|
||||
|
||||
// 获得支付方式
|
||||
async function setPayMethods() {
|
||||
const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId || 1);
|
||||
// 业务订单详情不含支付应用编号,拆分后需从支付单获取真实 appId,避免误用商城应用渠道
|
||||
let appId = Number(state.orderInfo.appId);
|
||||
if (!appId && payOrderId.value) {
|
||||
const payOrderRes = await PayOrderApi.getOrder(payOrderId.value, false);
|
||||
appId = Number(payOrderRes?.data?.appId);
|
||||
}
|
||||
if (!appId) {
|
||||
sheep.$helper.toast('支付应用信息异常');
|
||||
state.payMethods = [];
|
||||
return;
|
||||
}
|
||||
const { data, code } = await PayChannelApi.getEnableChannelCodeList(appId);
|
||||
if (code !== 0) {
|
||||
return;
|
||||
}
|
||||
state.payMethods = getPayMethods(data);
|
||||
// 现金待确认状态下去除现金渠道,仅展示可切换的线上渠道
|
||||
state.payMethods = getPayMethods(data).filter(
|
||||
(item) => item.value !== 'cash' || state.payStatus !== 3,
|
||||
);
|
||||
// 金额超出阈值,仅允许余额支付
|
||||
if (state.orderInfo?.totalPrice >= SYSCONST.MAX_PRICE) {
|
||||
state.payMethods = state.payMethods.map((item) => ({
|
||||
@@ -148,6 +166,9 @@
|
||||
if (state.payStatus === 2) {
|
||||
return '该订单已支付';
|
||||
}
|
||||
if (state.payStatus === 3) {
|
||||
return '现金待确认';
|
||||
}
|
||||
if (state.payStatus === 1 && state.orderInfo?.payExpireTime) {
|
||||
const time = useDurationTime(state.orderInfo.payExpireTime);
|
||||
if (time?.ms <= 0) {
|
||||
@@ -184,6 +205,10 @@
|
||||
state.payStatus = -1;
|
||||
return;
|
||||
}
|
||||
if (Number(state.orderInfo.status) === 70) {
|
||||
state.payStatus = 3;
|
||||
return;
|
||||
}
|
||||
state.payStatus = 1; // 待支付
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,11 @@
|
||||
<view class="copy" @click.stop="onCopy">
|
||||
<image :src="`${$url}goods/copy1.png`" mode="scaleToFill" />
|
||||
</view>
|
||||
<truckLine :data="state.orderInfo" :code="3" v-if="state.orderInfo.deliveryTime"></truckLine>
|
||||
<truckLine
|
||||
:data="state.orderInfo"
|
||||
:code="3"
|
||||
v-if="state.orderInfo.deliveryTime"
|
||||
></truckLine>
|
||||
</view>
|
||||
<view class="notice-item flex-row ju-between">
|
||||
<text class="title c25">下单时间</text>
|
||||
@@ -169,6 +173,12 @@
|
||||
text: '已取消',
|
||||
text1: '您的订单已取消!',
|
||||
},
|
||||
70: {
|
||||
text: '现金待确认',
|
||||
text1: '等待工作人员确认收款',
|
||||
btn1: '切换支付',
|
||||
btn2: '取消订单',
|
||||
},
|
||||
});
|
||||
|
||||
// ========== 门店自提(核销) ==========
|
||||
@@ -234,7 +244,14 @@
|
||||
}
|
||||
if (state.orderInfo.status === 0 && type === 2) {
|
||||
// 取消订单
|
||||
cancelOrder();
|
||||
cancelUnpaidOpenOrder();
|
||||
}
|
||||
if (Number(state.orderInfo.status) === 70 && type === 2) {
|
||||
cancelOpenOrder();
|
||||
}
|
||||
if (Number(state.orderInfo.status) === 70 && type === 1) {
|
||||
// 现金待确认切回线上支付
|
||||
goPay();
|
||||
}
|
||||
if (state.orderInfo.status === 20 && type === 1) {
|
||||
// 确认收货confirmReceive
|
||||
@@ -253,8 +270,17 @@
|
||||
payOrderId: state.orderInfo.payOrderId,
|
||||
});
|
||||
};
|
||||
const cancelOrder = () => {
|
||||
OrderApi.cancelOrder({
|
||||
const cancelUnpaidOpenOrder = () => {
|
||||
OrderApi.cancelUnpaidOpenOrder({
|
||||
id: orderId.value,
|
||||
}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
getOrderDetail();
|
||||
}
|
||||
});
|
||||
};
|
||||
const cancelOpenOrder = () => {
|
||||
OrderApi.cancelOpenOrder({
|
||||
id: orderId.value,
|
||||
}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
|
||||
+14
-1
@@ -31,7 +31,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view
|
||||
class="detail-goods"
|
||||
:style="[{ marginTop: state.orderInfo.receiverAreaId > 0 ? '0' : '-40rpx' }]"
|
||||
@@ -178,6 +178,12 @@
|
||||
text: '已取消',
|
||||
text1: '您的订单已取消!',
|
||||
},
|
||||
70: {
|
||||
text: '现金待确认',
|
||||
text1: '等待工作人员确认收款',
|
||||
btn1: '切换支付',
|
||||
btn2: '取消订单',
|
||||
},
|
||||
});
|
||||
|
||||
// ========== 门店自提(核销) ==========
|
||||
@@ -264,6 +270,13 @@
|
||||
// 取消订单
|
||||
cancelOrder();
|
||||
}
|
||||
if (Number(state.orderInfo.status) === 70 && type === 2) {
|
||||
cancelOrder();
|
||||
}
|
||||
if (Number(state.orderInfo.status) === 70 && type === 1) {
|
||||
// 现金待确认切回线上支付
|
||||
goPay();
|
||||
}
|
||||
if (state.orderInfo.status === 20 && type === 1) {
|
||||
// 确认收货confirmReceive
|
||||
OrderApi.confirmReceive({
|
||||
|
||||
+41
-13
@@ -72,7 +72,11 @@
|
||||
<view class="copy" @click.stop="onCopy">
|
||||
<image :src="`${$url}goods/copy2.svg`" mode="scaleToFill" />
|
||||
</view>
|
||||
<truckLine :data="state.orderInfo" :code="1" v-if="state.orderInfo.deliveryTime"></truckLine>
|
||||
<truckLine
|
||||
:data="state.orderInfo"
|
||||
:code="1"
|
||||
v-if="state.orderInfo.deliveryTime"
|
||||
></truckLine>
|
||||
</view>
|
||||
<view class="notice-item flex-row ju-between">
|
||||
<text class="title c0">下单时间</text>
|
||||
@@ -103,8 +107,14 @@
|
||||
@now="nowShipment"
|
||||
@confirm="confirmReceiveOrder"
|
||||
@pay="goPay"
|
||||
@cancel="cancelAiOrder"
|
||||
/>
|
||||
<card_orderBan v-else :data="state.orderInfo" @downData="getOrderDetail" type="2"></card_orderBan>
|
||||
<card_orderBan
|
||||
v-else
|
||||
:data="state.orderInfo"
|
||||
@downData="getOrderDetail"
|
||||
type="2"
|
||||
></card_orderBan>
|
||||
</view>
|
||||
</su-fixed>
|
||||
</s-pages>
|
||||
@@ -114,10 +124,7 @@
|
||||
import sheep from '@/sheep';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import {
|
||||
fen2yuan,
|
||||
handleOrderButtons,
|
||||
} from '@/sheep/hooks/useGoods';
|
||||
import { fen2yuan, handleOrderButtons } from '@/sheep/hooks/useGoods';
|
||||
import OrderApi from '@/sheep/api/trade/order';
|
||||
import {
|
||||
aiDelayedShipment,
|
||||
@@ -126,11 +133,13 @@
|
||||
giftConfirmReceive,
|
||||
getOrderDetail as getAiOrderDetail,
|
||||
getOpenOrderDetail,
|
||||
cancelOrder as cancelAiOrderRequest,
|
||||
cancelOpenOrder,
|
||||
} from '@/sheep/api/ai';
|
||||
import StoreApi from '@/sheep/api/trade/store';
|
||||
import card_order from '@/components/orderItem/card_order.vue';
|
||||
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
|
||||
import truckLine from '@/components/truckLine/truckLine.vue'
|
||||
import truckLine from '@/components/truckLine/truckLine.vue';
|
||||
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
|
||||
|
||||
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
|
||||
@@ -143,7 +152,6 @@
|
||||
source: '',
|
||||
});
|
||||
|
||||
|
||||
// ========== 门店自提(核销) ==========
|
||||
const systemStore = ref({}); // 门店信息
|
||||
|
||||
@@ -178,7 +186,7 @@
|
||||
const status = Number(state.orderInfo?.status);
|
||||
if ([0, 20].includes(status)) return true;
|
||||
if (isPickUpOrder.value) return false;
|
||||
return [10, 50].includes(status);
|
||||
return [10, 50, 70].includes(status);
|
||||
});
|
||||
|
||||
const resolvePickUpStoreId = (data = {}) => {
|
||||
@@ -256,9 +264,10 @@
|
||||
const confirmReceiveOrder = async () => {
|
||||
const id = resolveAiOrderId(state.orderInfo);
|
||||
if (!id) return;
|
||||
const req = Number(state.orderInfo?.type) === 5 || String(state.orderType) === '5'
|
||||
? giftConfirmReceive
|
||||
: aiConfirmReceive;
|
||||
const req =
|
||||
Number(state.orderInfo?.type) === 5 || String(state.orderType) === '5'
|
||||
? giftConfirmReceive
|
||||
: aiConfirmReceive;
|
||||
const { code } = await req({ id });
|
||||
if (code === 0) {
|
||||
getOrderDetail();
|
||||
@@ -281,6 +290,25 @@
|
||||
});
|
||||
};
|
||||
|
||||
const cancelAiOrder = () => {
|
||||
const id = resolveAiOrderId(state.orderInfo);
|
||||
if (!id) return;
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要取消订单吗?',
|
||||
confirmColor: '#FA7E31',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return;
|
||||
const request =
|
||||
Number(state.orderInfo?.type) === 5 || String(state.orderType) === '5'
|
||||
? cancelOpenOrder
|
||||
: cancelAiOrderRequest;
|
||||
const result = await request({ id });
|
||||
if (result.code === 0) await getOrderDetail();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
async function getOrderDetail() {
|
||||
let id = state.orderInfo.id;
|
||||
// 对详情数据进行适配
|
||||
@@ -350,7 +378,7 @@
|
||||
type: 1,
|
||||
},
|
||||
{
|
||||
title: "随机优惠",
|
||||
title: '随机优惠',
|
||||
value: 'randomDiscountPrice',
|
||||
type: 1,
|
||||
},
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
:data="v"
|
||||
@downData="downCallback(state.currentTab)"
|
||||
:index="state.currentTab"
|
||||
:isAfterSale="tabMaps[state.currentTab].id === 4"
|
||||
>
|
||||
</orderItem>
|
||||
</view>
|
||||
@@ -119,6 +120,11 @@
|
||||
name: '待支付',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
id: 70,
|
||||
name: '现金待确认',
|
||||
value: 70,
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
name: '待发货',
|
||||
|
||||
+22
-10
@@ -31,12 +31,7 @@
|
||||
src="/static/pay/cod_disabled.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<image
|
||||
class="pay-icon"
|
||||
v-else
|
||||
:src="item.icon"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<image class="pay-icon" v-else :src="item.icon" mode="aspectFit" />
|
||||
<text class="pay-title c0">{{ item.title }}</text>
|
||||
</view>
|
||||
<view class="check-box ss-flex ss-col-center ss-p-l-10">
|
||||
@@ -64,6 +59,9 @@
|
||||
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
|
||||
支付已过期
|
||||
</button>
|
||||
<button v-else-if="state.payStatus === 3" class="submit-btn" @tap="onPay">
|
||||
切换支付方式
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="submit-btn"
|
||||
@@ -94,7 +92,7 @@
|
||||
const state = reactive({
|
||||
orderType: 'goods', // 订单类型; goods - 商品订单, recharge - 充值订单
|
||||
orderInfo: {}, // 支付单信息
|
||||
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
|
||||
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付,3=现金待确认
|
||||
payMethods: [], // 可选的支付方式
|
||||
payment: '', // 选中的支付方式
|
||||
});
|
||||
@@ -139,7 +137,11 @@
|
||||
},
|
||||
});
|
||||
} else {
|
||||
console.log('支付方式:'+state.payment, '订单类型:'+state.orderType, '订单ID:'+state.orderInfo.id);
|
||||
console.log(
|
||||
'支付方式:' + state.payment,
|
||||
'订单类型:' + state.orderType,
|
||||
'订单ID:' + state.orderInfo.id,
|
||||
);
|
||||
sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id);
|
||||
}
|
||||
};
|
||||
@@ -149,6 +151,9 @@
|
||||
if (state.payStatus === 2) {
|
||||
return '该订单已支付';
|
||||
}
|
||||
if (state.payStatus === 3) {
|
||||
return '现金待确认';
|
||||
}
|
||||
// if (state.payStatus === 1 && state.orderInfo?.expireTime) {
|
||||
// const time = useDurationTime(state.orderInfo.expireTime);
|
||||
// if (time?.ms <= 0) {
|
||||
@@ -185,6 +190,10 @@
|
||||
state.payStatus = -1;
|
||||
return;
|
||||
}
|
||||
if (Number(state.orderInfo.status) === 40) {
|
||||
state.payStatus = 3;
|
||||
return;
|
||||
}
|
||||
state.payStatus = 1; // 待支付
|
||||
}
|
||||
|
||||
@@ -213,7 +222,7 @@
|
||||
|
||||
// 设置支付状态
|
||||
checkPayStatus();
|
||||
// 获得支付方式
|
||||
// 现金待确认不再展示支付渠道
|
||||
await setPayMethods();
|
||||
}
|
||||
|
||||
@@ -224,7 +233,10 @@
|
||||
return;
|
||||
}
|
||||
console.log(data);
|
||||
state.payMethods = getPayMethods(data);
|
||||
// 现金待确认状态下去除现金渠道,仅展示可切换的线上渠道
|
||||
state.payMethods = getPayMethods(data).filter(
|
||||
(item) => item.value !== 'cash' || state.payStatus !== 3,
|
||||
);
|
||||
console.log(state.payMethods);
|
||||
state.payMethods.find((item) => {
|
||||
console.log(item);
|
||||
|
||||
Reference in New Issue
Block a user