From 277d6652893fcc10fb6827b62ef16fe2910a525c Mon Sep 17 00:00:00 2001 From: zhouwenxuan <1175765986@qq.com> Date: 星期五, 15 十二月 2023 16:58:25 +0800 Subject: [PATCH] 强制更新功能 --- common/request.js | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 42 insertions(+), 8 deletions(-) diff --git a/common/request.js b/common/request.js index c243a1d..61413b2 100644 --- a/common/request.js +++ b/common/request.js @@ -21,26 +21,60 @@ return new Promise((resolved, rejected) => { //成功 options.success = (res) => { - if (Number(res.data.code) == 100) { - resolved(res.data); - } else { + console.log("ressssss",res) + // if (Number(res.data.code) == 100) { + if(Number(res.data.code) == 405){ uni.showToast({ icon: 'none', - duration: 3000, + duration: 2000, position: 'top', title: `${res.data.msg}` }); - rejected(res.data.msg); - uni.navigateTo({ - url: '/pages/index/index' - }) + rejected(res.data.msg); + setTimeout(()=>{ + uni.clearStorageSync(); + uni.clearStorage(); + uni.navigateTo({ + url: '/pages/index/index' + }) + },2000) + }else if(Number(res.data.code) == 100){ + + if(res.data.msg == '您点击太快了,请稍后尝试'){ + uni.showToast({ + icon: 'none', + duration: 2000, + position: 'top', + title: `${res.data.msg}` + }); + } } + resolved(res.data); + // } else { + // uni.showToast({ + // icon: 'none', + // duration: 3000, + // position: 'top', + // title: `${res.data.msg}` + // }); + // rejected(res.data.msg); + // setTimeout(()=>{ + // uni.navigateTo({ + // url: '/pages/index/index' + // }) + // },2000) + // } } options.fail = (err) => { uni.showToast({ icon: "none", title: '服务响应失败' }); + uni.clearStorageSync(); + uni.clearStorage(); + uni.navigateTo({ + url: '/pages/index/index' + }) rejected(err); } uni.request(options); -- Gitblit v1.9.2