【登录token失效问题】修改下Android端获取token的实现

This commit is contained in:
liyuetong
2021-11-04 17:48:48 +08:00
parent 564775b1a9
commit a95ade983f

View File

@@ -169,8 +169,14 @@ service.interceptors.request.use(
// 安卓or苹果(非浏览器) // 安卓or苹果(非浏览器)
if (!target.isWeixin && !target.isChrome) { if (!target.isWeixin && !target.isChrome) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const res = await EWebBridge.webCallAppInJs('getToken') let u = navigator.userAgent;
CacheUtils.setLocItem('token', JSON.parse(res).token) let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //判断是否是 android终端
if(isAndroid){
CacheUtils.setLocItem('token', JSON.parse(window.Android.getToken()))
}else{
const res = await EWebBridge.webCallAppInJs('getToken')
CacheUtils.setLocItem('token', JSON.parse(res).token)
}
} }
} }