fix:getNoIsbnBook非200/网络错误显示错误信息并停止后续

This commit is contained in:
97694732@qq.com 2026-06-06 16:04:36 +08:00
parent a4e71f53b8
commit eae0d67996

View File

@ -2420,12 +2420,25 @@ export default {
}) })
return return
} }
// code=200
if (typeof callback === 'function') callback.call(that, false)
} else {
// 200code200
var errMsg = ''
if (res.data) {
errMsg = res.data.msg || res.data.message || ('请求失败: ' + res.statusCode)
} else {
errMsg = '请求失败: HTTP ' + res.statusCode
}
console.error('【getNoIsbnBook】错误:', errMsg)
uni.showToast({ title: errMsg, icon: 'none', duration: 3000 })
if (typeof callback === 'function') callback.call(that, true)
} }
//
if (typeof callback === 'function') callback.call(that, false)
}, },
fail: function() { fail: function(err) {
if (typeof callback === 'function') callback.call(that, false) console.error('【getNoIsbnBook】网络请求失败:', JSON.stringify(err))
uni.showToast({ title: '网络请求失败', icon: 'none', duration: 3000 })
if (typeof callback === 'function') callback.call(that, true)
} }
}) })
}, },