测试bug修改
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import request from './request'
|
||||
import cache from './cacheKey.js'
|
||||
import { getImageUrl } from '@/common/api/basic'
|
||||
import { apiUpdatePush } from '@/common/api/user'
|
||||
import { queryDictDataCache } from '../api/dictionary.js'
|
||||
import cacheKey from './cacheKey.js'
|
||||
const toast = (title, duration = 1500, call, mask = false, icon = 'none') => {
|
||||
@@ -200,31 +201,39 @@ const prePage = () => {
|
||||
return prePage
|
||||
}
|
||||
|
||||
const loginSuccess = (data) => {
|
||||
console.log(data)
|
||||
uni.setStorageSync('access_token', data.token_type + ' ' + data.access_token)
|
||||
uni.setStorageSync('refresh_token', data.refresh_token)
|
||||
let strings = data.access_token.split('.') //截取token,获取载体
|
||||
console.log(escape, atob)
|
||||
var userInfo = JSON.parse(decodeURIComponent(escape(atob(strings[1].replace(/-/g, '+').replace(/_/g, '/')))))
|
||||
userInfo.authorities = userInfo.authorities[0]
|
||||
if (userInfo.headSculpture) {
|
||||
getImageUrl(userInfo.headSculpture).then((res) => {
|
||||
userInfo.avatar = res.data
|
||||
const loginSuccess = (data, jump = true) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(data)
|
||||
uni.setStorageSync('access_token', data.token_type + ' ' + data.access_token)
|
||||
uni.setStorageSync('refresh_token', data.refresh_token)
|
||||
let strings = data.access_token.split('.') //截取token,获取载体
|
||||
console.log(escape, atob)
|
||||
var userInfo = JSON.parse(decodeURIComponent(escape(atob(strings[1].replace(/-/g, '+').replace(/_/g, '/')))))
|
||||
userInfo.authorities = userInfo.authorities[0]
|
||||
if (userInfo.headSculpture) {
|
||||
getImageUrl(userInfo.headSculpture).then((res) => {
|
||||
userInfo.avatar = res.data
|
||||
uni.setStorageSync(cache.userInfo, userInfo)
|
||||
apiUpdatePush()
|
||||
resolve(userInfo)
|
||||
})
|
||||
} else {
|
||||
uni.setStorageSync(cache.userInfo, userInfo)
|
||||
})
|
||||
} else {
|
||||
uni.setStorageSync(cache.userInfo, userInfo)
|
||||
}
|
||||
console.log('reLaunch')
|
||||
queryDictDataCache().then((res) => {
|
||||
uni.setStorageSync(cacheKey.dictData, res.data)
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
fail: (err) => {
|
||||
console.log(err)
|
||||
},
|
||||
})
|
||||
apiUpdatePush()
|
||||
resolve(userInfo)
|
||||
}
|
||||
console.log('reLaunch')
|
||||
if (jump) {
|
||||
queryDictDataCache().then((res) => {
|
||||
uni.setStorageSync(cacheKey.dictData, res.data)
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
fail: (err) => {
|
||||
console.log(err)
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user