leavelinemap.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!--
  2. * @Title:
  3. * @Description: 转移路线地图信息
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <view class="container">
  11. <uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
  12. @clickLeft="toBack">
  13. <view class="nav-title">
  14. <text>{{title}}</text>
  15. </view>
  16. </uni-nav-bar>
  17. <view class="page-body">
  18. <view class="page-section page-section-gap">
  19. <map :style="mapStyles" :latitude="latitude" :longitude="longitude" :markers="markets"
  20. enable-zoom="true" :polyline="polylines" :scale="scale">
  21. </map>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. gcoord
  29. } from '@/static/js/gcoord.global.prod.js'
  30. import http from '@/http/api.js';
  31. import {
  32. pathToBase64,
  33. base64ToPath
  34. } from '@/js_sdk/mmmm-image-tools/index.js';
  35. import {
  36. oss,
  37. devUrl,
  38. prodUrl
  39. } from '@/common/setting';
  40. export default {
  41. components: {
  42. },
  43. data() {
  44. return {
  45. title: '转移路线地图',
  46. id: 0,
  47. areaList: [],
  48. areaIndex: 0,
  49. latitude: 40.848119,
  50. longitude: 111.755426,
  51. zoom: true,
  52. scale: 16,
  53. markets: [],
  54. polylines: [],
  55. mapStyles: {
  56. width: '100%',
  57. height: '600px'
  58. },
  59. }
  60. },
  61. computed: {
  62. },
  63. onShow() {
  64. },
  65. onLoad(options) {
  66. this.mapStyles.height = (uni.getWindowInfo().windowHeight - 50) + "px";
  67. this.id = options.id;
  68. this.baseURL = process.env.NODE_ENV === 'development' ? devUrl : prodUrl;
  69. let that = this;
  70. let postData = {};
  71. postData['id'] = this.id;
  72. http.request({
  73. url: '/galaxy-business/map/leaveline/detail',
  74. method: 'GET',
  75. data: postData
  76. }).then(res => {
  77. console.log(res)
  78. if (res.data != null) {
  79. let p = {};
  80. let ps = res.data.points.map(item => {
  81. let l = gcoord.transform(
  82. [item.pointLng, item.pointLat],
  83. gcoord.WGS84,
  84. gcoord.GCJ02
  85. );
  86. return {
  87. latitude: l[1],
  88. longitude: l[0],
  89. }
  90. })
  91. p['points'] = ps;
  92. p['color'] = '#EE6666';
  93. that.polylines.push(p);
  94. let c = gcoord.transform(
  95. [res.data.centerPointLng, res.data.centerPointLat],
  96. gcoord.WGS84,
  97. gcoord.GCJ02
  98. );
  99. console.log(c)
  100. that.latitude = c[1];
  101. that.longitude = c[0];
  102. that.scale = 16;
  103. }
  104. }).catch(err => {
  105. console.log(err)
  106. })
  107. },
  108. methods: {
  109. toBack() {
  110. uni.navigateBack({
  111. delta: 1
  112. })
  113. },
  114. }
  115. }
  116. </script>
  117. <style>
  118. .uni-body {
  119. font-size: 0.7rem;
  120. }
  121. </style>