耀实惠小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

86 lines
1.8 KiB

import { LOGINS_LIST } from '@/config/settings.js'
import utils from '@/utils/utils'
import { storageKeys, storage } from '@/utils/storage.js'
export default {
isLoginsPage (path) {
let token = storage.getStorage(storageKeys.TOKEN)
let userInfo = storage.getStorage(storageKeys.USERINFO)
let flag = false
console.log(LOGINS_LIST.findIndex(item => path.indexOf(item) > -1) > -1 , !token , !Object.keys(userInfo).length, userInfo)
try{
flag = LOGINS_LIST.findIndex(item => path.indexOf(item) > -1) > -1 && (!token || !Object.keys(userInfo).length)
}catch(err){
flag = true
console.log(err)
}
console.log(path,flag)
return flag
},
navigateTo (options = {}) {
return new Promise((resolve, reject) => {
try{
let { url } = options
if (this.isLoginsPage(url)) {
utils.loginModal()
} else {
uni.navigateTo(options)
resolve()
}
}catch(err){
reject()
console.error(err)
}
})
},
redirectTo (options = {}) {
return new Promise((resolve, reject) => {
try{
let { url } = options
if (this.isLoginsPage(url)) {
utils.loginModal()
} else {
uni.redirectTo(options)
resolve()
}
}catch(err){
reject()
console.error(err)
}
})
},
reLaunch (options = {}) {
return new Promise((resolve, reject) => {
try{
let { url } = options
if (this.isLoginsPage(url)) {
utils.loginModal()
} else {
uni.reLaunch(options)
resolve()
}
}catch(err){
reject()
console.error(err)
}
})
},
switchTab (options = {}) {
return new Promise((resolve, reject) => {
try{
let { url } = options
if (this.isLoginsPage(url)) {
utils.loginModal()
} else {
uni.switchTab(options)
resolve()
}
}catch(err){
reject()
console.error(err)
}
})
},
navigateBack (options = {}) {
uni.navigateBack(options)
}
}