From 3f1239c35e03b7a5927c7856913d957194d91974 Mon Sep 17 00:00:00 2001 From: yuzhiran Date: Thu, 18 Jun 2026 20:54:42 +0800 Subject: [PATCH] fix: add network error detection and timeout for mini program JSAPI payment 1. member.vue: check for res.statusCode === 0 (network failure) before accessing data, add 30s timeout 2. manifest.json: bump to v1.0.14 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- zhiyin-app/src/manifest.json | 4 ++-- zhiyin-app/src/pages/member/member.vue | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/zhiyin-app/src/manifest.json b/zhiyin-app/src/manifest.json index 5eb6686..4b0d643 100644 --- a/zhiyin-app/src/manifest.json +++ b/zhiyin-app/src/manifest.json @@ -1,8 +1,8 @@ { "name": "宇之然AI磁场", "appid": "__UNI__DEV__", - "versionName": "1.0.13", - "versionCode": "113", + "versionName": "1.0.14", + "versionCode": "114", "description": "职引 - 宇之然AI磁场旗下AI模拟面试平台,提供AI面试官模拟练习、简历智能优化、大厂面经题库,助你轻松应对校招面试。", "h5": { "title": "职引 - AI模拟面试 | 宇之然AI磁场", diff --git a/zhiyin-app/src/pages/member/member.vue b/zhiyin-app/src/pages/member/member.vue index 566ba88..1b57dc9 100644 --- a/zhiyin-app/src/pages/member/member.vue +++ b/zhiyin-app/src/pages/member/member.vue @@ -183,6 +183,7 @@ const startPay = async (selectedPlan) => { url: api('/payment/jsapi'), method: 'POST', data: { plan: planLabel }, header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' }, + timeout: 30000, }) payLoading.value = false @@ -203,6 +204,11 @@ const startPay = async (selectedPlan) => { }, fail: (err) => { payError.value = '支付取消或失败'; uni.showToast({ title: '支付取消', icon: 'none' }) }, }) + } else if (!res.statusCode || res.statusCode === 0) { + payLoading.value = false + const errMsg = '网络连接失败,请检查网络后重试' + payError.value = errMsg + uni.showToast({ title: errMsg, icon: 'none' }) } else { payLoading.value = false const errMsg = res.data?.message || '创建订单失败' @@ -242,9 +248,14 @@ const startPay = async (selectedPlan) => { }) // 轮询支付结果 pollPayResult(res.data.outTradeNo, planLabel) + } else if (!res.statusCode || res.statusCode === 0) { + payLoading.value = false + const errMsg = '网络连接失败,请检查网络后重试' + payError.value = errMsg + uni.showToast({ title: errMsg, icon: 'none' }) } else { payError.value = res.data?.message || '支付服务暂不可用' - uni.showToast({ title: '支付服务暂不可用', icon: 'none' }) + uni.showToast({ title: res.data?.message || '支付服务暂不可用', icon: 'none' }) } } catch (e) { payLoading.value = false