261024
This commit is contained in:
@@ -80,6 +80,18 @@
|
||||
</template>
|
||||
</uv-cell>
|
||||
</block>
|
||||
<uv-cell
|
||||
:title="balancePayTitle"
|
||||
icon="https://oss.wsdns.cn/20240511/fae57a94fa0042b9bceb721421304db1.png?x-oss-process=image/resize,m_fixed,w_100,h_100/quality,Q_90"
|
||||
:cellStyle="{ padding: '20rpx 10rpx', borderRadius: '8rpx', backgroundColor: 19 === form.payType ? '#f6fff1' : '', opacity: canUseBalancePay ? 1 : 0.45 }"
|
||||
:border="false"
|
||||
@click="onPayType(19)"
|
||||
>
|
||||
<template v-slot:right-icon>
|
||||
<text v-if="!canUseBalancePay" class="balance-tip">余额不足</text>
|
||||
<uv-icon v-else-if="19 === form.payType" size="30rpx" name="checkbox-mark"></uv-icon>
|
||||
</template>
|
||||
</uv-cell>
|
||||
</uv-cell-group>
|
||||
<view slot="actions" class="card-actions">
|
||||
<view class="card-actions-item">
|
||||
@@ -182,10 +194,11 @@ import {checkPayPassword} from '@/api/passport/login';
|
||||
import {getWeek, getKey} from '@/utils/common';
|
||||
import {useUserStore} from '@/store/modules/user';
|
||||
import dayjs from "dayjs";
|
||||
import {addThinkOrder} from "@/api/think/thinkOrder";
|
||||
import {addThinkOrder, updateThinkOrder} from "@/api/think/thinkOrder";
|
||||
import {listUserThinkCard} from "@/api/think/thinkCard";
|
||||
import {listThinkUsersVip} from "@/api/think/thinkUsersVip";
|
||||
import {number} from "@/uni_modules/uv-ui-tools/libs/function/test";
|
||||
import md5 from 'md5'
|
||||
|
||||
const userStore = useUserStore();
|
||||
// const carStore = useCarStore();
|
||||
@@ -195,6 +208,15 @@ export default {
|
||||
computed: {
|
||||
dayjs() {
|
||||
return dayjs
|
||||
},
|
||||
currentBalance() {
|
||||
return Number(this.userInfo?.balance || this.userInfo?.money || 0);
|
||||
},
|
||||
canUseBalancePay() {
|
||||
return this.currentBalance >= Number(this.payPrice || 0);
|
||||
},
|
||||
balancePayTitle() {
|
||||
return `余额支付(当前余额¥${this.currentBalance.toFixed(2)})`;
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -558,6 +580,13 @@ export default {
|
||||
},
|
||||
// 切换支付方式
|
||||
async onPayType(index) {
|
||||
if (index === 19 && !this.canUseBalancePay) {
|
||||
uni.showToast({
|
||||
title: '当前余额不足',
|
||||
icon: 'none'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
// app.payType = index;
|
||||
this.form.payType = index;
|
||||
console.log(this.form.payType)
|
||||
@@ -643,10 +672,6 @@ export default {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (form.payType === 0 && !this.isPayPasswordCorrect) {
|
||||
app.$refs.payPasswordForm.open('center');
|
||||
return false;
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '订单提交中.'
|
||||
});
|
||||
@@ -663,13 +688,15 @@ export default {
|
||||
}
|
||||
return item
|
||||
})
|
||||
const postTime = dayjs().valueOf()
|
||||
form.postTime = postTime
|
||||
form.sign = md5(postTime + "wxd38cc38c54fa7370" + form.startTime + this.userInfo.uid)
|
||||
addThinkOrder(form)
|
||||
.then((data) => {
|
||||
const orderInfo = data;
|
||||
console.log(data)
|
||||
// 调起微信支付
|
||||
if (form.payType === 1) {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.requestPayment({
|
||||
provider: orderInfo.provider, // 服务提供商
|
||||
timeStamp: orderInfo.timeStamp, // 时间戳
|
||||
@@ -683,34 +710,30 @@ export default {
|
||||
title: '支付成功',
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(function () {
|
||||
setTimeout(() => {
|
||||
app.disabled = false;
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/order/order',
|
||||
// success: function (e) {
|
||||
// var page = getCurrentPages()[0];
|
||||
// if (page == undefined || page == null) return;
|
||||
// page.onLoad();
|
||||
// }
|
||||
// });
|
||||
uni.switchTab({url: '/pages/order'})
|
||||
}, 1500);
|
||||
},
|
||||
fail: function (err) {
|
||||
fail: async (err) => {
|
||||
uni.showToast({
|
||||
title: '取消支付',
|
||||
icon: 'error'
|
||||
});
|
||||
await updateThinkOrder({
|
||||
id: orderInfo.orderId,
|
||||
orderStatus: 3
|
||||
})
|
||||
console.log('支付失败', err);
|
||||
app.disabled = false;
|
||||
uni.switchTab({
|
||||
url: '/pages/order'
|
||||
});
|
||||
// uni.switchTab({
|
||||
// url: '/pages/order/order'
|
||||
// })
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
}
|
||||
// 使用余额支付
|
||||
if (form.payType === 0) {
|
||||
if (form.payType === 19) {
|
||||
if (!orderInfo) {
|
||||
return uni.showToast({
|
||||
title: '支付失败',
|
||||
@@ -724,7 +747,6 @@ export default {
|
||||
});
|
||||
setTimeout(function () {
|
||||
app.disabled = false;
|
||||
app.$refs.payPasswordForm.close();
|
||||
uni.switchTab({url: '/pages/order'})
|
||||
}, 1500);
|
||||
}
|
||||
@@ -757,6 +779,11 @@ export default {
|
||||
title: res.message || '请检查您的网络.',
|
||||
icon: 'none'
|
||||
});
|
||||
if (res.message === '未绑定人脸') {
|
||||
setTimeout(() => {
|
||||
uni.switchTab({url: '/pages/user'})
|
||||
}, 1500)
|
||||
}
|
||||
});
|
||||
},
|
||||
selectVipCard(card) {
|
||||
@@ -807,6 +834,11 @@ page {
|
||||
.container {
|
||||
}
|
||||
|
||||
.balance-tip {
|
||||
font-size: 24rpx;
|
||||
color: #fa3534;
|
||||
}
|
||||
|
||||
.checkout-car {
|
||||
width: 700rpx;
|
||||
left: 25rpx;
|
||||
|
||||
Reference in New Issue
Block a user