dangerareamap.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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/dangerarea/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. if (res.data.dangerStatus == '1') {
  83. // p['strokeColor'] = '#EE6666';
  84. p['strokeColor'] = '#FF0000';
  85. p['fillColor'] = '#F72C5B7D';
  86. } else {
  87. p['strokeColor'] = '#FC8452';
  88. p['fillColor'] = '#FAC8587D';
  89. }
  90. that.polygons.push(p);
  91. let c = gcoord.transform(
  92. [res.data.centerPointLng, res.data.centerPointLat],
  93. gcoord.WGS84,
  94. gcoord.GCJ02
  95. );
  96. console.log(c)
  97. that.latitude = c[1];
  98. that.longitude = c[0];
  99. let marketPoints = res.data.rtus.map(item => {
  100. console.log(JSON.stringify(item))
  101. let rtu = {};
  102. rtu['iconPath'] = '/static/images/icon_warning.png';
  103. rtu['id'] = parseInt(item.id);
  104. let r = gcoord.transform(
  105. [parseFloat(item.lng), parseFloat(item.lat)],
  106. gcoord.WGS84,
  107. gcoord.GCJ02
  108. );
  109. rtu['latitude'] = r[1];
  110. rtu['longitude'] = r[0];
  111. rtu['width'] = 20;
  112. rtu['height'] = 20;
  113. let label = {};
  114. label['content'] = item.rtuName;
  115. label['color'] = '#ff0000';
  116. label['bgColor'] = '#ffffff';
  117. label['anchorY'] = -40;
  118. rtu['label'] = label;
  119. return rtu;
  120. });
  121. that.markets = marketPoints;
  122. that.scale = 14;
  123. }
  124. }).catch(err => {
  125. console.log(err)
  126. })
  127. },
  128. data() {
  129. return {
  130. title: '地图测试',
  131. id: 0,
  132. title: 'map',
  133. areaList: [],
  134. areaIndex: 0,
  135. latitude: 40.848119,
  136. longitude: 111.755426,
  137. zoom: true,
  138. scale: 14,
  139. markets: [],
  140. polygons: [],
  141. }
  142. },
  143. computed: {
  144. },
  145. onShow() {
  146. },
  147. created() {
  148. },
  149. methods: {
  150. toOss(path) {
  151. return oss + path;
  152. },
  153. toBack() {
  154. uni.navigateBack({
  155. delta: 1
  156. })
  157. },
  158. onAreaClick(item) {
  159. let p = {};
  160. p['points'] = item.data;
  161. let dashArray = [];
  162. dashArray.push(10);
  163. dashArray.push(10);
  164. p['dashArray'] = dashArray;
  165. p['strokeColor'] = '#FFF';
  166. p['fillColor'] = '#A500337D';
  167. this.polygons = [];
  168. this.polygons.push(p);
  169. let center = item.center;
  170. this.latitude = center[1];
  171. this.longitude = center[0];
  172. },
  173. }
  174. }
  175. </script>
  176. <style>
  177. /* page {
  178. background-color: rgb(240, 242, 244);
  179. } */
  180. .uni-body {
  181. font-size: 0.7rem;
  182. }
  183. </style>