Browse Source

修改没网络请求提示

lijuncheng0816
lijuncheng 3 months ago
parent
commit
edd078a40f
  1. 24
      src/api/httpRequest3.js
  2. 2
      src/pages/login/index.vue

24
src/api/httpRequest3.js

@ -1,10 +1,10 @@
import storage from '../common/utils/storage' import storage from '../common/utils/storage'
import { import {
removeToken removeToken
} from '@/common/utils/auth' } from '@/common/utils/auth'
function service(options = {}) { function service(options = {}) {
var token = storage.getStorage(storage.constant.token) var token = storage.getStorage(storage.constant.token)
var tenantId = storage.getStorage('tenantId') var tenantId = storage.getStorage('tenantId')
// if(getApp()!=undefined){ // if(getApp()!=undefined){
@ -69,7 +69,29 @@ function service(options = {}) {
reject("系统异常:" + message); reject("系统异常:" + message);
console.log("系统异常", message) console.log("系统异常", message)
}; };
// #ifdef APP
uni.getNetworkType({
success: function(res) {
const networkType = res.networkType;
console.log("网络类型", networkType)
if (networkType == "none") {
reject("当前无网络");
} else {
uni.request(options); uni.request(options);
}
}
})
// #endif
// #ifdef H5
console.log("网s络H5", navigator.onLine)
if(navigator.onLine){
uni.request(options);
}else {
reject("当前无网络");
}
// #endif
}); });
} }

2
src/pages/login/index.vue

@ -261,6 +261,8 @@
this.imageSrc = base64.replace(/[\r\n]/g, "") this.imageSrc = base64.replace(/[\r\n]/g, "")
this.uuid = res.data.uuid this.uuid = res.data.uuid
} }
}).catch(error => {
this.showErrorMessage(error);
}) })
}, },
getAppVersion() { getAppVersion() {

Loading…
Cancel
Save