Browse Source

修改网络异常

lijuncheng0816
lijuncheng 3 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) + '异常' 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);
} }

23
src/pages/login/index.vue

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