index.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. // 进入H5页面时,如果有assetid,跳转到设备详情页面
  27. beforeEnter(to, from, next) {
  28. if (to.query.assetid) {
  29. let assetid = to.query.assetid
  30. let query = { assetid, first: true }
  31. // @ts-ignore
  32. next({ name: 'AssetDetail', query })
  33. } else {
  34. next()
  35. }
  36. },
  37. },
  38. // 项目概况
  39. {
  40. path: '/overview',
  41. name: 'Overview',
  42. component: () => import(/* webpackChunkName: "overview" */ '../views/overview/index.vue'),
  43. meta: {
  44. keepAlive: true,
  45. showTabbar: true,
  46. },
  47. },
  48. // 楼层功能
  49. {
  50. path: '/floorFunc',
  51. name: 'FloorFunc',
  52. component: () => import(/* webpackChunkName: "floorFunc" */ '../views/FloorFunc.vue'),
  53. meta: {
  54. keepAlive: true,
  55. showTabbar: true,
  56. },
  57. },
  58. // 设备设施
  59. {
  60. path: '/equipmentFacilities',
  61. name: 'EquipmentFacilities',
  62. component: () => import(/* webpackChunkName: "equipmentFacilities" */ '../views/equipmentFacilities/index.vue'),
  63. meta: {
  64. keepAlive: true,
  65. showTabbar: true,
  66. },
  67. },
  68. // 设备设施 --> 设备卡片跳转到的设备列表页面
  69. {
  70. path: '/equipmentList',
  71. name: 'EquipmentList',
  72. component: () => import(/* webpackChunkName: "equipmentList" */ '../views/equipmentFacilities/EquipmentList.vue'),
  73. meta: {
  74. keepAlive: true,
  75. showTabbar: false,
  76. hideNarBar: true,
  77. },
  78. },
  79. // 设备设施 --> 更多设备卡片 跳转到的设备列表页面
  80. {
  81. path: '/moreEquipmentList',
  82. name: 'MoreEquipmentList',
  83. component: () => import(/* webpackChunkName: "moreEquipmentList" */ '../views/equipmentFacilities/MoreEquipmentList.vue'),
  84. meta: {
  85. keepAlive: false,
  86. showTabbar: false,
  87. hideNarBar: true,
  88. },
  89. },
  90. // 设备设置 --> 机房平面布置图
  91. {
  92. path: '/engineRoomPicture',
  93. name: 'EngineRoomPicture',
  94. component: () => import(/* webpackChunkName: "engineRoomPicture" */ '../views/equipmentFacilities/EngineRoomPicture.vue'),
  95. meta: {
  96. keepAlive: false,
  97. showTabbar: false,
  98. hideNarBar: true,
  99. },
  100. },
  101. // 设备设施 --> 主要设备清单
  102. {
  103. path: '/mainEquipment',
  104. name: 'MainEquipment',
  105. component: () => import(/* webpackChunkName: "mainEquipment" */ '../views/equipmentFacilities/MainEquipment.vue'),
  106. meta: {
  107. keepAlive: false,
  108. showTabbar: false,
  109. hideNarBar: true,
  110. },
  111. },
  112. // 设备设施 --> 主要设备清单 --> 详情
  113. {
  114. path: '/mainEquipmentDetail',
  115. name: 'MainEquipmentDetail',
  116. component: () => import(/* webpackChunkName: "mainEquipmentDetail" */ '../views/equipmentFacilities/MainEquipmentDetail.vue'),
  117. meta: {
  118. keepAlive: false,
  119. showTabbar: false,
  120. hideNarBar: true,
  121. },
  122. },
  123. // 设备设施 --> 其他事项
  124. {
  125. path: '/otherMatters',
  126. name: 'OtherMatters',
  127. component: () => import(/* webpackChunkName: "otherMatters" */ '../views/equipmentFacilities/OtherMatters.vue'),
  128. meta: {
  129. keepAlive: false,
  130. showTabbar: false,
  131. hideNarBar: true,
  132. },
  133. },
  134. // 设备设置 --> 楼层分布
  135. {
  136. path: '/systemFloor',
  137. name: 'SystemFloor',
  138. component: () => import(/* webpackChunkName: "systemFloor" */ '../views/equipmentFacilities/SystemFloor.vue'),
  139. meta: {
  140. keepAlive: false,
  141. showTabbar: true,
  142. hideNarBar: true,
  143. },
  144. },
  145. // 设备设置 --> 电井间控制商铺范围
  146. {
  147. path: '/electricWell',
  148. name: 'ElectricWell',
  149. component: () => import(/* webpackChunkName: "electricWell" */ '../views/equipmentFacilities/ElectricWell.vue'),
  150. meta: {
  151. keepAlive: false,
  152. showTabbar: false,
  153. hideNarBar: true,
  154. },
  155. },
  156. // 设备设置 --> 配电室低压出线柜及出线明细
  157. {
  158. path: '/lowVoltageCabinet',
  159. name: 'LowVoltageCabinet',
  160. component: () => import(/* webpackChunkName: "lowVoltageCabinet" */ '../views/equipmentFacilities/LowVoltageCabinet.vue'),
  161. meta: {
  162. keepAlive: true,
  163. showTabbar: false,
  164. hideNarBar: true,
  165. },
  166. },
  167. // 设备设置 --> 配电室低压出线柜及出线明细 --> 详情
  168. {
  169. path: '/lowVoltageCabinetDetail',
  170. name: 'LowVoltageCabinetDetail',
  171. component: () => import(/* webpackChunkName: "lowVoltageCabinetDetail" */ '../views/equipmentFacilities/LowVoltageCabinetDetail.vue'),
  172. meta: {
  173. keepAlive: false,
  174. showTabbar: false,
  175. hideNarBar: true,
  176. },
  177. },
  178. // 其他事项
  179. {
  180. path: '/otherMatter',
  181. name: 'OtherMatter',
  182. component: () => import(/* webpackChunkName: "otherMatter" */ '../views/otherMatter/index.vue'),
  183. meta: {
  184. keepAlive: true,
  185. showTabbar: true,
  186. },
  187. },
  188. // 其他事项 --> 综合事项
  189. {
  190. path: '/comprehensiveMatter',
  191. name: 'ComprehensiveMatter',
  192. component: () => import(/* webpackChunkName: "comprehensiveMatter" */ '../views/otherMatter/ComprehensiveMatter.vue'),
  193. meta: {
  194. keepAlive: true,
  195. showTabbar: true,
  196. },
  197. },
  198. // 其他事项 --> 综合事项 --> 政府/其他 事项列表页面
  199. {
  200. path: '/comprehensiveMatterList',
  201. name: 'ComprehensiveMatterList',
  202. component: () => import(/* webpackChunkName: "comprehensiveMatterList" */ '../views/otherMatter/ComprehensiveMatterList.vue'),
  203. meta: {
  204. keepAlive: false,
  205. showTabbar: false,
  206. hideNarBar: true,
  207. },
  208. },
  209. // 其他事项 --> 辅助用房
  210. {
  211. path: '/auxiliaryRoom',
  212. name: 'AuxiliaryRoom',
  213. component: () => import(/* webpackChunkName: "auxiliaryRoom" */ '../views/otherMatter/AuxiliaryRoom.vue'),
  214. meta: {
  215. keepAlive: false,
  216. showTabbar: true,
  217. },
  218. },
  219. // 说明书更新记录
  220. {
  221. path: '/updateRecord',
  222. name: 'UpdateRecord',
  223. component: () => import(/* webpackChunkName: "updateRecord" */ '../views/overview/UpdateRecord.vue'),
  224. meta: {
  225. keepAlive: true,
  226. showTabbar: false,
  227. hideNarBar: true,
  228. },
  229. },
  230. // 说明书更新记录详情
  231. {
  232. path: '/updateRecordDetail',
  233. name: 'UpdateRecordDetail',
  234. component: () => import(/* webpackChunkName: "updateRecordDetail" */ '../views/overview/UpdateRecordDetail.vue'),
  235. meta: {
  236. keepAlive: false,
  237. showTabbar: false,
  238. hideNarBar: true,
  239. },
  240. },
  241. // 平面图查看
  242. {
  243. path: '/mapView',
  244. name: 'MapView',
  245. component: () => import(/* webpackChunkName: "mapView" */ '../views/overview/MapView.vue'),
  246. meta: {
  247. keepAlive: false,
  248. showTabbar: false,
  249. hideNarBar: true,
  250. },
  251. },
  252. // 平面图查看(特殊)
  253. {
  254. path: '/mapOther',
  255. name: 'MapOther',
  256. component: () => import(/* webpackChunkName: "mapOther" */ '../views/overview/MapOther.vue'),
  257. meta: {
  258. keepAlive: false,
  259. showTabbar: false,
  260. hideNarBar: true,
  261. },
  262. },
  263. // 全局搜索
  264. {
  265. path: '/globalSearch',
  266. name: 'GlobalSearch',
  267. component: () => import(/* webpackChunkName: "globalSearch" */ '../views/GlobalSearch.vue'),
  268. meta: {
  269. keepAlive: false,
  270. showTabbar: false,
  271. hideNarBar: true,
  272. },
  273. },
  274. // 设备详情页
  275. {
  276. path: '/assetDetail',
  277. name: 'AssetDetail',
  278. component: () => import(/* webpackChunkName: "assetDetail" */ '../views/AssetDetail.vue'),
  279. meta: {
  280. keepAlive: false,
  281. showTabbar: false,
  282. hideNarBar: true,
  283. },
  284. },
  285. // 重要维修及重要维保
  286. {
  287. path: '/maintenanceRecordView',
  288. name: 'MaintenanceRecordView',
  289. component: () => import(/* webpackChunkName: "MaintenanceRecordView" */ '../views/equipmentFacilities/MaintenanceRecordView.vue'),
  290. meta: {
  291. keepAlive: true,
  292. showTabbar: false,
  293. hideNarBar: true,
  294. },
  295. },
  296. // 重要维修及重要维保详情页
  297. {
  298. path: '/maintenanceRecordDetail',
  299. name: 'MaintenanceRecordDetail',
  300. component: () => import(/* webpackChunkName: "MaintenanceRecordView" */ '../views/equipmentFacilities/MaintenanceRecordDetail.vue'),
  301. meta: {
  302. keepAlive: false,
  303. showTabbar: false,
  304. hideNarBar: true,
  305. },
  306. },
  307. ]
  308. const router = new VueRouter({
  309. mode: 'history',
  310. base: process.env.BASE_URL,
  311. routes,
  312. })
  313. // 跳入路由后要对发送pvuv
  314. router.afterEach((to, from) => {
  315. // console.log(to, from)
  316. // 项目概览,楼层功能,设备设施,其他事项 记录pupv
  317. let pupvArr = ['Overview', 'FloorFunc', 'EquipmentFacilities', 'OtherMatter']
  318. // tabbar对应的四个路由相互切换,发送puuv
  319. // @ts-ignore
  320. if (!pupvArr.includes(to.name) || !pupvArr.includes(from.name)) {
  321. return true
  322. }
  323. let postParams = {
  324. type: 'router',
  325. target: to.name,
  326. parameter: to.path,
  327. app: 'H5',
  328. }
  329. const data = {
  330. plazaId: store.getters['plazaId'],
  331. }
  332. getPvUv(data, postParams)
  333. .then((res: any) => {
  334. // console.log('pvuv', res)
  335. })
  336. .catch((res: any) => {
  337. // console.log('error', res)
  338. })
  339. })
  340. export default router