viewRoute.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="page-container">
  3. <map-container
  4. ref="mapContainerRef"
  5. @onload="handleOnload"
  6. :markerClusterOptions="{
  7. maxZoom: 1,
  8. }"
  9. >
  10. </map-container>
  11. </view>
  12. </template>
  13. <script>
  14. import MapContainer from '@/components/MapContainer'
  15. import {routeDetail} from '@/api/common/system.js'
  16. import {isEmpty} from 'lodash'
  17. export default {
  18. components: {
  19. MapContainer,
  20. },
  21. computed: {
  22. },
  23. data() {
  24. return {
  25. id: '',
  26. pointList: [],
  27. }
  28. },
  29. onLoad(option) {
  30. const {id} = option
  31. if(id) {
  32. this.id = id
  33. }
  34. },
  35. onShow() {
  36. },
  37. onHide() {
  38. },
  39. onReady() {
  40. },
  41. methods: {
  42. async getRouteDetail(id) {
  43. let {code,data} = await routeDetail({id})
  44. if(code == 0) {
  45. this.pointList = data.pointList
  46. if(!isEmpty(this.pointList)) {
  47. let getPath = []
  48. this.pointList.forEach((item) => {
  49. getPath.push([item.lng,item.lat])
  50. })
  51. if(this.$refs.mapContainerRef) {
  52. let polyline = this.$refs.mapContainerRef.createPolyline(getPath,{
  53. })
  54. this.$refs.mapContainerRef.setFitView(polyline, false, [40, 200, 20, 20])
  55. }
  56. }
  57. }
  58. },
  59. handleOnload(map) {
  60. this.map = map
  61. this.getRouteDetail(this.id)
  62. },
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .page-container {
  68. background: #fff;
  69. font-size: 28rpx;
  70. height: 100vh;
  71. position: relative;
  72. .footer {
  73. padding: 10rpx 0;
  74. position: fixed;
  75. width: 100%;
  76. left: 0;
  77. bottom: 0;
  78. }
  79. }
  80. ::v-deep {
  81. .u-form-item__body {
  82. padding: 0;
  83. }
  84. .hidde-cell-title {
  85. .u-cell__body__content {
  86. width: auto;
  87. flex: none;
  88. }
  89. .u-cell__body {
  90. .value {
  91. flex: 1;
  92. }
  93. }
  94. }
  95. }
  96. </style>