routes.js 2.7KB

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