dev测试token问题

This commit is contained in:
bai.jinyan
2021-05-19 20:56:56 +08:00
parent ef6ebe0a4a
commit 945d9664cc

View File

@@ -136,7 +136,7 @@ const service = axios.create({
// request拦截器
service.interceptors.request.use(
config => {
async config => {
let relativePath = config.url && config.url.split(configApp.API_VERSION)[1]
if (whiteList.includes(relativePath)) {
Toast.loading({
@@ -161,18 +161,18 @@ service.interceptors.request.use(
// token 不存在初始化处理
let token = CacheUtils.getLocItem('token')
console.log('前端缓存token====>>', token)
if (!token) {
console.log('token====>>', token)
// 设备类型
const target = BusinessCommon.device()
// 安卓or苹果(非浏览器)
if (target.isAndroid || target.isIphone) {
if (!target.isWeixin && !target.isChrome) {
// eslint-disable-next-line no-undef
const res = EWebBridge.webCallAppInJs('getToken')
const res = await EWebBridge.webCallAppInJs('getToken')
CacheUtils.setLocItem('token', JSON.parse(res).token)
}
}
console.log('最终token====>>', CacheUtils.getLocItem('token'))
config.headers['token'] = CacheUtils.getLocItem('token')
// 添加请时间戳
let timeStr = new Date().getTime() + ''