|
@@ -10,6 +10,7 @@ import qs from 'qs'
|
|
|
import constant from '@/constant/index'
|
|
import constant from '@/constant/index'
|
|
|
// import common from '@/utils/common'
|
|
// import common from '@/utils/common'
|
|
|
import { parse, getCheckLogin } from '@/utils/util'
|
|
import { parse, getCheckLogin } from '@/utils/util'
|
|
|
|
|
+import store from '@/store'
|
|
|
|
|
|
|
|
const Base64 = require('js-base64').Base64
|
|
const Base64 = require('js-base64').Base64
|
|
|
class Request {
|
|
class Request {
|
|
@@ -167,41 +168,55 @@ class Request {
|
|
|
}
|
|
}
|
|
|
reject(response.data)
|
|
reject(response.data)
|
|
|
} else if (response.data.code && response.data.code == -1) {
|
|
} else if (response.data.code && response.data.code == -1) {
|
|
|
- // 无权限或者登录过期
|
|
|
|
|
uni.removeStorageSync('token')
|
|
uni.removeStorageSync('token')
|
|
|
|
|
+ store.commit('setLoginInfo', {})
|
|
|
|
|
+
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '加载中...',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- if(noLogin.indexOf(currentPages) == -1){
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '登录过期,正在重新登录...',
|
|
|
|
|
- icon: 'none',
|
|
|
|
|
- mask: true
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ let account = uni.getStorageSync('account')
|
|
|
|
|
+ if(account){
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ uni.reLaunch({
|
|
|
|
|
+ url: '/'+currentPages+'?account='+account
|
|
|
|
|
+ })
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+ }else{
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ uni.reLaunch({
|
|
|
|
|
+ url: `/pages/home/recent`
|
|
|
|
|
+ })
|
|
|
|
|
+ }, 1000)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- getCheckLogin()
|
|
|
|
|
- uni.reLaunch({
|
|
|
|
|
- url: `/pages/home/index`
|
|
|
|
|
- })
|
|
|
|
|
- }, 1000)
|
|
|
|
|
|
|
+
|
|
|
} else if (response.data.code == 2) {
|
|
} else if (response.data.code == 2) {
|
|
|
uni.removeStorageSync('token')
|
|
uni.removeStorageSync('token')
|
|
|
- uni.removeStorageSync('shopUser')
|
|
|
|
|
- uni.removeStorageSync('account')
|
|
|
|
|
- if(noLogin.indexOf(currentPages) == -1){
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '登录失效,正在重新登录...',
|
|
|
|
|
- icon: 'none',
|
|
|
|
|
- mask: true
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ store.commit('setLoginInfo', {})
|
|
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- getCheckLogin()
|
|
|
|
|
- uni.reLaunch({
|
|
|
|
|
- url: `/pages/home/index`
|
|
|
|
|
- })
|
|
|
|
|
- }, 1000)
|
|
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '加载中...',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ let account = uni.getStorageSync('account')
|
|
|
|
|
+ if(account){
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ uni.reLaunch({
|
|
|
|
|
+ url: '/'+currentPages+'?account='+account
|
|
|
|
|
+ })
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+ }else{
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ uni.reLaunch({
|
|
|
|
|
+ url: `/pages/home/recent`
|
|
|
|
|
+ })
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
console.log('response.data', response.data)
|
|
console.log('response.data', response.data)
|
|
|
if (!config.hideError) {
|
|
if (!config.hideError) {
|