|
@@ -1,127 +1,26 @@
|
|
|
import router from '@/router/router'
|
|
|
import store from '@/store/'
|
|
|
+import { powerCheck } from '@/utils/bigmember/'
|
|
|
|
|
|
-const PowerMap = {
|
|
|
- 1: {
|
|
|
- tip: '搜索+订阅',
|
|
|
- url: 'big_subscribe&bigVip_detail&bigvip_viewpage',
|
|
|
- anchor: 'zb'
|
|
|
- },
|
|
|
- 2: {
|
|
|
- tip: '子账号',
|
|
|
- url: ''
|
|
|
- },
|
|
|
- 3: {
|
|
|
- tip: '附件下载',
|
|
|
- url: ''
|
|
|
- },
|
|
|
- 4: {
|
|
|
- tip: '企业全景分析',
|
|
|
- url: 'ent_portrait&ent_follow_search&ent_follow',
|
|
|
- anchor: 'jc'
|
|
|
- },
|
|
|
- 5: {
|
|
|
- tip: '采购单位全景分析',
|
|
|
- url: 'unit_portrayal',
|
|
|
- anchor: 'jc'
|
|
|
- },
|
|
|
- 6: {
|
|
|
- tip: '投标决策分析',
|
|
|
- url: 'analysis_search&analysis_filter&analysis_result&ai_unit',
|
|
|
- anchor: 'jc'
|
|
|
- },
|
|
|
- 7: {
|
|
|
- tip: '挖掘潜在客户',
|
|
|
- url: 'potential_cor_list&potential_cor',
|
|
|
- anchor: 'qz'
|
|
|
- },
|
|
|
- 8: {
|
|
|
- tip: '挖掘潜在伙伴/竞争对手',
|
|
|
- url: 'potential_cor_list&potential_cor',
|
|
|
- anchor: 'qz'
|
|
|
- },
|
|
|
- 9: {
|
|
|
- tip: '挖掘潜在项目',
|
|
|
- url: 'forecast_list&forecast_detail',
|
|
|
- anchor: 'fx'
|
|
|
- },
|
|
|
- 10: {
|
|
|
- tip: '周报/月报',
|
|
|
- url: 'bigvip_subreport_week&bigvip_subreport_month&report_detail_week&report_detail_month',
|
|
|
- anchor: 'fx'
|
|
|
- },
|
|
|
- 11: {
|
|
|
- tip: '招标文件解读',
|
|
|
- url: ''
|
|
|
- },
|
|
|
- 12: {
|
|
|
- tip: '企业情报监控',
|
|
|
- url: 'ent_portrait&ent_portrait_change&ent_follow_search&ent_follow',
|
|
|
- anchor: 'fx'
|
|
|
- },
|
|
|
- 13: {
|
|
|
- tip: '企业中标动态',
|
|
|
- url: 'ent_follow&ent_portrait&ent_follow_search',
|
|
|
- anchor: 'fx'
|
|
|
- },
|
|
|
- 14: {
|
|
|
- tip: '项目进度监控',
|
|
|
- url: 'pro_follow_list&pro_follow_detail',
|
|
|
- anchor: 'zb'
|
|
|
- },
|
|
|
- 15: {
|
|
|
- tip: '中标企业预测',
|
|
|
- url: 'ai_search&ai_add&ai_result&ai_balance&voucher_center&ai_unit',
|
|
|
- anchor: 'zb'
|
|
|
- },
|
|
|
- 16: {
|
|
|
- tip: '企业情报监控+企业中标动态',
|
|
|
- url: '',
|
|
|
- anchor: 'fx'
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function createURL2Power () {
|
|
|
- const URL2Power = new Map()
|
|
|
- Object.keys(PowerMap).forEach(v => {
|
|
|
- const nowV = PowerMap[v]
|
|
|
- const tempUrls = nowV.url.split('&')
|
|
|
- tempUrls.forEach(u => {
|
|
|
- const oldPower = URL2Power.get(u) || []
|
|
|
- URL2Power.set(u, Array.from(new Set(oldPower.concat(Number(v)))))
|
|
|
- })
|
|
|
- })
|
|
|
- return URL2Power
|
|
|
-}
|
|
|
-
|
|
|
-const URL2Power = createURL2Power()
|
|
|
+// 权限控制白名单-组件名
|
|
|
+const powerCheckWhiteList = ['404']
|
|
|
|
|
|
-// 从vue实例中获取store对象
|
|
|
-// const store = router.app.$store
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
const { power, info } = store.state.user
|
|
|
if (!Object.keys(info).length) {
|
|
|
await store.dispatch('user/getUserPower')
|
|
|
}
|
|
|
- let href = '/big/page/index'
|
|
|
- if (info?.memberStatus > 0) {
|
|
|
- const result = URL2Power.get(to.path) || URL2Power.get(to.name)
|
|
|
- if (result) {
|
|
|
- const intersectionPower = result.filter(v => power.includes(v))
|
|
|
- if (intersectionPower.length) {
|
|
|
- next()
|
|
|
- } else {
|
|
|
- const anchor = PowerMap[result[0]].anchor
|
|
|
- if (anchor) {
|
|
|
- href += '#' + anchor
|
|
|
- }
|
|
|
- location.href = href
|
|
|
- }
|
|
|
- } else {
|
|
|
- next()
|
|
|
- }
|
|
|
+ if (powerCheckWhiteList.includes(to.name)) {
|
|
|
+ next()
|
|
|
} else {
|
|
|
- if (to.name !== '404') {
|
|
|
+ let href = '/big/page/index'
|
|
|
+ const { pass, anchor } = powerCheck(info, power, to, from)
|
|
|
+ if (pass) {
|
|
|
+ next()
|
|
|
+ } else {
|
|
|
+ if (anchor) {
|
|
|
+ href = `${href}#${anchor}`
|
|
|
+ }
|
|
|
location.href = href
|
|
|
}
|
|
|
}
|