This commit is contained in:
xyc 2025-04-16 17:25:48 +08:00
parent e74fc686b0
commit ca98b5c60e

View File

@ -155,7 +155,12 @@ import headers from '../../components/header/headers.vue'
import request from '@/utils/request.js'
import tabbar from '../../components/tabbar/tabbar.vue'
import upload from '@/utils/upload.js'
import {getCoachId, getLocalUserInfo,getStaffType,getToken} from '../../utils/auth'
import {
getCoachId,
getLocalUserInfo,
getStaffType,
getToken
} from '../../utils/auth'
export default {
data() {
@ -277,9 +282,9 @@ export default {
methods: {
// or
updateDisplayPrice() {
this.currentPrice = this.selectedPayType === 1
? this.rightInfoList.reserveMoney
: this.rightInfoList.price;
this.currentPrice = this.selectedPayType === 1 ?
this.rightInfoList.reserveMoney :
this.rightInfoList.price;
},
//
@ -409,19 +414,31 @@ export default {
//
async validateForm() {
if (!this.sfzimg) {
uni.showToast({title: '请上传身份证照片', icon: 'error'});
uni.showToast({
title: '请上传身份证照片',
icon: 'error'
});
return false;
}
if (!this.phone || !this.name || !this.identity) {
uni.showToast({title: '请输入完整信息', icon: 'error'});
uni.showToast({
title: '请输入完整信息',
icon: 'error'
});
return false;
}
if (!this.isValidPhoneNumber(this.phone)) {
uni.showToast({title: '手机号不规范', icon: 'error'});
uni.showToast({
title: '手机号不规范',
icon: 'error'
});
return false;
}
if (!this.isValidIDNumber(this.identity)) {
uni.showToast({title: '身份证不规范', icon: 'error'});
uni.showToast({
title: '身份证不规范',
icon: 'error'
});
return false;
}
return true;
@ -435,7 +452,9 @@ export default {
try {
// 1.
if (!this.checkLogin()) {
uni.navigateTo({url: '/pages/login/login'});
uni.navigateTo({
url: '/pages/login/login'
});
return;
}
if (!await this.validateForm()) return;
@ -457,7 +476,10 @@ export default {
await this.createNewOrder();
} catch (error) {
if (!error.message.includes('cancel')) {
uni.showToast({title: error.message || '操作失败', icon: 'none'});
uni.showToast({
title: error.message || '操作失败',
icon: 'none'
});
}
} finally {
this.loading = false;
@ -604,17 +626,20 @@ export default {
}, */
async processExistingOrder() {
uni.showLoading({title: '准备支付...', mask: true});
uni.showLoading({
title: '准备支付...',
mask: true
});
try {
// 1.
const payType = this.selectedPayType;
const reserveMoney = payType === 1
? this.rightInfoList.reserveMoney
: this.rightInfoList.price;
const restMoney = payType === 1
? this.rightInfoList.price - reserveMoney
: 0;
const reserveMoney = payType === 1 ?
this.rightInfoList.reserveMoney :
this.rightInfoList.price;
const restMoney = payType === 1 ?
this.rightInfoList.price - reserveMoney :
0;
// 2.
const orderDetail = await this.getOrderDetail(this.orderId);
@ -746,7 +771,8 @@ export default {
resolve(res.errMsg === 'requestPayment:ok' ? 'success' : 'fail');
},
fail: (err) => {
resolve(err.errMsg === 'requestPayment:fail cancel' ? 'cancelled' : 'fail');
resolve(err.errMsg === 'requestPayment:fail cancel' ? 'cancelled' :
'fail');
}
});
});
@ -754,13 +780,16 @@ export default {
//
async createNewOrder() {
uni.showLoading({title: '创建订单中...', mask: true});
uni.showLoading({
title: '创建订单中...',
mask: true
});
try {
if (this.startPay === 1) {
const payType = this.selectedPayType;
const reserveMoney = payType === 1
? this.rightInfoList.reserveMoney
: this.rightInfoList.price;
const reserveMoney = payType === 1 ?
this.rightInfoList.reserveMoney :
this.rightInfoList.price;
this.payPrice = reserveMoney
await this.wxPayClick(
this.name,
@ -934,7 +963,10 @@ export default {
checkLogin() {
const token = uni.getStorageSync('App-Token');
if (!token) {
uni.showToast({title: '请先登录', icon: 'none'});
uni.showToast({
title: '请先登录',
icon: 'none'
});
return false;
}
return true;