Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
xyxBooking-weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2026-01-12 18:55:25 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6ba50be00194fa5d12d448f8e15586792aa37297
6ba50be0
1 parent
9c4a2e97
fix(submit): 修复支付流程逻辑并优化错误处理
重构支付流程以支持订单重试,避免重复创建订单 添加支付失败时的错误提示和状态管理 优化加载状态显示和代码结构
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
src/pages/submit/index.vue
src/pages/submit/index.vue
View file @
6ba50be
<!--
* @Date: 2024-01-15 16:25:51
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2026-01-12 18:
42:42
* @LastEditTime: 2026-01-12 18:
54:33
* @FilePath: /xyxBooking-weapp/src/pages/submit/index.vue
* @Description: 预约人员信息
-->
...
...
@@ -116,10 +116,15 @@ const goToVisitor = () => {
const submitBtn = async () => {
if (!checked_visitors.value.length) {
Taro.showToast({ title: '请先添加参观者', icon: 'none' })
} else {
return;
}
let pay_id = pending_pay_id.value;
if (!pay_id) {
// TAG: 提交订单跳转到支付页面
Taro.showLoading({ title: '提交中...' });
const { code, data } = await addReserveAPI({
const { code, data
, msg
} = await addReserveAPI({
reserve_date: date.value,
begin_time: time.value.split('-')[0],
end_time: time.value.split('-')[1],
...
...
@@ -128,10 +133,19 @@ const submitBtn = async () => {
Taro.hideLoading();
if (code) {
if (!code || code !== 1) {
Taro.showToast({ title: msg || '提交失败', icon: 'none' });
return;
}
pay_id = data.pay_id;
pending_pay_id.value = pay_id;
}
// 如果金额大于零, 走微信支付, 如果等于零直接跳转成功页
if (total.value > 0) {
const payParams = await wxPayAPI({ pay_id: data.pay_id }); // 参数接口
Taro.showLoading({ title: '支付准备中...' });
const payParams = await wxPayAPI({ pay_id: pay_id }); // 参数接口
Taro.hideLoading();
if (payParams.code) {
let pay = payParams.data;
...
...
@@ -142,16 +156,21 @@ const submitBtn = async () => {
signType: pay.signType,
paySign: pay.paySign,
success (res) {
go('/success', { pay_id: data.
pay_id });
go('/success', { pay_id:
pay_id });
},
fail (res) { }
fail (res) {
// 支付取消或失败,保留 pending_pay_id,允许用户再次点击按钮尝试支付同一订单
// 只有当 wxPayAPI 获取支付参数失败时(如下面的 else 分支),才重置 ID 以便重新创建订单
Taro.showToast({ title: '支付失败,请重试', icon: 'none' });
}
})
} else {
pending_pay_id.value = null; // 支付参数获取失败,重置订单ID
Taro.showToast({ title: payParams.msg || '获取支付信息失败', icon: 'none' });
}
} else {
// 金额等于零, 直接跳转成功页
go('/success', { pay_id: data.pay_id });
}
}
go('/success', { pay_id: pay_id });
}
}
...
...
Please
register
or
login
to post a comment