h5Map.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="pastRoute">
  3. <map-container
  4. ref="mapContainerRef"
  5. toolMapKey="moveAnimation"
  6. @onload="mapOnload"
  7. :pointsData="pointsData"
  8. @handleMarkerClick="handleMarkerClick"
  9. @moving="mapMoving"
  10. >
  11. </map-container>
  12. <view class="options">
  13. <view class="options-item" @click="showSatelliteLayer">
  14. <image
  15. style="width: 100%; height: 100%"
  16. :src="$getImages('/assetsMobile/images/map/icon/weixing.png')"
  17. />
  18. </view>
  19. <view class="options-item" @click="showPanel">
  20. <image
  21. style="width: 100%; height: 100%"
  22. :src="$getImages('/assetsMobile/images/map/icon/boxselection.png')"
  23. />
  24. </view>
  25. <view class="options-item" @click="queryLocation">
  26. <image
  27. style="width: 100%; height: 100%"
  28. :src="$getImages('/assetsMobile/images/map/icon/position.png')"
  29. />
  30. </view>
  31. </view>
  32. <panel ref="panelRef"
  33. @startAnimation="startAnimation"
  34. @pauseAnimation="pauseAnimation"
  35. @resumeAnimation="resumeAnimation"
  36. >
  37. </panel>
  38. <veh-info ref="vehInfoRef" :item="historyItem"></veh-info>
  39. <view class="slider-group" v-if="pointsData.length">
  40. <image style="width: 58rpx; height: 58rpx" v-show="playState === 2 || playState === 0" @click="play" :src="$getImages('/assetsMobile/images/map/icon/track/play.png')" />
  41. <image style="width: 58rpx; height: 58rpx" v-show="playState === 1 || playState === 3" @click="play" :src="$getImages('/assetsMobile/images/map/icon/track/pause.png')" />
  42. <image style="width: 58rpx; height: 58rpx;margin-left: 4rpx;" @click="refresh" :src="$getImages('/assetsMobile/images/map/icon/track/refresh.png')" />
  43. <div class="slider-box">
  44. <!-- disabled -->
  45. <u-slider @input="sliderInput" @change="sliderChange" v-model="progressBar" :min="0" :max="sliderMax" :disabled="sliderMax === 1"></u-slider>
  46. <view class="slider-text">{{formatTooltip}}</view>
  47. </div>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import MapContainer from '@/components/MapContainer'
  53. import panel from './panel.vue' //操作面板
  54. import vehInfo from './vehInfo.vue'
  55. export default {
  56. components: {
  57. MapContainer,
  58. panel,
  59. vehInfo,
  60. },
  61. data() {
  62. return {
  63. progressBar:0,
  64. sliderMax:1,
  65. playState:0,//0未开始 1开始播放中 2暂停播放中 3继续播放中
  66. //卫星图层
  67. isShowStelliteLayer: false,
  68. historyItem: null
  69. }
  70. },
  71. computed: {
  72. pointsData() {
  73. return this.$store.state.pastRoute.trackRecordArr;
  74. },
  75. formatTooltip(){
  76. return this.$store.state.pastRoute.trackRecordArr[this.progressBar]?.gpsTime
  77. },
  78. pastRouteParams(){
  79. return this.$store.state.pastRoute.pastRouteParams;
  80. }
  81. },
  82. watch: {
  83. pointsData:{
  84. deep: true,
  85. handler(newVal) {
  86. this.resetAll();
  87. this.$nextTick(() => {
  88. this.sliderMax= newVal.length-1
  89. })
  90. }
  91. },
  92. pastRouteParams: {
  93. immediate: false,
  94. deep: true,
  95. handler(newVal) {
  96. console.log('查询参数更新',this.$store.state.pastRoute.vehStopArr)
  97. if (newVal.parkRecord) {
  98. this.$refs.mapContainerRef.createProjects('createMarker', { list: this.$store.state.pastRoute.vehStopArr, type: 'vehStop' })
  99. }
  100. if (newVal.warning) {
  101. this.$refs.mapContainerRef.createProjects('createMarker', { list: this.$store.state.pastRoute.veAlarmArr, type: 'veAlarm' })
  102. }
  103. }
  104. }
  105. },
  106. onReady () {
  107. console.log('123')
  108. },
  109. methods: {
  110. play(){
  111. if (this.sliderMax === 1) return;
  112. switch (this.playState) {
  113. case 0:
  114. this.startAnimation() //开始播放
  115. this.playState = 1
  116. break;
  117. case 1:
  118. this.pauseAnimation() //暂停
  119. this.playState = 2
  120. break;
  121. case 2:
  122. this.resumeAnimation() //继续
  123. this.playState = 3
  124. break;
  125. case 3:
  126. this.pauseAnimation() //暂停
  127. this.playState = 2
  128. break;
  129. }
  130. },
  131. refresh(){
  132. if (this.sliderMax === 1) return;
  133. this.progressBar = 0
  134. this.sliderInput(0)
  135. this.sliderChange(0)
  136. },
  137. sliderInput(e){
  138. console.log('input',e)
  139. let item = this.pointsData[e]
  140. this.$refs.mapContainerRef.createMoveAlongFn.moveTo({ lnglat: [Number(item.lng02), Number(item.lat02)], angle: item.direction, index: e })
  141. },
  142. sliderChange(e){
  143. console.log('change',e)
  144. let item = this.pointsData[e]
  145. this.$refs.mapContainerRef.createMoveAlongFn.moveTo({ lnglat: [Number(item.lng02), Number(item.lat02)], angle: item.direction, index: e })
  146. this.playState = 1
  147. this.startAnimation()
  148. },
  149. resetAll(){
  150. this.playState = 0
  151. this.progressBar = 0
  152. this.sliderMax = 1
  153. },
  154. mapMoving(e){
  155. console.log('mapMoving',e)
  156. this.progressBar=e.index
  157. },
  158. // 查询自身位置
  159. queryLocation() {
  160. uni.getLocation({
  161. type: "gcj02",
  162. success: (res) => {
  163. const {latitude,longitude} = res
  164. this.$refs.mapContainerRef.setZoomAndCenter(12,[longitude,latitude],true)
  165. },
  166. fail: (res) => {
  167. console.log('定位失败',JSON.stringify(res));
  168. }
  169. });
  170. },
  171. //操作面板
  172. showPanel() {
  173. this.$refs.panelRef.show()
  174. },
  175. //展示卫星图层
  176. showSatelliteLayer() {
  177. this.isShowStelliteLayer = !this.isShowStelliteLayer
  178. if(this.$refs.mapContainerRef) this.$refs.mapContainerRef.setStelliteLayer(this.isShowStelliteLayer)
  179. },
  180. //点击标注点
  181. handleMarkerClick(e,key) {
  182. console.log('修改车辆弹框',e)
  183. let item = this.$store.state.pastRoute.trackRecordArr[e.index]
  184. this.historyItem = item
  185. // console.log(item,'handleMarkerClick')
  186. if(key == 'click') {
  187. this.$refs.vehInfoRef.show()
  188. }
  189. },
  190. startAnimation() {
  191. console.log('重新开始')
  192. // console.log( this.$refs.mapContainerRef,' this.$refs.mapContainerRef.createMoveAlongFn')
  193. this.$refs.mapContainerRef.createMoveAlongFn.startAnimation()
  194. },
  195. pauseAnimation() {
  196. console.log('暂停')
  197. this.$refs.mapContainerRef.createMoveAlongFn.pauseAnimation()
  198. },
  199. resumeAnimation() {
  200. console.log('继续')
  201. this.$refs.mapContainerRef.createMoveAlongFn.resumeAnimation()
  202. },
  203. mapOnload() {
  204. },
  205. },
  206. beforeDestroy() {
  207. this.$store.dispatch('setTrackRecordArr',[])
  208. }
  209. }
  210. </script>
  211. <style lang="scss" scoped>
  212. .pastRoute {
  213. width: 100%;
  214. height: 100vh;
  215. position: relative;
  216. #map {
  217. width: 750rpx;
  218. height: 100%;
  219. }
  220. .options {
  221. position: absolute;
  222. width: 72rpx;
  223. right: 30rpx;
  224. bottom: 156rpx;
  225. // box-shadow: 0px 3px 30px 0px rgba(0, 0, 0, 0.15);
  226. z-index: 9999;
  227. .options-item {
  228. height: 72rpx;
  229. }
  230. .options-item+.options-item{
  231. margin-top: 20rpx;
  232. }
  233. }
  234. .slider-group{
  235. position: fixed;
  236. bottom: 12rpx;
  237. // top: 0;
  238. width: 96%;
  239. padding: 22rpx 22rpx;
  240. background: #E5F2FF;
  241. margin-left: 2%;
  242. border-radius: 12rpx;
  243. margin-top: 24rpx;
  244. display: flex;
  245. align-items: center;
  246. box-sizing: border-box;
  247. .slider-box {
  248. flex: 1;
  249. margin-left: 2rpx;
  250. // transform: scale(0.88);
  251. position: relative;
  252. .slider-text{
  253. position: absolute;
  254. left: 32rpx;
  255. bottom: -20rpx;
  256. color: #888;
  257. font-size: 28rpx;
  258. }
  259. }
  260. }
  261. }
  262. </style>