用户登录&退出

This commit is contained in:
骆超
2023-05-06 17:03:05 +08:00
parent fea1c29b96
commit 767f164e59
5 changed files with 98 additions and 76 deletions

View File

@@ -5,17 +5,17 @@ import utils from '@/utils/encode'
// const env = 'test'// 仅用于测试、
// const env = 'production'
//42 洛超 /29 孙志华 /40 阿浩
// 测试日日顺时需要连阿浩
// 测试日日顺时需要连阿浩
const testUrl = 'http://192.168.26:38080'
// const productionUrl = 'https://www.51xingka.net/oilApp' // 生产,加密 old
// const productionUrl = 'https://www.xingoil.com/adminapi' // 生产,加密 new
// const productionUrl = 'https://www.xingoil.com/adminapi' // 生产,加密 new
// const productionUrl = 'https://www.xingoil.com/adminapi' // 生产,加密 new
// const productionUrl = 'https://www.xingoil.com/adminapi' // 生产,加密 new
const productionUrl = 'http://uat.xingoil.com/adminapi'
// const env = process.env.NODE_ENV // 环境
const service = axios.create({
baseURL: env=='production'?productionUrl:testUrl, //
// baseURL: testUrl, //
baseURL: env=='production'?productionUrl:testUrl, //
// baseURL: testUrl, //
timeout: 5000
})
@@ -33,13 +33,13 @@ service.interceptors.request.use(
title: '加载中...',
mask:true
})
// }
// }
const token = uni.getStorageSync('Authorization')
const openid = uni.getStorageSync('device')
const openId = uni.getStorageSync('openid')
const unionId = uni.getStorageSync('unionid')
const accountSources = 'LOGIN_MP_WECHAT'
// console.log(unionId)
// 原本为 openid
config.headers['Authorization'] = token
@@ -89,7 +89,7 @@ service.interceptors.response.use(
const res = response.data
// const env = process.env.NODE_ENV
// const env = 'production' // 测试中的生茶
if (env === 'production') {
// 生产环境,进行加密解密,不输出日志
if (res.encrypt == 1) {
@@ -117,7 +117,7 @@ service.interceptors.response.use(
title: res.msg,
icon: "none"
})
}
}
if (res.msg === '登录已过期!') {
outTimer = setTimeout(() => {
uni.showModal({
@@ -181,7 +181,7 @@ service.interceptors.response.use(
}
})
}
if (res.code != 20000 && res.msg != '令牌为空,不允许操作' && res.code != 42077 && res.code != 42011 &&res.msg != '您的ip已经更改请重新登录' && res.msg != '登录与操作设备不同') {
uni.showToast({
title: res.msg,
@@ -196,7 +196,7 @@ service.interceptors.response.use(
// console.log(err)
// }
// })
}
}
}
return res
},
@@ -212,7 +212,7 @@ service.interceptors.response.use(
})
} else {
uni.showToast({
title: '请求失败!',
title: res.msg?res.msg:'请求失败!',
icon: "none"
})
}