uni.request({
url: url,
method,
header: this.getHeader(url),
data: postData,
sslVerify: false,
success: async (res) => {
if (res.data.status == -1) {
let userInfo = {
uid: 0,
login: false,
token: ''
}
fun.saveData("userInfo", userInfo);
store.dispatch("setUserInfo", userInfo)
fun.tips("登录失效,重新登录")
setTimeout(() => {
fun.gotologin()
}, 1500)
}
callBack(res.data);
},
fail(res) {
console.log('web fail:' + JSON.stringify(res));
if (fail_callBack != undefined) {
fail_callBack(res);
} else if (res.errMsg.indexOf("request:fail timeout") != -1) {
uni.hideLoading();
uni.showModal({
title: '提示',
showCancel: false,
content: '请求超时,请重载'
})
}
}
});

- 发布:2022-09-03 11:28
- 更新:2022-09-03 11:28
- 阅读:311
产品分类: uniapp/H5
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: window10
HBuilderX类型: 正式
HBuilderX版本号: 3.5.3
浏览器平台: 微信内置浏览器
项目创建方式: HBuilderX
App下载地址或H5⽹址: https://h5.jieyang.la/#/?auth_id=ff0e58607ba227da5d92
示例代码:
操作步骤:
uni.request({
url: url,
method,
header: this.getHeader(url),
data: postData,
sslVerify: false,
success: async (res) => {
if (res.data.status == -1) {
let userInfo = {
uid: 0,
login: false,
token: ''
}
fun.saveData("userInfo", userInfo);
store.dispatch("setUserInfo", userInfo)
fun.tips("登录失效,重新登录")
setTimeout(() => {
fun.gotologin()
}, 1500)
}
callBack(res.data);
},
fail(res) {
console.log('web fail:' + JSON.stringify(res));
if (fail_callBack != undefined) {
fail_callBack(res);
} else if (res.errMsg.indexOf("request:fail timeout") != -1) {
uni.hideLoading();
uni.showModal({
title: '提示',
showCancel: false,
content: '请求超时,请重载'
})
}
}
});
uni.request({
url: url,
method,
header: this.getHeader(url),
data: postData,
sslVerify: false,
success: async (res) => {
if (res.data.status == -1) {
let userInfo = {
uid: 0,
login: false,
token: ''
}
fun.saveData("userInfo", userInfo);
store.dispatch("setUserInfo", userInfo)
fun.tips("登录失效,重新登录")
setTimeout(() => {
fun.gotologin()
}, 1500)
}
callBack(res.data);
},
fail(res) {
console.log('web fail:' + JSON.stringify(res));
if (fail_callBack != undefined) {
fail_callBack(res);
} else if (res.errMsg.indexOf("request:fail timeout") != -1) {
uni.hideLoading();
uni.showModal({
title: '提示',
showCancel: false,
content: '请求超时,请重载'
})
}
}
});
预期结果:
走success函数
走success函数
实际结果:
走fail函数
走fail函数
bug描述:
H5 ios12.0 uni.request请求失败,errMsg:request:fail 其实的安卓和ios12以上的都正常 ios12版本的就不行
