index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="receivedBox">
  3. <view class="container">
  4. <map
  5. class="mapBox"
  6. :latitude="latitude"
  7. :longitude="longitude"
  8. :polygons="covers"
  9. :scale="scale"
  10. id="map"
  11. ref="map"
  12. >
  13. </map>
  14. <SlideCard>
  15. <view class="titleBox">
  16. <view class="search">
  17. <input
  18. v-model="dkbhModel"
  19. placeholder-class="address"
  20. class="input"
  21. type="text"
  22. placeholder="请输入地块编号"
  23. />
  24. </view>
  25. <view class="searchBtn" @click="queryClick()">
  26. <image class="icon" src="../../static/images/search.png"></image>
  27. </view>
  28. </view>
  29. <scroll-view scroll-y="true" class="scroll-view_H" lower-threshold="50">
  30. <view
  31. class="cardBox"
  32. @click="cardBoxClick(item, index)"
  33. v-for="(item, index) in listData"
  34. :key="index"
  35. >
  36. <view class="cardBoxTitle">
  37. <view class="titleOne">
  38. <view class="x1">{{ index + 1 }}</view>
  39. <view class="x2">{{ item.dkbh }}</view>
  40. </view>
  41. <view class="citys">
  42. <image class="icon" src="../../static/images/citys.png"></image>
  43. <view class="x1">{{ item.dkwz }}</view>
  44. </view>
  45. </view>
  46. <div class="cardBoxContent">
  47. <view class="x1"> 管地单位:{{ item.gddw }} </view>
  48. <view class="x1"> 地块面积:{{ item.mj }} 亩 </view>
  49. <view class="x1"> 上次巡查时间:{{ item.xcsj }} </view>
  50. </div>
  51. <div class="cardBoxBtns">
  52. <view class="btn btn1" @click.stop="toDetailHandle(item)">
  53. <image class="icon" src="../../static/images/xcxq.png"></image>
  54. <view class="x1">详情</view>
  55. </view>
  56. <view class="btn btn2" @click.stop="toDetailHandle1(item)">
  57. <image
  58. class="icon"
  59. src="../../static/images/xuncha.png"
  60. ></image>
  61. <view class="x1">巡查</view>
  62. </view>
  63. </div>
  64. </view>
  65. </scroll-view>
  66. </SlideCard>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import SlideCard from '../../components/SlideCard/SlideCard.vue';
  72. import CustomMixins from '@/mixins/CustomMixins.js';
  73. import httpAjax from '@/utils/https.js';
  74. import config from '@/utils/config.js';
  75. export default {
  76. mixins: [CustomMixins],
  77. components: {
  78. SlideCard,
  79. },
  80. data() {
  81. return {
  82. dkbhModel: '',
  83. scale: 12,
  84. id: 0, // 使用 marker点击事件 需要填写id
  85. title: 'map',
  86. latitude: 30.131,
  87. longitude: 120.19308,
  88. covers: [],
  89. count: 0,
  90. listData: [],
  91. scrollTop: 0,
  92. pageNo: 1, //当前页
  93. pageSize: 10, //每页显示多少条
  94. isRequest: true, //是否请求 是 true,否 false
  95. detailData: {},
  96. mapObj: null,
  97. };
  98. },
  99. mounted() {
  100. this.queryWarningPage();
  101. this.mapObj = uni.createMapContext('map');
  102. },
  103. methods: {
  104. cardBoxClick(item, index) {
  105. // let s = dksyhArr.map((item) => `'${item}'`).join(",");
  106. // let url = config.bjdkgl + '/0/query?dksyh=' + item.dksyh;
  107. let params = {
  108. where: 'dksyh=' + item.dksyh,
  109. };
  110. let where =
  111. '?where=dksyh%3D%27' +
  112. item.dksyh +
  113. '%27&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson';
  114. let url = config.bjdkgl + '/0/query';
  115. // let whereStr = `1=1 and dksyh in (${s})`;
  116. uni
  117. .request({
  118. url: url + where,
  119. method: 'GET',
  120. })
  121. .then((result) => {
  122. let arr = result[1].data.features[0].geometry.rings[0];
  123. let newArr = [];
  124. arr.forEach((item, index) => {
  125. let obj = {
  126. latitude: item[1],
  127. longitude: item[0],
  128. };
  129. newArr.push(obj);
  130. });
  131. let center = this.calculateCenter(newArr);
  132. // this.latitude = newArr[0].latitude - (Math.random() / 100000 + 0.008);
  133. // this.longitude = newArr[0].longitude;
  134. this.latitude = center.lat - 0.007;
  135. this.longitude = center.lng;
  136. this.scale = 15.3 + (Math.random() + 1) / 1000;
  137. this.covers = [
  138. {
  139. // dashArray: Math.random(),
  140. points: newArr,
  141. strokeColor: '#ff0000',
  142. fillColor: '#ff0000',
  143. zIndex: 100,
  144. strokeWidth: 2,
  145. },
  146. ];
  147. });
  148. },
  149. // 取面对象 中心点
  150. calculateCenter(lnglatarr) {
  151. var total = lnglatarr.length;
  152. var X = 0,
  153. Y = 0,
  154. Z = 0;
  155. lnglatarr.forEach(function (lnglat) {
  156. var lng = (lnglat.longitude * Math.PI) / 180;
  157. var lat = (lnglat.latitude * Math.PI) / 180;
  158. var x, y, z;
  159. x = Math.cos(lat) * Math.cos(lng);
  160. y = Math.cos(lat) * Math.sin(lng);
  161. z = Math.sin(lat);
  162. X += x;
  163. Y += y;
  164. Z += z;
  165. });
  166. X = X / total;
  167. Y = Y / total;
  168. Z = Z / total;
  169. var Lng = Math.atan2(Y, X);
  170. var Hyp = Math.sqrt(X * X + Y * Y);
  171. var Lat = Math.atan2(Z, Hyp);
  172. console.log(Lng, Lat, Hyp);
  173. return { lng: (Lng * 180) / Math.PI, lat: (Lat * 180) / Math.PI };
  174. },
  175. queryClick() {
  176. this.queryWarningPage();
  177. },
  178. location(val) {
  179. const sendData = {
  180. id: val.id,
  181. };
  182. httpAjax({
  183. url: 'app-api/mining/app/task',
  184. method: 'GET',
  185. data: sendData,
  186. })
  187. .then((result) => {
  188. const data = result['data'];
  189. this.latitude = data.lat - (Math.random() / 100000 + 0.004);
  190. this.longitude = data.lng;
  191. this.scale = 15.3 + (Math.random() + 1) / 1000;
  192. this.covers = [
  193. {
  194. id: Math.random(),
  195. latitude: data.lat,
  196. longitude: data.lng,
  197. width: 18,
  198. height: 25,
  199. iconPath: '../../static/images/location.png',
  200. },
  201. ];
  202. })
  203. .catch((err) => {
  204. console.error('');
  205. });
  206. },
  207. toDetailHandle(item) {
  208. uni.navigateTo({
  209. url: `/pages/receivedDetail/index?obj=${JSON.stringify(item)}`,
  210. });
  211. },
  212. toDetailHandle1(item) {
  213. uni.navigateTo({
  214. url: `/pages/nocheckDetail/index?obj=${JSON.stringify(item)}`,
  215. });
  216. },
  217. scrollHandle() {
  218. if (this.isRequest) {
  219. this.pageNo += 1;
  220. this.queryWarningPage();
  221. }
  222. },
  223. queryWarningPage() {
  224. if (!this.isRequest) return;
  225. const sendData = {
  226. dkbh: this.dkbhModel,
  227. xcryId: uni.getStorageSync('userInfo').id,
  228. // xcryId: '11e77c7e53b2730407fd3e481b2d6558',
  229. };
  230. httpAjax({
  231. url: 'app/xc/getXcryDkList',
  232. method: 'GET',
  233. data: sendData,
  234. })
  235. .then((result) => {
  236. if (result.data) {
  237. this.listData = result.data;
  238. this.listData.forEach((item) => {
  239. if (item.lxdh.indexOf('\n') > -1) {
  240. item.lxdh = item.lxdh.replace('\n', '');
  241. }
  242. for (let key in item) {
  243. if (item[key] == null) {
  244. item[key] = '';
  245. }
  246. }
  247. });
  248. console.log(this.listData);
  249. }
  250. })
  251. .catch((err) => {
  252. console.error('');
  253. });
  254. },
  255. queryWarningRegional() {
  256. //查询预警区域分布
  257. if (!this.isRequest) return;
  258. const sendData = {
  259. taskStatus: 1,
  260. };
  261. httpAjax({
  262. url: '/admin-api/mining/deviceWarning/regional',
  263. method: 'GET',
  264. data: sendData,
  265. })
  266. .then((result) => {})
  267. .catch((err) => {
  268. console.error('');
  269. });
  270. },
  271. },
  272. };
  273. </script>
  274. <style lang="scss">
  275. @import './index.scss';
  276. </style>