Browse Source

修改网络异常

lijuncheng0816
lijuncheng 1 month ago
parent
commit
069cad56cc
  1. 4
      src/api/httpRequest3.js
  2. 9
      src/pages/login/index.vue
  3. 12
      src/store/modules/user.js

4
src/api/httpRequest3.js

@ -89,6 +89,8 @@ function service(options = {}) {
message = '接口' + message.substr(message.length - 3) + '异常' message = '接口' + message.substr(message.length - 3) + '异常'
} else if (message.includes('get lock')) { } else if (message.includes('get lock')) {
message = '接口' + "数据库死锁" message = '接口' + "数据库死锁"
}else if(message.includes('statusCode:-1')){
message = "当前设备无网络,请检查网络后重试"
} }
reject("系统异常:" + message); reject("系统异常:" + message);
console.log("系统异常", message) console.log("系统异常", message)
@ -99,7 +101,7 @@ function service(options = {}) {
const networkType = res.networkType; const networkType = res.networkType;
console.log("网络类型", networkType) console.log("网络类型", networkType)
if (networkType == "none") { if (networkType == "none") {
reject("当前无网络"); reject("当前设备无网络,请检查网络后重试");
} else { } else {
uni.request(options); uni.request(options);
} }

9
src/pages/login/index.vue

@ -226,14 +226,21 @@
title: "正在登录", title: "正在登录",
mask: true mask: true
}) })
await this.$store.dispatch('Login', logininfo); try{
var result = await this.$store.dispatch('Login', logininfo);
// await this.$store.dispatch('GetTenantIdInfo', this.tenantName) // await this.$store.dispatch('GetTenantIdInfo', this.tenantName)
console.log(result)
uni.hideLoading() uni.hideLoading()
uni.setStorageSync('hasLogin', true) uni.setStorageSync('hasLogin', true)
uni.switchTab({ uni.switchTab({
url: '/pages/index/index' url: '/pages/index/index'
}); });
uni.setStorageSync('username', this.username); uni.setStorageSync('username', this.username);
}catch(e){
uni.hideLoading()
this.showErrorMessage(e)
}
}, },

12
src/store/modules/user.js

@ -59,16 +59,14 @@ const user = {
storage.setStorage(storage.constant.token,res.accessToken) storage.setStorage(storage.constant.token,res.accessToken)
resolve(res) resolve(res)
}else { }else {
uni.showToast({ if(res.msg){
title:res.msg reject(res.msg)
}) }else {
reject("登录失败")
}
} }
}).catch(error => { }).catch(error => {
reject(error) reject(error)
uni.showToast({
title:error
})
}) })
}) })
}, },

Loading…
Cancel
Save