移动端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

permission.js 13 KiB

4 年前
4 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
1年前
3 个月前
1年前
4 年前
4 年前
4 年前
4 年前
4 年前
4 年前
4 年前
4 年前
4 年前
3 年前
3 年前
2 年前
3 年前
4 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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/index_new',
  16. '/news/newDetail',
  17. '/notice/index',
  18. '/notice/inviteTendersDetail',
  19. '/notice/winTheBiddingDetail',
  20. '/project/projectNeedsDetail',
  21. '/chungeng/userSSOLogin',
  22. '/chungeng/farmerSSOLogin',
  23. '/supply/index',
  24. '/interaction/index',
  25. '/register/index',
  26. '/register/registerType',
  27. '/register/userRegister',
  28. '/register/companyRegister',
  29. '/biddingHall',
  30. '/authenticRight',
  31. '/authenticRight/login',
  32. '/project',
  33. '/policy',
  34. '/policyDetail',
  35. '/policyPDF',
  36. '/attestationDetail',
  37. '/noticeDetail',
  38. '/homestead/login',
  39. '/applicationForm',
  40. '/applicationList',
  41. '/certificateList',
  42. '/certificateSee',
  43. '/informationList',
  44. '/circulationList',
  45. '/circulationAdd',
  46. '/onlineHomeLogin',
  47. '/lawEnforcement',
  48. '/lawEnforcement/caseList',
  49. '/lawEnforcement/productsList',
  50. '/lawEnforcement/user',
  51. '/lawEnforcement/programme',
  52. '/lawEnforcement/programmeDetail',
  53. '/lawEnforcement/programmeModify',
  54. '/lawEnforcement/programmeApproval',
  55. '/lawEnforcement/complaint',
  56. '/lawEnforcement/reply',
  57. '/lawEnforcement/changePassword',
  58. '/lawEnforcement/feedback',
  59. '/lawEnforcement/feedbackForm',
  60. '/lawEnforcement/agreement',
  61. '/lawEnforcement/work',
  62. '/lawEnforcement/workDetail',
  63. '/lawEnforcement/caseDetail',
  64. '/lawEnforcement/login',
  65. '/lawEnforcement/indexComplaint',
  66. '/lawEnforcement/schemeDetail',
  67. '/lawEnforcement/waitingProcessing',
  68. '/lawEnforcement/complaintAdd',
  69. '/homesteadLogin',
  70. '/yinnongLogin',
  71. '/yinnongLiteLogin',
  72. '/lawEnforcement/userRegister',
  73. '/lawEnforcement/companyRegister',
  74. //宅基地
  75. '/zjdLogin',
  76. '/onlineHome/workbench',
  77. //阳光村务--新
  78. '/sunVillage_info/login', //登录
  79. '/sunVillage_info/index', //首页
  80. '/sunVillage_info/list_tourists', //二页列表-游客
  81. '/sunVillage_info/fixedAssets', //固定资产
  82. '/sunVillage_info/information', //合同信息
  83. '/sunVillage_info/details', //详情页
  84. '/sunVillage_info/index_code', //农户首页
  85. '/sunVillage_info/list_finance', //财务公开
  86. '/sunVillage_info/list_issues', //零工公开
  87. '/sunVillage_info/list_photo', //一张图公开
  88. '/sunVillage_info/list_contract', //合同公开
  89. '/sunVillage_info/list_contract_detail', //合同公开详情页
  90. '/sunVillage_info/list_tourists_detail', //详情页
  91. '/sunVillage_info/list_issues_detail', //详情页
  92. '/sunVillage_info/list_finance_detail', //详情页
  93. '/sunVillage_info/list_photo_detail', //详情页
  94. '/sunVillage_info/list_finance_ranking', //详情页
  95. '/sunVillage_info/list_tourists_ranking', //零工排行榜
  96. '/sunVillage_info/list_tourists_ranking_lite', //零工排行榜
  97. '/sunVillage_info/list_tourists_registration_detail_visitor', //零工详情页
  98. '/sunVillage_info/login_code', //详情页
  99. '/sunVillage_info/index_code_rights', //详情页
  100. '/sunVillage_info/list_vote', //详情页
  101. '/sunVillage_info/list_vote_detail', //详情页
  102. '/sunVillage_info/list_vote_form', //详情页
  103. '/sunVillage_info/suishoupai', //随手拍
  104. '/sunVillage_info/list_complaint', //详情页
  105. '/sunVillage_info/list_complaint_add', //详情页
  106. '/sunVillage_info/list_complaint_detail', //详情页
  107. '/sunVillage_info/list_message', //详情页
  108. '/sunVillage_info/list_message_add', //详情页
  109. '/sunVillage_info/list_message_detail', //详情页
  110. '/sunVillage_info/homeApplication/applicationList', //列表页面
  111. '/sunVillage_info/homeApplication/applicationNewList', //列表页面
  112. '/sunVillage_info/proposerLite',
  113. '/sunVillage_info/proposerLiteNew',
  114. '/sunVillage_info/paidExitAddNew',
  115. '/sunVillage_info/paidExit/paidExitList', //列表页面
  116. '/sunVillage_info/paidExit/paidExitNewList', //宅基地退出列表页面(新)
  117. '/sunVillage_info/paidExitAdd',
  118. '/sunVillage_info/paidExitModify',
  119. '/sunVillage_info/paidExitModifyNew',
  120. '/sunVillage_info/paidExitDetail',
  121. '/sunVillage_info/paidExitDetailNew',
  122. '/sunVillage_info/arbitrationList',
  123. '/sunVillage_info/arbitrationDetail',
  124. '/sunVillage_info/familyMember',
  125. '/sunVillage_info/familyMemberDetail',
  126. '/sunVillage_info/list_cbfsq',
  127. '/sunVillage_info/list_signature',
  128. '/sunVillage_info/list_official',
  129. '/sunVillage_info/list_signature_add',
  130. '/sunVillage_info/list_multipleLotsNh',
  131. '/sunVillage_info/list_multipleLotsNh_detail',
  132. '/sunVillage_info/list_cbf',
  133. '/sunVillage_info/list_cbht_detail',
  134. '/sunVillage_info/list_resources_ranking',
  135. '/sunVillage_info/list_property_ranking',
  136. '/sunVillage_info/list_contract_ranking',
  137. '/sunVillage_info/identity_check',
  138. '/sunVillage_info/assetMapOpen',
  139. '/sunVillage_info/otherOpenVisitIndex',
  140. '/sunVillage_info/otherOpenVisitDetail',
  141. '/sunVillage_info/list_discussions_new',
  142. '/sunVillage_info/list_discussions_new_detail',
  143. '/sunVillage_info/list_process',
  144. '/sunVillage_info/list_process_detail',
  145. '/sunVillage_info/list_issues_zy',
  146. '/sunVillage_info/list_issues_zy_detail',
  147. '/sunVillage_info/list_special',
  148. '/sunVillage_info/list_special_detail',
  149. '/sunVillage_info/list_special_detail_vote',
  150. '/sunVillage_info/list_finance_new',
  151. '/sunVillage_info/list_finance_new_detail',
  152. // 新型经营主体
  153. 'newBusinessEntity/newsBulletin', //新闻公告
  154. '/newBusinessEntity/index', //首页
  155. '/newBusinessEntity/login', //登录
  156. '/newBusinessEntity/register', //注册
  157. '/newBusinessEntity/conter', //底部组件
  158. '/newBusinessEntity/newsDetails', //新闻详情
  159. '/newBusinessEntity/listBody', //主体名录
  160. '/newBusinessEntity/map', //地图
  161. //农业大托管
  162. '/agriculturalTrusteeship/index',//首页
  163. '/agriculturalTrusteeship/login',//登录
  164. '/agriculturalTrusteeship/insuranceList',//保险列表
  165. '/agriculturalTrusteeship/insuranceProjectList',//保险产品列表
  166. '/agriculturalTrusteeship/insuranceProjectDetail',//保险产品详情
  167. '/agriculturalTrusteeship/societyList',//社会化列表
  168. '/agriculturalTrusteeship/societyProjectList',//社会化产品列表
  169. '/agriculturalTrusteeship/societyProjectDetail',//社会化产品详情
  170. '/agriculturalTrusteeship/shopList',//保险列表首页
  171. '/agriculturalTrusteeship/shopNeedsList',//保险列表首页
  172. '/agriculturalTrusteeship/shopOrganizationDetail',//保险列表首页
  173. '/agriculturalTrusteeship/shopDepositDetail',//保险列表首页
  174. '/agriculturalTrusteeship/shopDetail',//保险列表详情
  175. '/agriculturalTrusteeship/shopEdit',//保险列表详情
  176. '/agriculturalTrusteeship/shopAdd',//保险列表首页
  177. '/agriculturalTrusteeship/serviceEdit',//保险列表首页
  178. '/agriculturalTrusteeship/socializationIndex',//社会化服务组织待处理
  179. '/agriculturalTrusteeship/socializationProject',//社会化服务组织产品
  180. '/agriculturalTrusteeship/socializationProjectDetail',//社会化服务组织产品详情
  181. '/agriculturalTrusteeship/socializationProjectEdit',//社会化服务组织产品修改
  182. '/agriculturalTrusteeship/socializationBill',//社会化服务组织订单
  183. '/agriculturalTrusteeship/socializationBillDetail',//社会化服务组织订单详情
  184. '/agriculturalTrusteeship/socializationBillOrder',//社会化服务组织订单详情
  185. '/agriculturalTrusteeship/socializationUser',//社会化服务组织个人中心
  186. '/agriculturalTrusteeship/socializationUserEdit',//社会化服务组织个人信息
  187. '/agriculturalTrusteeship/socializationRelease',//社会化服务组织发布产品
  188. '/agriculturalTrusteeship/socializationDraft',//社会化服务组织草稿箱
  189. '/agriculturalTrusteeship/socializationDraftEdit',//社会化服务组织草稿箱修改
  190. //'/agriculturalTrusteeship/buyerIndex',//买家选购
  191. //'/agriculturalTrusteeship/buyerWaitBill',//买家选购-等待处理
  192. // '/agriculturalTrusteeship/buyerAllBill',//买家选购-所有订单
  193. // '/agriculturalTrusteeship/placeOrder',//买家选购-下单页
  194. // '/agriculturalTrusteeship/billDetail',//买家选购-订单详情
  195. // '/agriculturalTrusteeship/billDetail2',//买家选购-订单详情
  196. // '/agriculturalTrusteeship/billDetail3',//买家选购-订单详情
  197. // '/agriculturalTrusteeship/billDetail4',//买家选购-订单详情
  198. // '/agriculturalTrusteeship/evaluate',//买家选购-服务评价
  199. '/plotPremisesMobile/index',//闲置资源
  200. '/sunVillage_info/login_farmer', //村民登录
  201. '/sunVillage_info/index_farmer', //村民主页
  202. '/sunVillage_info/financeOpen', //村民主页
  203. //承包地确权
  204. '/contracted/login',//登录
  205. '/contracted/index',//首页
  206. //虫害APP
  207. '/pest/pestLogin',//登录
  208. '/pest/index',//首页
  209. '/pest/agriculturalRecords',//农事记录
  210. '/pest/agriculturalRecordsAdd',//农事记录(新增)
  211. '/pest/soilTesting',//土壤检测
  212. '/pest/weather',//气象服务
  213. '/pest/growthMonitoring',//长势监测
  214. '/pest/temperatureAndHumidity',//温湿度
  215. ]
  216. router.beforeEach((to, from, next) => {
  217. NProgress.start()
  218. if (getToken()) {
  219. /* has token*/
  220. if (to.path === '/login') {
  221. next({ path: '/' })
  222. NProgress.done()
  223. } else {
  224. if (store.getters.roles.length === 0) {
  225. next()
  226. // 判断当前用户是否已拉取完user_info信息
  227. store.dispatch('GetInfo').then(res => {
  228. // 拉取user_info
  229. const roles = res.roles
  230. Cookies.set('user',res.user)
  231. // store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => {
  232. // // 根据roles权限生成可访问的路由表
  233. // router.addRoutes(accessRoutes) // 动态添加可访问路由表
  234. // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
  235. // })
  236. next()
  237. }).catch(err => {
  238. // store.dispatch('LogOut').then(() => {
  239. // try {
  240. // let loginUrl = Cookies.get("_Login_url");
  241. // if (loginUrl && loginUrl.indexOf("onlineHomeLogin") !== -1) {
  242. // next({ path: '/onlineHomeLogin' })
  243. // return;
  244. // }
  245. // } catch (e) { console.log(e); }
  246. // // Message.error(err)
  247. // if ('/authenticRight'.indexOf(to.path) !== -1) {
  248. // next({ path: '/authenticRight/login' })
  249. // } else if ('/homestead'.indexOf(to.path) !== -1) {
  250. // next({ path: '/homestead/login' })
  251. // } else if (to.path.indexOf('/onlineHome') !== -1) {
  252. // //next(`/onlineHomeLogin`)
  253. // next(`/zjdLogin`)
  254. // } else if (to.path.indexOf('/yinnong') !== -1) {
  255. // next(`/yinnongLogin`)
  256. // } else if (window.location.href.indexOf('/sunVillage_info/') != -1) {
  257. // window.location.href = '/sunVillage_info/login';
  258. // } else if (to.path.indexOf('/homesteadSurvey') !== -1) {
  259. // next(`/homesteadLogin`)
  260. // } else if (to.path.indexOf('/lawEnforcement') !== -1) {
  261. // next(`/lawEnforcement/login`)
  262. // } else if (to.path.indexOf('/sunVillage') !== -1) {
  263. // next(`/sunVillage/login`)
  264. // } else {
  265. // next(`/yinnongLogin`)
  266. // //next({ path: '/' })
  267. // }
  268. // })
  269. })
  270. } else {
  271. next()
  272. }
  273. }
  274. } else {
  275. // 没有token
  276. //console.info(to);
  277. if (whiteList.indexOf(to.path) !== -1) {
  278. // 在免登录白名单,直接进入
  279. //console.log(to.path)
  280. next()
  281. } else {
  282. try {
  283. let loginUrl = Cookies.get("_Login_url");
  284. console.log('登录页面: ' + loginUrl)
  285. if (loginUrl) {
  286. if(loginUrl.indexOf("onlineHomeLogin") !== -1)
  287. {
  288. next({ path: `/onlineHomeLogin?redirect=${to.fullPath}` })
  289. return;
  290. }
  291. else if(loginUrl.indexOf("yinnongLiteLogin") !== -1)
  292. {
  293. next({ path: '/yinnongLiteLogin' })
  294. return;
  295. }
  296. }
  297. } catch (e) { console.log(e); }
  298. if ('/authenticRight/index'.indexOf(to.path) !== -1) {
  299. next(`/authenticRight/login?redirect=${to.fullPath}`)
  300. } else if ('/homestead/index'.indexOf(to.path) !== -1) {
  301. next(`/homestead/login?redirect=${to.fullPath}`)
  302. } else if (to.path.indexOf('/onlineHome') !== -1) {
  303. next(`/onlineHomeLogin`)
  304. } else if (to.path.indexOf('/yinnong') !== -1) {
  305. next(`/yinnongLogin`)
  306. } else if (window.location.href.indexOf('/sunVillage_info/') != -1) {
  307. window.location.href = '/sunVillage_info/login';
  308. } else if (to.path.indexOf('/homesteadSurvey') !== -1) {
  309. next(`/homesteadLogin`)
  310. } else if (to.path.indexOf('/lawEnforcement') !== -1) {
  311. next(`/lawEnforcement/login?redirect=${to.fullPath}`)
  312. } else if (to.path.indexOf('/sunVillage') !== -1) {
  313. next(`/sunVillage/login`)
  314. } else if (to.path.indexOf('/pest') !== -1) {
  315. next(`/pest/pestLogin`)
  316. } else {
  317. next(`/login?redirect=${to.fullPath}`)
  318. }
  319. // // 否则全部重定向到登录页
  320. //next('/index');
  321. NProgress.done()
  322. }
  323. }
  324. })
  325. router.afterEach(() => {
  326. NProgress.done()
  327. })