移动端
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.

permission.js 13 KiB

4 years ago
4 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. import router from './router'
  2. import store from './store'
  3. import NProgress from 'nprogress'
  4. import 'nprogress/nprogress.css'
  5. import { getToken } from '@/utils/auth'
  6. import Cookies from "js-cookie";
  7. NProgress.configure({ showSpinner: false })
  8. const whiteList = [
  9. '/index',
  10. '/login',
  11. '/auth-redirect',
  12. '/bind',
  13. '/register',
  14. '/news/index',
  15. '/news/newDetail',
  16. '/notice/index',
  17. '/notice/inviteTendersDetail',
  18. '/notice/winTheBiddingDetail',
  19. '/project/projectNeedsDetail',
  20. '/chungeng/userSSOLogin',
  21. '/chungeng/farmerSSOLogin',
  22. '/supply/index',
  23. '/interaction/index',
  24. '/register/index',
  25. '/register/registerType',
  26. '/register/userRegister',
  27. '/register/companyRegister',
  28. '/biddingHall',
  29. '/authenticRight',
  30. '/authenticRight/login',
  31. '/project',
  32. '/policy',
  33. '/policyDetail',
  34. '/attestationDetail',
  35. '/noticeDetail',
  36. '/homestead/login',
  37. '/applicationForm',
  38. '/applicationList',
  39. '/certificateList',
  40. '/certificateSee',
  41. '/informationList',
  42. '/circulationList',
  43. '/circulationAdd',
  44. '/onlineHomeLogin',
  45. '/lawEnforcement',
  46. '/lawEnforcement/caseList',
  47. '/lawEnforcement/productsList',
  48. '/lawEnforcement/user',
  49. '/lawEnforcement/programme',
  50. '/lawEnforcement/programmeDetail',
  51. '/lawEnforcement/programmeModify',
  52. '/lawEnforcement/programmeApproval',
  53. '/lawEnforcement/complaint',
  54. '/lawEnforcement/reply',
  55. '/lawEnforcement/changePassword',
  56. '/lawEnforcement/feedback',
  57. '/lawEnforcement/feedbackForm',
  58. '/lawEnforcement/agreement',
  59. '/lawEnforcement/work',
  60. '/lawEnforcement/workDetail',
  61. '/lawEnforcement/caseDetail',
  62. '/lawEnforcement/login',
  63. '/lawEnforcement/indexComplaint',
  64. '/lawEnforcement/schemeDetail',
  65. '/lawEnforcement/waitingProcessing',
  66. '/lawEnforcement/complaintAdd',
  67. '/homesteadLogin',
  68. '/yinnongLogin',
  69. '/lawEnforcement/userRegister',
  70. '/lawEnforcement/companyRegister',
  71. '/sunVillage/login',
  72. //阳光村务公众号 -- 待删
  73. '/sunVillage/index',
  74. '/sunVillage/latestReport', //最新报道列表
  75. '/sunVillage/latestReport/details', //最新报道详情
  76. '/sunVillage/importantItems', //重大事项-列表
  77. '/sunVillage/importantItems/details', //重大事项-详情
  78. '/sunVillage/public', //三务公开
  79. '/sunVillage/public/details', //三务公开-详情
  80. '/sunVillage/financial', //惠民金融
  81. '/sunVillage/financial/details', //惠民金融-详情
  82. '/sunVillage/financial/products', //惠民金融 - 理财产品
  83. '/sunVillage/financial/loan', //惠民金融 - 理财产品
  84. '/sunVillage/injoint', //三资公开-财务公开
  85. '/sunVillage/injoint/details',//三资公开-财务公开-详情
  86. '/sunVillage/injoint/meansOf', //三资公开-清产核资
  87. '/sunVillage/injoint/meansOf_desc', //三资公开-清产核资-详情页
  88. '/sunVillage/injoint/assetsPublic', //三资公开-资产公开
  89. '/sunVillage/injoint/assetsPublic_desc', //三资公开-资产公开-详情
  90. '/sunVillage/injoint/publicResources', //三资公开-资源公开
  91. '/sunVillage/injoint/publicResources_desc', //三资公开-资源公开-详情
  92. '/sunVillage/consulting', //民生直通车
  93. '/sunVillage/consulting/inquiries', //民生直通车-咨询
  94. "/sunVillage/consulting/my_consulting", //民生直通车-我的咨询详情
  95. '/sunVillage/consulting/kanban', //民生直通车-民生看板
  96. '/sunVillage/consulting/kanban/focusList', //民生直通车-民生看板 -关注民生list
  97. '/sunVillage/consulting/kanban/focusDesc', //民生直通车-民生看板 -关注民生详情
  98. '/sunVillage/consulting/kanban/affairsList', //民生直通车-民生看板 - 民生办事list
  99. '/sunVillage/equity', //股权查询-股民信息
  100. '/sunVillage/equity_desc', // 股权查询-股民信息-详情
  101. '/sunVillage/shareBonus', //股权查询-股权分红
  102. '/sunVillage/shareBonus_num', //股权查询-股权分红-股数详情页
  103. '/sunVillage/shareBonus_amount', //股权查询-股权分红-分红详情页
  104. '/sunVillage/user/index', //个人中心
  105. '/sunVillage/user/mobile', //个人中心-修改手机号
  106. '/sunVillage/user/information', //个人中心-修改用户信息
  107. '/sunVillage/user/cooperative', //个人中心-修改所属合作社
  108. //阳光村务公众号 -- 待删
  109. //宅基地
  110. '/zjdLogin',
  111. '/onlineHome/workbench',
  112. //阳光村务--新
  113. '/sunVillage_info/login', //登录
  114. '/sunVillage_info/index', //首页
  115. '/sunVillage_info/list_tourists', //二页列表-游客
  116. '/sunVillage_info/fixedAssets', //固定资产
  117. '/sunVillage_info/information', //合同信息
  118. '/sunVillage_info/details', //详情页
  119. '/sunVillage_info/index_code', //农户首页
  120. '/sunVillage_info/list_finance', //财务公开
  121. '/sunVillage_info/list_issues', //零工公开
  122. '/sunVillage_info/list_photo', //一张图公开
  123. '/sunVillage_info/list_contract', //合同公开
  124. '/sunVillage_info/list_contract_detail', //合同公开详情页
  125. '/sunVillage_info/list_tourists_detail', //详情页
  126. '/sunVillage_info/list_issues_detail', //详情页
  127. '/sunVillage_info/list_finance_detail', //详情页
  128. '/sunVillage_info/list_photo_detail', //详情页
  129. '/sunVillage_info/list_finance_ranking', //详情页
  130. '/sunVillage_info/list_tourists_ranking', //详情页
  131. '/sunVillage_info/login_code', //详情页
  132. '/sunVillage_info/index_code_rights', //详情页
  133. '/sunVillage_info/list_vote', //详情页
  134. '/sunVillage_info/list_vote_detail', //详情页
  135. '/sunVillage_info/list_vote_form', //详情页
  136. '/sunVillage_info/list_complaint', //详情页
  137. '/sunVillage_info/list_complaint_add', //详情页
  138. '/sunVillage_info/homeApplication/applicationList', //列表页面
  139. '/sunVillage_info/proposerLite',
  140. '/sunVillage_info/paidExit/paidExitList', //列表页面
  141. '/sunVillage_info/paidExitAdd',
  142. '/sunVillage_info/paidExitModify',
  143. '/sunVillage_info/paidExitDetail',
  144. '/sunVillage_info/arbitrationList',
  145. '/sunVillage_info/arbitrationDetail',
  146. '/sunVillage_info/familyMember',
  147. '/sunVillage_info/familyMemberDetail',
  148. '/sunVillage_info/list_signature',
  149. '/sunVillage_info/list_official',
  150. '/sunVillage_info/list_signature_add',
  151. '/sunVillage_info/list_multipleLotsNh',
  152. '/sunVillage_info/list_multipleLotsNh_detail',
  153. '/sunVillage_info/list_cbf',
  154. '/sunVillage_info/list_cbht_detail',
  155. // 新型经营主体
  156. 'newBusinessEntity/newsBulletin', //新闻公告
  157. '/newBusinessEntity/index', //首页
  158. '/newBusinessEntity/login', //登录
  159. '/newBusinessEntity/register', //注册
  160. '/newBusinessEntity/conter', //底部组件
  161. '/newBusinessEntity/newsDetails', //新闻详情
  162. '/newBusinessEntity/listBody', //主体名录
  163. '/newBusinessEntity/map', //地图
  164. //农业大托管
  165. '/agriculturalTrusteeship/index',//首页
  166. '/agriculturalTrusteeship/login',//登录
  167. '/agriculturalTrusteeship/insuranceList',//保险列表
  168. '/agriculturalTrusteeship/insuranceProjectList',//保险产品列表
  169. '/agriculturalTrusteeship/insuranceProjectDetail',//保险产品详情
  170. '/agriculturalTrusteeship/societyList',//社会化列表
  171. '/agriculturalTrusteeship/societyProjectList',//社会化产品列表
  172. '/agriculturalTrusteeship/societyProjectDetail',//社会化产品详情
  173. '/agriculturalTrusteeship/shopList',//保险列表首页
  174. '/agriculturalTrusteeship/shopNeedsList',//保险列表首页
  175. '/agriculturalTrusteeship/shopOrganizationDetail',//保险列表首页
  176. '/agriculturalTrusteeship/shopDepositDetail',//保险列表首页
  177. '/agriculturalTrusteeship/shopDetail',//保险列表详情
  178. '/agriculturalTrusteeship/shopEdit',//保险列表详情
  179. '/agriculturalTrusteeship/shopAdd',//保险列表首页
  180. '/agriculturalTrusteeship/serviceEdit',//保险列表首页
  181. '/agriculturalTrusteeship/socializationIndex',//社会化服务组织待处理
  182. '/agriculturalTrusteeship/socializationProject',//社会化服务组织产品
  183. '/agriculturalTrusteeship/socializationProjectDetail',//社会化服务组织产品详情
  184. '/agriculturalTrusteeship/socializationProjectEdit',//社会化服务组织产品修改
  185. '/agriculturalTrusteeship/socializationBill',//社会化服务组织订单
  186. '/agriculturalTrusteeship/socializationBillDetail',//社会化服务组织订单详情
  187. '/agriculturalTrusteeship/socializationBillOrder',//社会化服务组织订单详情
  188. '/agriculturalTrusteeship/socializationUser',//社会化服务组织个人中心
  189. '/agriculturalTrusteeship/socializationUserEdit',//社会化服务组织个人信息
  190. '/agriculturalTrusteeship/socializationRelease',//社会化服务组织发布产品
  191. '/agriculturalTrusteeship/socializationDraft',//社会化服务组织草稿箱
  192. '/agriculturalTrusteeship/socializationDraftEdit',//社会化服务组织草稿箱修改
  193. //'/agriculturalTrusteeship/buyerIndex',//买家选购
  194. //'/agriculturalTrusteeship/buyerWaitBill',//买家选购-等待处理
  195. // '/agriculturalTrusteeship/buyerAllBill',//买家选购-所有订单
  196. // '/agriculturalTrusteeship/placeOrder',//买家选购-下单页
  197. // '/agriculturalTrusteeship/billDetail',//买家选购-订单详情
  198. // '/agriculturalTrusteeship/billDetail2',//买家选购-订单详情
  199. // '/agriculturalTrusteeship/billDetail3',//买家选购-订单详情
  200. // '/agriculturalTrusteeship/billDetail4',//买家选购-订单详情
  201. // '/agriculturalTrusteeship/evaluate',//买家选购-服务评价
  202. '/plotPremisesMobile/index',//两清三化
  203. ]
  204. router.beforeEach((to, from, next) => {
  205. NProgress.start()
  206. if (getToken()) {
  207. /* has token*/
  208. if (to.path === '/login') {
  209. next({ path: '/' })
  210. NProgress.done()
  211. } else {
  212. if (store.getters.roles.length === 0) {
  213. next()
  214. // 判断当前用户是否已拉取完user_info信息
  215. store.dispatch('GetInfo').then(res => {
  216. // 拉取user_info
  217. const roles = res.roles
  218. // store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => {
  219. // // 根据roles权限生成可访问的路由表
  220. // router.addRoutes(accessRoutes) // 动态添加可访问路由表
  221. // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
  222. // })
  223. next()
  224. }).catch(err => {
  225. store.dispatch('LogOut').then(() => {
  226. try {
  227. let loginUrl = Cookies.get("_Login_url");
  228. if (loginUrl && loginUrl.indexOf("onlineHomeLogin") !== -1) {
  229. next({ path: '/onlineHomeLogin' })
  230. return;
  231. }
  232. } catch (e) { console.log(e); }
  233. // Message.error(err)
  234. if ('/authenticRight/index'.indexOf(to.path) !== -1) {
  235. next({ path: '/authenticRight/login' })
  236. } else if ('/homestead/index'.indexOf(to.path) !== -1) {
  237. next({ path: '/homestead/login' })
  238. } else if (to.path.indexOf('/onlineHome') !== -1) {
  239. //next(`/onlineHomeLogin`)
  240. next(`/zjdLogin`)
  241. } else if (to.path.indexOf('/yinnong') !== -1) {
  242. next(`/yinnongLogin`)
  243. } else if (window.location.href.indexOf('/sunVillage_info/') != -1) {
  244. window.location.href = '/sunVillage_info/login';
  245. } else if (to.path.indexOf('/homesteadSurvey') !== -1) {
  246. next(`/homesteadLogin`)
  247. } else if (to.path.indexOf('/lawEnforcement') !== -1) {
  248. next(`//lawEnforcement/login`)
  249. } else if (to.path.indexOf('/sunVillage') !== -1) {
  250. next(`/sunVillage/login`)
  251. } else if (to.path.indexOf('/homestead/') !== -1) {
  252. next(`/homestead/login`)
  253. } else {
  254. next(`/yinnongLogin`)
  255. //next({ path: '/' })
  256. }
  257. })
  258. })
  259. } else {
  260. next()
  261. }
  262. }
  263. } else {
  264. // 没有token
  265. console.info(to);
  266. if (whiteList.indexOf(to.path) !== -1) {
  267. // 在免登录白名单,直接进入
  268. console.log(to.path)
  269. next()
  270. } else {
  271. try {
  272. let loginUrl = Cookies.get("_Login_url");
  273. if (loginUrl && loginUrl.indexOf("onlineHomeLogin") !== -1) {
  274. next({ path: `/onlineHomeLogin?redirect=${to.fullPath}` })
  275. return;
  276. }
  277. } catch (e) { console.log(e); }
  278. if ('/authenticRight/index'.indexOf(to.path) !== -1) {
  279. next(`/authenticRight/login?redirect=${to.fullPath}`)
  280. } else if ('/homestead/index'.indexOf(to.path) !== -1) {
  281. next(`/homestead/login?redirect=${to.fullPath}`)
  282. } else if (to.path.indexOf('/onlineHome') !== -1) {
  283. next(`/onlineHomeLogin`)
  284. } else if (to.path.indexOf('/yinnong') !== -1) {
  285. next(`/yinnongLogin`)
  286. } else if (window.location.href.indexOf('/sunVillage_info/') != -1) {
  287. window.location.href = '/sunVillage_info/login';
  288. } else if (to.path.indexOf('/homesteadSurvey') !== -1) {
  289. next(`/homesteadLogin`)
  290. } else if (to.path.indexOf('/lawEnforcement') !== -1) {
  291. next(`/lawEnforcement/login?redirect=${to.fullPath}`)
  292. } else if (to.path.indexOf('/sunVillage') !== -1) {
  293. next(`/sunVillage/login`)
  294. } else {
  295. next(`/login?redirect=${to.fullPath}`)
  296. }
  297. // // 否则全部重定向到登录页
  298. //next('/index');
  299. NProgress.done()
  300. }
  301. }
  302. })
  303. router.afterEach(() => {
  304. NProgress.done()
  305. })