fix: 设备扫码检测到订单为in_used状态,跳转不成功的问题

This commit is contained in:
8vd8
2025-04-10 14:46:29 +08:00
parent 3491d93e27
commit 2da6ef8f41
12 changed files with 269 additions and 55 deletions
+21 -5
View File
@@ -5,6 +5,9 @@ import {
const request = (option) => {
return new Promise((resolve, reject) => {
// Debug request info
console.log(`发起请求: ${option.method} ${URL + option.url}`, option.data)
uni.request({
url: URL + option.url,
method: option.method,
@@ -17,17 +20,29 @@ const request = (option) => {
'Clientid': uni.getStorageSync('client_id')
},
success(res) {
// 检查响应状态码和业务状态码
// 记录响应
console.log(`请求响应: ${option.url}`, res)
// 检查响应状态码
if (res.statusCode !== 200) {
// HTTP状态码不是200,表示请求失败
console.error(`HTTP状态码错误: ${res.statusCode}`, res.data)
// 为了适应某些服务器的异常响应,我们仍然返回数据
if (res.data) {
resolve(res.data)
return
}
reject({msg: `请求失败,状态码:${res.statusCode}`})
return
}
// 检查业务状态码
if (res.data.code !== 200) {
// 业务状态码不是200,表示业务处理失败
reject(res.data)
if (res.data && res.data.code !== 200) {
console.warn(`业务状态码错误: ${res.data.code}`, res.data)
// 仍然返回数据,由业务逻辑处理
resolve(res.data)
return
}
@@ -35,6 +50,7 @@ const request = (option) => {
},
fail(err) {
// 网络请求本身失败
console.error(`请求失败: ${option.url}`, err)
reject(err)
}
})