index.ts 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. import Vue from 'vue'
  2. import store from '@/store'
  3. import VueRouter, { RouteConfig } from 'vue-router'
  4. // 解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题
  5. const originalPush = VueRouter.prototype.push
  6. // @ts-ignore
  7. VueRouter.prototype.push = function push(location, onResolve, onReject) {
  8. if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  9. // @ts-ignore
  10. return originalPush.call(this, location).catch((err) => err)
  11. }
  12. // @ts-ignore
  13. import { getPvUv } from '@/api/public.js'
  14. Vue.use(VueRouter)
  15. const routes: Array<RouteConfig> = [
  16. // 项目概况
  17. {
  18. path: '/',
  19. name: 'Overview',
  20. // redirect: '/otherMatter',
  21. component: () => import(/* webpackChunkName: "overview" */ '../views/overview/index.vue'),
  22. meta: {
  23. keepAlive: true,
  24. showTabbar: true,
  25. },
  26. },
  27. // 项目概况
  28. {
  29. path: '/overview',
  30. name: 'Overview',
  31. component: () => import(/* webpackChunkName: "overview" */ '../views/overview/index.vue'),
  32. meta: {
  33. keepAlive: true,
  34. showTabbar: true,
  35. },
  36. },
  37. // 楼层功能
  38. {
  39. path: '/floorFunc',
  40. name: 'FloorFunc',
  41. component: () => import(/* webpackChunkName: "floorFunc" */ '../views/FloorFunc.vue'),
  42. meta: {
  43. keepAlive: true,
  44. showTabbar: true,
  45. },
  46. },
  47. // 设备设施
  48. {
  49. path: '/equipmentFacilities',
  50. name: 'EquipmentFacilities',
  51. component: () => import(/* webpackChunkName: "equipmentFacilities" */ '../views/equipmentFacilities/index.vue'),
  52. meta: {
  53. keepAlive: true,
  54. showTabbar: true,
  55. },
  56. },
  57. // 设备设施 --> 设备卡片跳转到的设备列表页面
  58. {
  59. path: '/equipmentList',
  60. name: 'EquipmentList',
  61. component: () => import(/* webpackChunkName: "equipmentList" */ '../views/equipmentFacilities/EquipmentList.vue'),
  62. meta: {
  63. keepAlive: false,
  64. showTabbar: false,
  65. hideNarBar: true,
  66. },
  67. },
  68. // 设备设施 --> 更多设备卡片 跳转到的设备列表页面
  69. {
  70. path: '/moreEquipmentList',
  71. name: 'MoreEquipmentList',
  72. component: () => import(/* webpackChunkName: "equipmentList" */ '../views/equipmentFacilities/MoreEquipmentList.vue'),
  73. meta: {
  74. keepAlive: false,
  75. showTabbar: false,
  76. hideNarBar: true,
  77. },
  78. },
  79. // 设备设置 --> 机房平面布置图
  80. {
  81. path: '/engineRoomPicture',
  82. name: 'EngineRoomPicture',
  83. component: () => import(/* webpackChunkName: "engineRoomPicture" */ '../views/equipmentFacilities/EngineRoomPicture.vue'),
  84. meta: {
  85. keepAlive: false,
  86. showTabbar: false,
  87. hideNarBar: true,
  88. },
  89. },
  90. // 设备设置 --> 楼层分布
  91. {
  92. path: '/systemFloor',
  93. name: 'SystemFloor',
  94. component: () => import(/* webpackChunkName: "systemFloor" */ '../views/equipmentFacilities/SystemFloor.vue'),
  95. meta: {
  96. keepAlive: false,
  97. showTabbar: true,
  98. hideNarBar: true,
  99. },
  100. },
  101. // 设备设置 --> 电井间控制商铺范围
  102. {
  103. path: '/electricWell',
  104. name: 'ElectricWell',
  105. component: () => import(/* webpackChunkName: "electricWell" */ '../views/equipmentFacilities/ElectricWell.vue'),
  106. meta: {
  107. keepAlive: false,
  108. showTabbar: false,
  109. hideNarBar: true,
  110. },
  111. },
  112. // 设备设置 --> 配电室低压柜及出线明细
  113. {
  114. path: '/lowVoltageCabinet',
  115. name: 'LowVoltageCabinet',
  116. component: () => import(/* webpackChunkName: "lowVoltageCabinet" */ '../views/equipmentFacilities/LowVoltageCabinet.vue'),
  117. meta: {
  118. keepAlive: false,
  119. showTabbar: false,
  120. hideNarBar: true,
  121. },
  122. },
  123. // 其他事项
  124. {
  125. path: '/otherMatter',
  126. name: 'OtherMatter',
  127. component: () => import(/* webpackChunkName: "otherMatter" */ '../views/otherMatter/index.vue'),
  128. meta: {
  129. keepAlive: true,
  130. showTabbar: true,
  131. },
  132. },
  133. // 其他事项 --> 综合事项
  134. {
  135. path: '/comprehensiveMatter',
  136. name: 'ComprehensiveMatter',
  137. component: () => import(/* webpackChunkName: "comprehensiveMatter" */ '../views/otherMatter/ComprehensiveMatter.vue'),
  138. meta: {
  139. keepAlive: true,
  140. showTabbar: true,
  141. },
  142. },
  143. // 其他事项 --> 综合事项 --> 政府/其他 事项列表页面
  144. {
  145. path: '/comprehensiveMatterList',
  146. name: 'ComprehensiveMatterList',
  147. component: () => import(/* webpackChunkName: "comprehensiveMatterList" */ '../views/otherMatter/ComprehensiveMatterList.vue'),
  148. meta: {
  149. keepAlive: false,
  150. showTabbar: false,
  151. hideNarBar: true,
  152. },
  153. },
  154. // 其他事项 --> 辅助用房
  155. {
  156. path: '/auxiliaryRoom',
  157. name: 'AuxiliaryRoom',
  158. component: () => import(/* webpackChunkName: "auxiliaryRoom" */ '../views/otherMatter/AuxiliaryRoom.vue'),
  159. meta: {
  160. keepAlive: false,
  161. showTabbar: true,
  162. },
  163. },
  164. // 说明书更新记录
  165. {
  166. path: '/updateRecord',
  167. name: 'UpdateRecord',
  168. component: () => import(/* webpackChunkName: "updateRecord" */ '../views/overview/UpdateRecord.vue'),
  169. meta: {
  170. keepAlive: true,
  171. showTabbar: false,
  172. hideNarBar: true,
  173. },
  174. },
  175. // 说明书更新记录详情
  176. {
  177. path: '/updateRecordDetail',
  178. name: 'UpdateRecordDetail',
  179. component: () => import(/* webpackChunkName: "updateRecordDetail" */ '../views/overview/UpdateRecordDetail.vue'),
  180. meta: {
  181. keepAlive: false,
  182. showTabbar: false,
  183. hideNarBar: true,
  184. },
  185. },
  186. // 平面图查看
  187. {
  188. path: '/mapView',
  189. name: 'MapView',
  190. component: () => import(/* webpackChunkName: "mapView" */ '../views/overview/MapView.vue'),
  191. meta: {
  192. keepAlive: false,
  193. showTabbar: false,
  194. hideNarBar: true,
  195. },
  196. },
  197. // 平面图查看(特殊)
  198. {
  199. path: '/mapOther',
  200. name: 'MapOther',
  201. component: () => import(/* webpackChunkName: "mapOther" */ '../views/overview/MapOther.vue'),
  202. meta: {
  203. keepAlive: false,
  204. showTabbar: false,
  205. hideNarBar: true,
  206. },
  207. },
  208. // 全局搜索
  209. {
  210. path: '/globalSearch',
  211. name: 'GlobalSearch',
  212. component: () => import(/* webpackChunkName: "globalSearch" */ '../views/GlobalSearch.vue'),
  213. meta: {
  214. keepAlive: false,
  215. showTabbar: false,
  216. hideNarBar: true,
  217. },
  218. },
  219. // 设备详情页
  220. {
  221. path: '/assetDetail',
  222. name: 'AssetDetail',
  223. component: () => import(/* webpackChunkName: "assetDetail" */ '../views/AssetDetail.vue'),
  224. meta: {
  225. keepAlive: false,
  226. showTabbar: false,
  227. hideNarBar: true,
  228. },
  229. },
  230. ]
  231. const router = new VueRouter({
  232. mode: 'history',
  233. base: process.env.BASE_URL,
  234. routes,
  235. })
  236. // 跳入路由后要对发送pvuv
  237. router.afterEach((to, from) => {
  238. // console.log(to, from)
  239. // 项目概览,楼层功能,设备设施,其他事项 记录pupv
  240. let pupvArr = ['Overview', 'FloorFunc', 'EquipmentFacilities', 'OtherMatter']
  241. // tabbar对应的四个路由相互切换,发送puuv
  242. // @ts-ignore
  243. if (!pupvArr.includes(to.name) || !pupvArr.includes(from.name)) {
  244. return true
  245. }
  246. let postParams = {
  247. type: 'router',
  248. target: to.name,
  249. parameter: to.path,
  250. app: 'H5',
  251. }
  252. const data = {
  253. plazaId: store.getters['plazaId'],
  254. }
  255. getPvUv(data, postParams)
  256. .then((res: any) => {
  257. // console.log('pvuv', res)
  258. })
  259. .catch((res: any) => {
  260. // console.log('error', res)
  261. })
  262. })
  263. export default router