routes.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // 客户页面
  2. const mainPages = [
  3. {
  4. title: '首页',
  5. page: 'pages/index/index',
  6. isIndex: true,
  7. },
  8. {
  9. title: '搜索',
  10. page: 'pages/search/search',
  11. },
  12. {
  13. title: '搜索结果',
  14. page: 'pages/searchResult/searchResult',
  15. },
  16. {
  17. title: '商铺详情',
  18. page: 'pages/details/foodDetails/foodDetails',
  19. },
  20. {
  21. title: '景点详情',
  22. page: 'pages/details/mjDetails/sceneryDetails',
  23. },
  24. {
  25. title: '订单',
  26. page: 'pages/PayOrder/index',
  27. },
  28. {
  29. title: '联系我们',
  30. page: 'pages/MineUserAll/ContactMe/index',
  31. },
  32. {
  33. title: '我的收藏',
  34. page: 'pages/MineUserAll/Collect/index',
  35. },
  36. {
  37. title: '协议声明',
  38. page: 'pages/MineUserAll/Rules/index',
  39. },
  40. {
  41. title: '退款申请',
  42. page: 'pages/MineUserAll/RefundMoney/index',
  43. },
  44. {
  45. title: '确认退款',
  46. page: 'pages/MineUserAll/RefundMoney/CheckRefund/index',
  47. },
  48. {
  49. title: '我的订单',
  50. page: 'pages/MineUserAll/AllOrder/index',
  51. },
  52. {
  53. title: '套餐核销',
  54. page: 'pages/TobeShop/index',
  55. },
  56. {
  57. title: '入住指引跳转表单',
  58. page: 'pages/RoomOrder/index'
  59. }
  60. ];
  61. // 商户管理页面shop/pages/spread/spreadIndex
  62. const shopPages = [
  63. {
  64. title: '商铺管理',
  65. page: 'pages/spread/spreadIndex',
  66. isIndex: true,
  67. },
  68. ];
  69. // 民宿管理页面hotel/pages/landlord/landlord
  70. const hotelPages = [
  71. {
  72. title: '民宿管理',
  73. page: 'pages/landlord/landlord',
  74. isIndex: true,
  75. },
  76. {
  77. title: '新增房源',
  78. page: 'pages/landlord/addRoom/addRoom',
  79. },
  80. {
  81. title: '查看入住人',
  82. page: 'pages/landlord/roomOrder/roomOrder',
  83. },
  84. ];
  85. // 所有的页面
  86. const routes = mainPages.concat(shopPages.map(x => ({ ...x, root: 'shop' })))
  87. .concat(hotelPages.map(x => ({ ...x, root: 'hotel' })))
  88. // 主包
  89. const pages = mainPages.map(x => x.page);
  90. // 分包
  91. const subPages = routes.reduce((acc, route) => {
  92. if (!route.root) return acc;
  93. const pgs = acc[route.root] || []
  94. return {
  95. ...acc,
  96. [route.root]: pgs.concat(route.page)
  97. }
  98. }, {})
  99. const subPackages = Object.keys(subPages).map((key) => {
  100. return {
  101. root: key,
  102. pages: subPages[key]
  103. }
  104. })
  105. // 获取路径对应页面
  106. function getPageBy(path) {
  107. return routes.filter(x => path.indexOf(x.page) > -1)[0]
  108. }
  109. // 获取角色首页
  110. function getIndexPageOf(role) {
  111. if (role === 'person') {
  112. return routes.filter(x => !x.root && x.isIndex)[0]
  113. }
  114. return routes.filter(x => x.root === role && x.isIndex)[0]
  115. }
  116. // eslint-disable-next-line import/no-commonjs
  117. module.exports = {
  118. routes,
  119. pages,
  120. subPackages,
  121. getPageBy,
  122. getIndexPageOf
  123. }