fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { createRouter, createWebHistory, RouteRecordRaw, createWebHashHistory } from 'vue-router'
|
||||
import { defineAsyncComponent } from 'vue'
|
||||
import store from "@/store"
|
||||
import { useStore } from "vuex";
|
||||
import { Https } from "@/tool/https";
|
||||
import { getCookie, setCookie } from "@/tool/cookie";
|
||||
const _import = (path: string) => () => import(`../views/${path}.vue`);
|
||||
@@ -11,6 +12,7 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: "/",
|
||||
// redirect重定向
|
||||
meta:{enter:'all',},
|
||||
redirect: "/Square"
|
||||
// redirect: "/upgrade"
|
||||
|
||||
@@ -18,6 +20,7 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
meta:{enter:'all',},
|
||||
component: _import('LoginPage')
|
||||
},
|
||||
// {
|
||||
@@ -28,6 +31,7 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/upgrade',
|
||||
name: 'upgrade',
|
||||
meta:{enter:'all',},
|
||||
component: _import('Upgrade'),
|
||||
},
|
||||
// {
|
||||
@@ -38,6 +42,7 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
meta:{enter:'all',},
|
||||
component: _import('HomeMain'),
|
||||
children:[
|
||||
{
|
||||
@@ -48,56 +53,68 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path:'homePage',
|
||||
name:'homePage',
|
||||
meta:{enter:'all',},
|
||||
component: _import_custom('HomeView/HomeView.vue'),
|
||||
},{
|
||||
},{
|
||||
path:'library',
|
||||
name:'library',
|
||||
meta:{enter:'all',},
|
||||
component: _import_custom('HomeView/library.vue'),
|
||||
},{
|
||||
path:'history',
|
||||
name:'history',
|
||||
meta:{enter:'all',},
|
||||
component: _import_custom('HomeView/history.vue'),
|
||||
},{
|
||||
path:'works',
|
||||
name:'works',
|
||||
meta:{enter:'all',},
|
||||
component: _import_custom('HomeView/Works.vue'),
|
||||
},{
|
||||
path:'events',
|
||||
name:'events',
|
||||
meta:{enter:'all',},
|
||||
component: _import_custom('HomeView/Events.vue'),
|
||||
},{
|
||||
path:'eventsDetail',
|
||||
name:'eventsDetail',
|
||||
meta:{enter:'all',},
|
||||
component: _import_component('Events/eventsDetail.vue'),
|
||||
},{
|
||||
path:'account',
|
||||
name:'account',
|
||||
meta:{enter:'all',},
|
||||
component: _import_component('Account/account.vue'),
|
||||
children:[
|
||||
{
|
||||
path: "",
|
||||
name:'accountChil',
|
||||
meta:{enter:'all',},
|
||||
redirect: "/home/account/frontPage"
|
||||
},
|
||||
{
|
||||
path:'frontPage',
|
||||
name:'frontPage',
|
||||
meta:{enter:'all',},
|
||||
component: _import_component('Account/frontPage.vue'),
|
||||
},
|
||||
{
|
||||
path:'accountMessage',
|
||||
name:'accountMessage',
|
||||
meta:{enter:'all',},
|
||||
component: _import_component('Account/accountMessage.vue'),
|
||||
},
|
||||
{
|
||||
path:'accountFollowFans',
|
||||
name:'accountFollowFans',
|
||||
meta:{enter:'all',},
|
||||
component: _import_component('Account/accountFollowFans.vue'),
|
||||
}
|
||||
]
|
||||
},{
|
||||
path:'otherUsers',
|
||||
name:'otherUsers',
|
||||
meta:{enter:'all',},
|
||||
component: _import_component('Account/otherUsers.vue'),
|
||||
}
|
||||
]
|
||||
@@ -105,25 +122,30 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/Square',
|
||||
name: "HomeRecommend",
|
||||
meta:{enter:'all',},
|
||||
component: _import('HomeRecommend'),
|
||||
children:[
|
||||
{
|
||||
path: "",
|
||||
name:'SquareChil',
|
||||
meta:{enter:'all',},
|
||||
redirect: "/Square/works"
|
||||
},
|
||||
{
|
||||
path:'works',
|
||||
name:'SquareWorks',
|
||||
meta:{enter:'all',},
|
||||
component: _import_custom('HomeView/Works.vue'),
|
||||
},{
|
||||
path:'events',
|
||||
name:'SquareEvents',
|
||||
meta:{enter:'all',},
|
||||
component: _import_custom('HomeView/Events.vue'),
|
||||
|
||||
},{
|
||||
path:'eventsDetail',
|
||||
name:'SquareEventsDetail',
|
||||
meta:{enter:'all',},
|
||||
component: _import_component('Events/eventsDetail.vue'),
|
||||
}
|
||||
]
|
||||
@@ -146,71 +168,118 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/administrator',
|
||||
name: 'administrator',
|
||||
meta:{enter:3,},
|
||||
component: _import('Administrator'),
|
||||
children:[
|
||||
{
|
||||
path: "",
|
||||
name:'adminChil',
|
||||
meta:{enter:3,},
|
||||
redirect: "/administrator/allUser"
|
||||
},
|
||||
{
|
||||
path:'allUser',
|
||||
name:'allUser',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/allUser.vue'),
|
||||
},
|
||||
{
|
||||
path:'testClickData',
|
||||
name:'testClickData',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/TestClickData.vue'),
|
||||
},
|
||||
{
|
||||
path:'trialApproval',
|
||||
name:'trialApproval',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/trialApproval.vue'),
|
||||
},{
|
||||
path:'questionnaire',
|
||||
name:'questionnaire',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/questionnaire.vue'),
|
||||
},{
|
||||
path:'recentActiveChart',
|
||||
name:'recentActiveChart',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/recentActiveChart.vue'),
|
||||
},{
|
||||
path:'recentActiveUser',
|
||||
name:'recentActiveUser',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/recentActiveUser.vue'),
|
||||
},{
|
||||
path:'recentActiveUserChart',
|
||||
name:'recentActiveUserChart',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/recentActiveUserChart.vue'),
|
||||
},{
|
||||
path:'recentNewUser',
|
||||
name:'recentNewUser',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/recentNewUser.vue'),
|
||||
},{
|
||||
path:'recentNewUserChart',
|
||||
name:'recentNewUserChart',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/recentNewUserChart.vue'),
|
||||
},{
|
||||
path:'trialUserCountry',
|
||||
name:'trialUserCountry',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/trialUserCountry.vue'),
|
||||
},{
|
||||
path:'trialUserConversionRateChart',
|
||||
name:'trialUserConversionRateChart',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/trialUserConversionRateChart.vue'),
|
||||
},{
|
||||
path:'trialAllUser',
|
||||
name:'trialAllUser',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/trialAllUser.vue'),
|
||||
},{
|
||||
path:'affiliateAudit',
|
||||
name:'affiliateAudit',
|
||||
meta:{enter:3,},
|
||||
component: _import_component('Administrator/affiliate/affiliateAudit.vue'),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/paySucceed',
|
||||
name: 'paySucceed',
|
||||
meta:{
|
||||
enter:'all',
|
||||
},
|
||||
component: _import('paySucceed')
|
||||
},
|
||||
{
|
||||
path: '/affiliate',
|
||||
name: 'affiliate',
|
||||
meta:{
|
||||
enter:2,
|
||||
},
|
||||
component: _import('affiliate/affiliatePage'),
|
||||
children:[
|
||||
{
|
||||
path: "/affiliate",
|
||||
name:'affiliateHome',
|
||||
meta:{
|
||||
enter:2,
|
||||
},
|
||||
component: _import_component('affiliate/home'),
|
||||
},
|
||||
]
|
||||
},{
|
||||
path: '/affiliateRegister',
|
||||
name: 'affiliateRegister',
|
||||
meta:{
|
||||
enter:'all',
|
||||
},
|
||||
component: _import('affiliate/affiliateRegister'),
|
||||
},
|
||||
// {
|
||||
// path: '/library',
|
||||
// name: 'library',
|
||||
@@ -224,26 +293,33 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/setIdentification',
|
||||
name: 'setIdentification',
|
||||
meta:{
|
||||
enter:'all',
|
||||
},
|
||||
component: _import('setIdentification')
|
||||
},
|
||||
{
|
||||
path: '/feedbackSurvey',
|
||||
name: 'feedbackSurvey',
|
||||
meta:{
|
||||
enter:'all',
|
||||
},
|
||||
component: _import('feedbackSurvey'),
|
||||
},
|
||||
{
|
||||
path: '/feedbackSurveyCN',
|
||||
name: 'feedbackSurveyCN',
|
||||
meta:{
|
||||
enter:'all',
|
||||
},
|
||||
component: _import('feedbackSurveyCN'),
|
||||
},
|
||||
{
|
||||
path: '/emailVerify',
|
||||
name: 'emailVerify',
|
||||
component: _import('emailVerify'),
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
name: '404',
|
||||
meta:{
|
||||
enter:'all',
|
||||
},
|
||||
component: _import('404')
|
||||
},
|
||||
{
|
||||
@@ -262,23 +338,15 @@ const router = createRouter({
|
||||
let state:any = store.state
|
||||
window.addEventListener("beforeunload", (e) => {
|
||||
localStorage.setItem(
|
||||
"vuex_setSystemUser",
|
||||
JSON.stringify(state.UserHabit.systemUser.value)
|
||||
);
|
||||
localStorage.setItem(
|
||||
"vuex_setUserInfo",
|
||||
JSON.stringify(state.UserHabit.userInfo)
|
||||
"vuex_setUserDetail",
|
||||
JSON.stringify(state.UserHabit.userDetail)
|
||||
);
|
||||
|
||||
});
|
||||
var vuex_setSystemUser:any = localStorage.getItem("vuex_setSystemUser");
|
||||
var vuex_setUserInfo:any = localStorage.getItem("vuex_setUserInfo");
|
||||
if (vuex_setSystemUser == 0 || vuex_setSystemUser == 1) {
|
||||
store.commit("setSystemUser", JSON.parse(vuex_setSystemUser));
|
||||
localStorage.removeItem("vuex_setSystemUser");
|
||||
}
|
||||
if (vuex_setUserInfo) {
|
||||
store.commit("setUserInfo", JSON.parse(vuex_setUserInfo));
|
||||
localStorage.removeItem("vuex_setSystemUser");
|
||||
var vuex_setUserDetail:any = localStorage.getItem("vuex_setUserDetail");
|
||||
if (vuex_setUserDetail) {
|
||||
store.commit("setUserDetail", JSON.parse(vuex_setUserDetail));
|
||||
// localStorage.removeItem("vuex_setUserDetail");
|
||||
}
|
||||
|
||||
let setMurmur = (id:any)=> {
|
||||
@@ -299,6 +367,11 @@ let setMurmur = (id:any)=> {
|
||||
setCookie("isBeginner", isBeginner);
|
||||
setCookie("isBeginnerNum", 0);//从第一步开始,机器人开始的话就是从第二部开始
|
||||
setCookie("userInfo", JSON.stringify(rv));
|
||||
let userid = {
|
||||
ueserId:rv.userId,
|
||||
systemUser:rv.systemUser
|
||||
}
|
||||
store.commit("upUserDetail", userid);
|
||||
sessionStorage.setItem('isTimeOne', JSON.stringify(false));//是否需要公告 提示 弹窗
|
||||
let randomNum: any = Math.floor(Math.random() * 9000000000000000) + 1000000000000000;
|
||||
sessionStorage.setItem('sessionId', randomNum);
|
||||
@@ -309,13 +382,16 @@ let setMurmur = (id:any)=> {
|
||||
// router.push('/Square')
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const setViewsIncrease = (value:any)=>{
|
||||
sessionStorage.setItem('affiliateRef', value);
|
||||
let data = {
|
||||
id:value
|
||||
}
|
||||
Https.axiosGet(Https.httpUrls.viewsIncrease,{params:data}).then((rv)=>{})
|
||||
}
|
||||
router.beforeEach((to:any, from, next) => {
|
||||
let upgradeList = ['/feedbackSurvey','/feedbackSurveyCN','emailVerify']//指定页面系统维护也可以访问
|
||||
|
||||
// // 系统维护
|
||||
// 系统维护
|
||||
// const toName = to.name === 'upgrade';
|
||||
// if(upgradeList.indexOf(to.path) > -1){
|
||||
// next();
|
||||
@@ -332,72 +408,20 @@ router.beforeEach((to:any, from, next) => {
|
||||
let herfData = window.location.search.substring(1)
|
||||
if(herfData.split('=')[0] == 'noLogin' && to.name != 'homePage'){
|
||||
setMurmur(herfData.split('=')[1])
|
||||
// console.log(`-------------------成功${herfData.split('=')[1]}-------------------`)
|
||||
return
|
||||
}
|
||||
|
||||
let userInfo = JSON.parse(getCookie("userInfo") as any);
|
||||
let murmurStr: any = localStorage.getItem('murmurStr')
|
||||
let getIsMurmur: any = getCookie("isMurmur")
|
||||
let token = getCookie("token");
|
||||
let isMurmur = JSON.parse(getIsMurmur)
|
||||
let routeList = ['/testClickData','/trialApproval']//指定页面需要指定id才能进入
|
||||
let userIdList = [88,6,46,31,73,83,87,4]
|
||||
let isSystemUserRouteList = ['/login','/Square']//游客用户只能进入这两个页面
|
||||
|
||||
let systemUser = state.UserHabit.systemUser
|
||||
const routeExists = router.getRoutes().some(({ name }) =>{
|
||||
if(name){
|
||||
return (name === to.name || to.path == '/')
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
});
|
||||
if(upgradeList.indexOf(to.path) > -1){//指定页面任何用户都可以进入
|
||||
let affiliateRef = sessionStorage.getItem('affiliateRef');
|
||||
if(to.query.order)sessionStorage.setItem('orderId', to.query.order);//记录是否点击跳转订单链接
|
||||
if(to.query.ref && affiliateRef != to.query.ref)setViewsIncrease(to.query.ref)
|
||||
|
||||
if(to.meta.enter == 'all'){
|
||||
next();
|
||||
return
|
||||
}else if(state.UserHabit.userDetail.systemList.indexOf(to.meta.enter) > -1){
|
||||
next()
|
||||
}else{
|
||||
next('/404');
|
||||
}
|
||||
|
||||
if(systemUser.value == 0){//游客用户只能进入这两个页面
|
||||
let sSystemUser = false
|
||||
for (let index = 0; index < isSystemUserRouteList.length; index++) {
|
||||
if(to.path.indexOf(isSystemUserRouteList[index]) > -1){
|
||||
sSystemUser = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if(sSystemUser){
|
||||
next();
|
||||
}else{
|
||||
next('/Square');
|
||||
}
|
||||
return
|
||||
}
|
||||
if (isMurmur && murmurStr && token) {
|
||||
const toName = to.name === 'login';
|
||||
if (toName) {
|
||||
return next({ name: '/home' });//机房用户
|
||||
}
|
||||
} else {
|
||||
if(to.path == '/upgrade'){
|
||||
return next({ path: '/' });//机房用户
|
||||
}
|
||||
if (routeList.indexOf(to.path) > -1 ) {//指定也买你必须指定用户可以进入
|
||||
if(userIdList.indexOf(userInfo.userId) > -1){
|
||||
}else{
|
||||
return next({ name: '/404' });
|
||||
}
|
||||
}
|
||||
// 如果页面存在,正常跳转
|
||||
}
|
||||
next();
|
||||
// if (routeExists) {//检测档期那页面是否存在
|
||||
|
||||
// } else {
|
||||
// // 如果页面不存在,可以跳转到404页面或者其他页面
|
||||
// next('/404');
|
||||
// }
|
||||
|
||||
// if(systemUser == 0){//游客用户只能进入这两个页面
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user