diff --git a/App.vue b/App.vue
index 7609ea9..e58073c 100644
--- a/App.vue
+++ b/App.vue
@@ -102,38 +102,31 @@
}, 100)
}
},
- // 启动轮询支付状态
+ // 启动轮询支付状态:回到小程序立马查一次,失败则每隔 3 秒再查,最多再查 3 次(共 4 次)
startOrderStatusPolling(orderNumber) {
- // 避免重复轮询
if (this._orderStatusTimer) {
clearInterval(this._orderStatusTimer);
this._orderStatusTimer = null;
}
let times = 0;
- const maxTimes = 5; // 最多轮询 20 次,大约 1 分钟
+ const maxTimes = 4; // 立即 1 次 + 最多再查 3 次
- this._orderStatusTimer = setInterval(async () => {
+ const doCheck = async () => {
times++;
try {
const res = await updateLuOrderPayStatus({ orderNumber });
- // 约定:接口有返回数据即认为支付成功
if (res) {
clearInterval(this._orderStatusTimer);
this._orderStatusTimer = null;
- // 成功后清理本地缓存的订单号
uni.removeStorageSync("lastOrderNumber");
-
- uni.showToast({
- title: '支付成功',
- icon: 'success'
- });
-
- // 跳转到服务记录页面,默认展示「待核销」tab
+ uni.showToast({ title: '支付成功', icon: 'success' });
uni.navigateTo({
url: '/pages/profileSub/serviceRecords?tab=pending_verification'
});
- } else if (times >= maxTimes) {
+ return;
+ }
+ if (times >= maxTimes) {
clearInterval(this._orderStatusTimer);
this._orderStatusTimer = null;
uni.showToast({
@@ -149,7 +142,10 @@
this._orderStatusTimer = null;
}
}
- }, 3000);
+ };
+
+ doCheck(); // 回到小程序立马查一次
+ this._orderStatusTimer = setInterval(doCheck, 3000); // 失败则每 3 秒再查,最多再查 3 次
}
}
}
diff --git a/api/index.js b/api/index.js
index 72dee5f..6dbefdf 100644
--- a/api/index.js
+++ b/api/index.js
@@ -4,8 +4,8 @@
*/
// 基础URL配置(注意:末尾不要加斜杠)
-// const BASE_URL = 'https://guangsh.manage.hschengtai.com'
-const BASE_URL = 'http://192.168.5.134:48085'
+const BASE_URL = 'https://guangsh.manage.hschengtai.com'
+// const BASE_URL = 'http://192.168.5.134:48085'
// 是否正在刷新token(防止并发刷新)
let isRefreshing = false
// 等待刷新完成的请求队列
@@ -366,12 +366,15 @@ export function request(options = {}) {
uni.hideLoading()
}
- // 网络错误处理
+ // 网络错误处理(真机/预览时域名未配置会报 domain 相关错误)
let errorMsg = '网络请求失败'
if (err.errMsg) {
- if (err.errMsg.includes('timeout')) {
+ const em = err.errMsg
+ if (em.includes('timeout')) {
errorMsg = '请求超时,请检查网络'
- } else if (err.errMsg.includes('fail')) {
+ } else if (em.includes('domain') || em.includes('url not in')) {
+ errorMsg = '请在小程序后台配置服务器域名'
+ } else if (em.includes('fail')) {
errorMsg = '网络连接失败,请检查网络设置'
}
}
diff --git a/api/service.js b/api/service.js
index 5175dae..eafd498 100644
--- a/api/service.js
+++ b/api/service.js
@@ -161,11 +161,16 @@ export function getMyOrderPage(params = {}){
})
}
-// 删除订单
-export function deleteOrder(id){
+// 删除订单(id 为 Query 参数,拼在 URL 上)
+export function deleteOrder(params = {}) {
+ const id = params.id
+ const url = id !== undefined && id !== ''
+ ? `/app-api/member/lu-order/delete?id=${encodeURIComponent(id)}`
+ : '/app-api/member/lu-order/delete'
return request({
- url: '/app-api/member/lu-order/delete?id='+id,
+ url,
method: 'DELETE',
+ data: {},
})
}
diff --git a/pages/detail/serviceDetail.vue b/pages/detail/serviceDetail.vue
index d8fac4a..5da61c3 100644
--- a/pages/detail/serviceDetail.vue
+++ b/pages/detail/serviceDetail.vue
@@ -61,7 +61,7 @@
{{ item.discount }}折
-
+