chore: 优化微信支付错误提示文案并重构配置文件
- 微信支付取消时显示友好提示"您已取消支付"替代技术错误信息 - 支付失败时显示"支付失败,请稍后重试" - 重构 config.js 提取环境 URL 常量提升可读性 - 修复 ESLint 代码风格问题(使用 !== 替代 !=) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Showing
2 changed files
with
16 additions
and
10 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2026-01-24 12:40:28 | 4 | + * @LastEditTime: 2026-01-29 18:42:55 |
| 5 | * @FilePath: /xyxBooking-weapp/src/utils/config.js | 5 | * @FilePath: /xyxBooking-weapp/src/utils/config.js |
| 6 | * @Description: 服务器环境配置 | 6 | * @Description: 服务器环境配置 |
| 7 | */ | 7 | */ |
| ... | @@ -14,13 +14,9 @@ | ... | @@ -14,13 +14,9 @@ |
| 14 | * - 线上/测试环境按需切换 | 14 | * - 线上/测试环境按需切换 |
| 15 | * @type {string} | 15 | * @type {string} |
| 16 | */ | 16 | */ |
| 17 | -const BASE_URL = | 17 | +const dev_url = 'https://oa-dev.onwall.cn' |
| 18 | - process.env.NODE_ENV === 'production' | 18 | +const pro_url = 'https://oa.jcedu.org' |
| 19 | - ? // ? 'https://oa.onwall.cn' | 19 | +const BASE_URL = process.env.NODE_ENV === 'production' ? pro_url : dev_url |
| 20 | - 'https://oa-dev.onwall.cn' | ||
| 21 | - : // ?'https://oa.jcedu.org' | ||
| 22 | - 'https://oa-dev.onwall.cn' | ||
| 23 | -// : 'https://oa.jcedu.org' | ||
| 24 | 20 | ||
| 25 | /** | 21 | /** |
| 26 | * 接口默认公共参数(避免在多个文件里硬编码) | 22 | * 接口默认公共参数(避免在多个文件里硬编码) | ... | ... |
| ... | @@ -28,7 +28,7 @@ export const wechat_pay = async ({ pay_id }) => { | ... | @@ -28,7 +28,7 @@ export const wechat_pay = async ({ pay_id }) => { |
| 28 | Taro.hideLoading() | 28 | Taro.hideLoading() |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | - if (!pay_params_res || pay_params_res.code != 1) { | 31 | + if (!pay_params_res || pay_params_res.code !== 1) { |
| 32 | return { code: 0, data: null, msg: pay_params_res?.msg || '获取支付信息失败,请稍后再试' } | 32 | return { code: 0, data: null, msg: pay_params_res?.msg || '获取支付信息失败,请稍后再试' } |
| 33 | } | 33 | } |
| 34 | 34 | ||
| ... | @@ -50,5 +50,15 @@ export const wechat_pay = async ({ pay_id }) => { | ... | @@ -50,5 +50,15 @@ export const wechat_pay = async ({ pay_id }) => { |
| 50 | return { code: 1, data: pay_result.res || null, msg: '支付成功' } | 50 | return { code: 1, data: pay_result.res || null, msg: '支付成功' } |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | - return { code: 0, data: pay_result?.err || null, msg: pay_result?.err?.errMsg || '支付未完成' } | 53 | + // 优化错误提示文案 |
| 54 | + const errMsg = pay_result?.err?.errMsg || '' | ||
| 55 | + let friendlyMsg = '支付未完成' | ||
| 56 | + | ||
| 57 | + if (errMsg.includes('cancel')) { | ||
| 58 | + friendlyMsg = '您已取消支付' | ||
| 59 | + } else if (errMsg.includes('fail')) { | ||
| 60 | + friendlyMsg = '支付失败,请稍后重试' | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + return { code: 0, data: pay_result?.err || null, msg: friendlyMsg } | ||
| 54 | } | 64 | } | ... | ... |
-
Please register or login to post a comment