|
|
@ -4,6 +4,17 @@ import { http } from 'plugins/request/index'; |
|
|
|
import App from './App'; |
|
|
|
import store from './store'; |
|
|
|
|
|
|
|
// 白名单页面
|
|
|
|
const whitePathList = ['basic-info', 'statistics', 'user-code']; |
|
|
|
/** |
|
|
|
* 检查url是否在是否在白名单内 |
|
|
|
* @param {string} url path+query |
|
|
|
*/ |
|
|
|
const checkWhitePath = url => { |
|
|
|
let str = url.slice(7).split('/')[0]; |
|
|
|
return whitePathList.includes(str); |
|
|
|
}; |
|
|
|
|
|
|
|
Vue.config.productionTip = false; |
|
|
|
Vue.prototype.$http = http; |
|
|
|
Vue.prototype.$moment = moment; |
|
|
@ -23,14 +34,17 @@ Vue.prototype.goHome = () => { |
|
|
|
*/ |
|
|
|
|
|
|
|
// 白名单页面
|
|
|
|
const whiteListPath = ['/pages/basic-info/basic-info','/pages/statistics/statistics','/pages/user-code/user-code'] |
|
|
|
const whiteListPath = [ |
|
|
|
'/pages/basic-info/basic-info', |
|
|
|
'/pages/statistics/statistics', |
|
|
|
'/pages/user-code/user-code', |
|
|
|
]; |
|
|
|
|
|
|
|
Vue.prototype.openPage = function(path, query = '') { |
|
|
|
let url = query ? `${path}?${query}` : path; |
|
|
|
store.commit('user/setPagePath',url) |
|
|
|
|
|
|
|
const choosePath = whiteListPath.indexOf(path) |
|
|
|
if(!store.state.user.userInfo.id && choosePath === -1) { |
|
|
|
store.commit('user/setPagePath', url); |
|
|
|
const isWhite = checkWhitePath(url); |
|
|
|
if (!store.state.user.userInfo.id && !isWhite) { |
|
|
|
url = '/pages/basic-info/basic-info'; |
|
|
|
} |
|
|
|
|
|
|
|