render.js
3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-09-23 19:04:32
* @LastEditors: limin
* @LastEditTime: 2021-09-23 20:34:32
* @FilePath: \scrm\scrm-sub-blog\src\qiankun\render.js
*/
import App from '../App.vue'
import Vue from 'vue'
import store from '@/store'
import { VueRouter } from '@/router'
const render = (base, routes) => {
const router = new VueRouter({
base,
routes,
mode: 'history'
})
router.beforeEach((to, from, next) => {
let modelStatus = false;
let menuStatus = false;
const menu = JSON.parse(sessionStorage['SCRM_BASE_MENULIST'])
menu.forEach(item => {
if (!item.children) {
return
}
item.children.forEach(itm => {
if (itm.path == '/enterpriseWechat/index') {
menuStatus = true;
}
})
})
if (menuStatus && Vue.prototype.$globalState.session.merchantModel == 1 && Vue.prototype.$globalState.session.accountLevel == 1) {
modelStatus = true;
}
if (menuStatus && Vue.prototype.$globalState.session.merchantModel == 2 && Vue.prototype.$globalState.session.accountLevel == 4) {
modelStatus = true;
}
if (!sessionStorage.getItem('wxStatus') && (to.path == '/home/index' || to.path == '/ehome/index') && modelStatus) {
Vue.prototype.$apis.ww.getStatus({}).then((res) => {
if (res.status != 'SUCCESS') {
Vue.prototype.$history.push('/settings/enterpriseWechat/index')
sessionStorage.setItem('wxStatus', 1)
} else {
sessionStorage.setItem('wxAcess', 1)
next()
}
})
} else {
next();
}
})
// router.beforeEach((to, from, next) => {
// let modelStatus = false;
// let menu = JSON.parse(sessionStorage.getItem('SCRM_BASE_MENULIST'));
// let menuStatus = menu[0].children.find(item => {
// return item.path.indexOf('enterpriseWechat/index') != -1
// })
// if (menuStatus && Vue.prototype.$globalState.session.merchantModel == 1 && Vue.prototype.$globalState.session.accountLevel == 1) {
// modelStatus = true;
// }
// if (menuStatus && Vue.prototype.$globalState.session.merchantModel == 2 && Vue.prototype.$globalState.session.accountLevel == 4) {
// modelStatus = true;
// }
// if (!sessionStorage.getItem('wxStatus') && (to.path == '/home/index' || to.path == '/ehome/index') && modelStatus) {
// Vue.prototype.$apis.ww.getStatus({}).then((res) => {
// if (res.status != 'SUCCESS') {
// next('/enterpriseWechat/index')
// sessionStorage.setItem('wxStatus', 1)
// } else {
// sessionStorage.setItem('wxAcess', 1)
// next()
// }
// })
// } else {
// next();
// }
// })
const vm = new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
return { router, vm }
}
export default render