Browse Source

修改网络异常

lijuncheng0816
lijuncheng 4 months ago
parent
commit
069cad56cc
  1. 4
      src/api/httpRequest3.js
  2. 23
      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) + '异常'
} else if (message.includes('get lock')) {
message = '接口' + "数据库死锁"
}else if(message.includes('statusCode:-1')){
message = "当前设备无网络,请检查网络后重试"
}
reject("系统异常:" + message);
console.log("系统异常", message)
@ -99,7 +101,7 @@ function service(options = {}) {
const networkType = res.networkType;
console.log("网络类型", networkType)
if (networkType == "none") {
reject("当前无网络");
reject("当前设备无网络,请检查网络后重试");
} else {
uni.request(options);
}

23
src/pages/login/index.vue

@ -226,14 +226,21 @@
title: "正在登录",
mask: true
})
await this.$store.dispatch('Login', logininfo);
// await this.$store.dispatch('GetTenantIdInfo', this.tenantName)
uni.hideLoading()
uni.setStorageSync('hasLogin', true)
uni.switchTab({
url: '/pages/index/index'
});
uni.setStorageSync('username', this.username);
try{
var result = await this.$store.dispatch('Login', logininfo);
// await this.$store.dispatch('GetTenantIdInfo', this.tenantName)
console.log(result)
uni.hideLoading()
uni.setStorageSync('hasLogin', true)
uni.switchTab({
url: '/pages/index/index'
});
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)
resolve(res)
}else {
uni.showToast({
title:res.msg
})
if(res.msg){
reject(res.msg)
}else {
reject("登录失败")
}
}
}).catch(error => {
reject(error)
uni.showToast({
title:error
})
})
})
},

Loading…
Cancel
Save