Commit f2474220 authored by Damon's avatar Damon

token过期处理

parent 502c78b5
......@@ -133,7 +133,6 @@ export default {
var that = this
that.globalData.token = util.getToken()
console.log(that.globalData.token, 'that.globalData.token')
that.initAPIneedToken()
// uni.getStorage({
// key: 'token',
......@@ -151,11 +150,21 @@ export default {
},
onShow: function () {
//if (!util.getToken()) {
this.autoLogin()
//}
if (util.getToken()) {
this.loginCheck()
} else {
this.autoLogin()
}
},
methods: {
methods: {
async loginCheck() {
setTimeout(async () => {
let result = await this.$u.api.loginCheck({token: util.getToken()})
if (!result.data) {
this.autoLogin()
}
}, 0)
},
getSystemInfo() {
try {
let a = wx.getSystemInfoSync();
......@@ -347,7 +356,7 @@ export default {
/**
* 用户自动登录
*/
autoLogin() {
autoLogin() {
let that = this
uni.login({
async success(res) {
......
......@@ -4,12 +4,14 @@ const ucenterApiUrl = globalUrl.ucenterUrl.apiUrl
let commonApiFun = function(vm){
let loginWxByUser = async (params = {}) => await vm.$u.get('/wxh-support-rest/rest/ssoinfo/v3/getUsersByCode', params);
let loginWxByPhone = async (params = {}) => await vm.$u.post('/wxh-support-rest/rest/ssoinfo/v3/findByMobile', params,{'content-type': 'application/x-www-form-urlencoded'});
let loginWechatAuth = async (params = {}) => await vm.$u.post('/wxh-support-rest/rest/ssoinfo/wxapp/unify/authorization', params, {'content-type': 'application/x-www-form-urlencoded'});
let loginWechatAuth = async (params = {}) => await vm.$u.post('/wxh-support-rest/rest/ssoinfo/wxapp/unify/authorization', params, {'content-type': 'application/x-www-form-urlencoded'});
let loginCheck = async (params = {}) => await vm.$u.get(`/wxh-support-rest/rest/ssoinfo/wxapp/unify/check/${params.token}`);
const commonApi = {
loginWxByUser,
loginWxByPhone,
loginWechatAuth,
loginWechatAuth,
loginCheck
}
return commonApi
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment