regionmap.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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="width: 100%; height: 600px;" :latitude="latitude" :longitude="longitude" :markers="markets"
  20. enable-zoom="true" :polygons="polygons" :scale="scale">
  21. </map>
  22. </view>
  23. <!-- <view class="item-button-group">
  24. <view v-for="item in areaList" :key="item.id" class="item-button" @click="onAreaClick(item)">
  25. <view class="items-line">
  26. <uni-icons class="input-uni-icon" type="close" size="18" color="coral" />
  27. <text class="button-text">{{ item.name }}</text>
  28. </view>
  29. </view>
  30. </view> -->
  31. </view>
  32. </view>
  33. </template>
  34. <!-- <script src="../../static/js/gcoord.global.prod.js" type="module"></script> -->
  35. <script>
  36. import {
  37. gcoord
  38. } from '@/static/js/gcoord.global.prod.js'
  39. import http from '@/http/api.js';
  40. import {
  41. pathToBase64,
  42. base64ToPath
  43. } from '@/js_sdk/mmmm-image-tools/index.js';
  44. import {
  45. oss,
  46. devUrl,
  47. prodUrl
  48. } from '@/common/setting';
  49. export default {
  50. components: {
  51. },
  52. onLoad(options) {
  53. this.id = options.id;
  54. this.baseURL = process.env.NODE_ENV === 'development' ? devUrl : prodUrl;
  55. let that = this;
  56. let postData = {};
  57. postData['id'] = this.id;
  58. http.request({
  59. url: '/galaxy-business/map/region/detail',
  60. method: 'GET',
  61. data: postData
  62. }).then(res => {
  63. console.log(res)
  64. if (res.data != null) {
  65. let p = {};
  66. let ps = res.data.points.map(item => {
  67. let l = gcoord.transform(
  68. [item.pointLng, item.pointLat],
  69. gcoord.WGS84,
  70. gcoord.GCJ02
  71. );
  72. return {
  73. latitude: l[1],
  74. longitude: l[0],
  75. }
  76. })
  77. p['points'] = ps;
  78. let dashArray = [];
  79. dashArray.push(4);
  80. dashArray.push(10);
  81. p['dashArray'] = dashArray;
  82. p['strokeWidth'] = 2;
  83. p['strokeColor'] = '#EE1ADC';
  84. //p['fillColor'] = '#FAC8587D';
  85. that.polygons.push(p);
  86. let c = gcoord.transform(
  87. [res.data.centerPointLng, res.data.centerPointLat],
  88. gcoord.WGS84,
  89. gcoord.GCJ02
  90. );
  91. console.log(c)
  92. that.latitude = c[1];
  93. that.longitude = c[0];
  94. that.scale = 8;
  95. }
  96. }).catch(err => {
  97. console.log(err)
  98. })
  99. },
  100. data() {
  101. return {
  102. title: '地图测试',
  103. id: 0,
  104. title: 'map',
  105. areaList: [],
  106. areaIndex: 0,
  107. latitude: 40.848119,
  108. longitude: 111.755426,
  109. zoom: true,
  110. scale: 8,
  111. markets: [],
  112. polygons: [],
  113. }
  114. },
  115. computed: {
  116. },
  117. onShow() {
  118. },
  119. created() {
  120. },
  121. methods: {
  122. toOss(path) {
  123. return oss + path;
  124. },
  125. toBack() {
  126. uni.navigateBack({
  127. delta: 1
  128. })
  129. },
  130. onAreaClick(item) {
  131. let p = {};
  132. p['points'] = item.data;
  133. let dashArray = [];
  134. dashArray.push(10);
  135. dashArray.push(10);
  136. p['dashArray'] = dashArray;
  137. p['strokeColor'] = '#FFF';
  138. p['fillColor'] = '#A500337D';
  139. this.polygons = [];
  140. this.polygons.push(p);
  141. let center = item.center;
  142. this.latitude = center[1];
  143. this.longitude = center[0];
  144. },
  145. }
  146. }
  147. </script>
  148. <style>
  149. /* page {
  150. background-color: rgb(240, 242, 244);
  151. } */
  152. .uni-body {
  153. font-size: 0.7rem;
  154. }
  155. </style>