Location-fa750809.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import { d as defineComponent, r as ref, w as watch, o as onMounted, b as createElementBlock, c as createVNode, B as unref, e as createBaseVNode, t as toDisplayString, u as useRouter, j as openBlock } from "./index-5e4623ce.js";
  2. import { p as post_promise } from "./index-18735c56.js";
  3. import { C as CusNavigation } from "./CusNavigation-87012716.js";
  4. import { s as showToast } from "./function-call-dc072a29.js";
  5. import "./axios-8cd254ce.js";
  6. import "./index-487cde8c.js";
  7. import "./index-eef3af38.js";
  8. import "./use-scope-id-0b5b8615.js";
  9. import "./on-popup-reopen-c5ca1603.js";
  10. import "./mount-component-2b0f7b23.js";
  11. import "./index-217c49a0.js";
  12. const _hoisted_1 = { style: { "display": "flex", "flex-direction": "column", "height": "100vh" } };
  13. const _hoisted_2 = {
  14. class: "container",
  15. style: { "overflow-y": "auto", "flex-grow": "1", "background-color": "#F7F8FA" }
  16. };
  17. const _hoisted_3 = { style: { "height": "100%", "position": "relative" } };
  18. const _hoisted_4 = { style: { "position": "absolute", "width": "100%", "z-index": "99999999", "border-top-left-radius": "20px", "border-top-right-radius": "20px", "background-color": "#fff", "border-top": "2px solid #eee", "bottom": "0px" } };
  19. const _hoisted_5 = { style: { "padding": "30px 40px" } };
  20. const _hoisted_6 = { style: { "display": "flex", "align-items": "flex-end" } };
  21. const _hoisted_7 = { style: { "font-weight": "bold" } };
  22. const _hoisted_8 = { style: { "display": "flex", "align-items": "flex-end", "margin-top": "5px" } };
  23. const _hoisted_9 = { style: { "font-weight": "bold" } };
  24. const _hoisted_10 = { style: { "display": "flex", "align-items": "flex-end", "margin-top": "5px" } };
  25. const _hoisted_11 = { style: { "font-weight": "bold" } };
  26. const _hoisted_12 = { style: { "display": "flex", "align-items": "flex-start", "margin-top": "5px" } };
  27. const _hoisted_13 = { style: { "font-weight": "bold", "width": "0px", "flex-grow": "1" } };
  28. const _sfc_main = /* @__PURE__ */ defineComponent({
  29. __name: "Location",
  30. setup(__props) {
  31. const BMap = window.BMapGL;
  32. const map = ref(null);
  33. const init_map = () => {
  34. if (map.value) {
  35. return;
  36. }
  37. map.value = new BMap.Map("map_1");
  38. map.value.centerAndZoom(new BMap.Point(116.404, 39.915), 15);
  39. map.value.enableScrollWheelZoom(true);
  40. };
  41. const update_map = () => {
  42. var _a, _b, _c, _d;
  43. console.log(device.value);
  44. map.value.clearOverlays();
  45. if (((_a = device.value) == null ? void 0 : _a.data.lat) && ((_b = device.value) == null ? void 0 : _b.data.lng)) {
  46. const lng = (_c = device.value) == null ? void 0 : _c.data.lng.value;
  47. const lat = (_d = device.value) == null ? void 0 : _d.data.lat.value;
  48. let point = new BMap.Point(lng, lat);
  49. console.log(lng, lat);
  50. let marker1 = new BMap.Marker(point);
  51. let circle = new BMap.Circle(point, 500, {
  52. strokeColor: "red",
  53. strokeWeight: 1,
  54. strokeOpacity: 1,
  55. fillOpacity: 0
  56. });
  57. map.value.addOverlay(marker1);
  58. map.value.addOverlay(circle);
  59. setTimeout(() => {
  60. map.value.setCenter(point);
  61. }, 300);
  62. } else {
  63. console.log("hhhh");
  64. showToast({ message: "暂无定位" });
  65. }
  66. };
  67. const device = ref();
  68. const refreshList = async () => {
  69. await post_promise({ url: "/device/search", data: {
  70. size: 200,
  71. page: 1,
  72. sort: "createtime",
  73. order: "desc",
  74. keyWord: deviceId.value
  75. } }).then((result) => {
  76. if (result.data[0]) {
  77. device.value = result.data[0];
  78. device.value.data = JSON.parse(result.data[0].data);
  79. console.log(device.value);
  80. } else {
  81. showToast("设备不存在");
  82. }
  83. });
  84. };
  85. const router = useRouter();
  86. const deviceId = ref("");
  87. watch(() => router.currentRoute.value.params, async (newParams, oldParams) => {
  88. console.log("路由参数发生了变化", newParams, oldParams);
  89. if (newParams.deviceId) {
  90. deviceId.value = newParams.deviceId;
  91. await refreshList();
  92. init_map();
  93. update_map();
  94. }
  95. });
  96. onMounted(async () => {
  97. console.log("deviceDetail onMounted");
  98. deviceId.value = router.currentRoute.value.params.deviceId;
  99. await refreshList();
  100. init_map();
  101. update_map();
  102. });
  103. return (_ctx, _cache) => {
  104. var _a, _b, _c, _d, _e, _f, _g, _h, _i;
  105. return openBlock(), createElementBlock("div", _hoisted_1, [
  106. createVNode(unref(CusNavigation), {
  107. gobackabled: "",
  108. title: "设备位置"
  109. }),
  110. createBaseVNode("div", _hoisted_2, [
  111. createBaseVNode("div", _hoisted_3, [
  112. _cache[4] || (_cache[4] = createBaseVNode("div", {
  113. id: "map_1",
  114. style: { "height": "100%", "background-color": "#aaa" }
  115. }, null, -1)),
  116. createBaseVNode("div", _hoisted_4, [
  117. createBaseVNode("div", _hoisted_5, [
  118. createBaseVNode("div", _hoisted_6, [
  119. _cache[0] || (_cache[0] = createBaseVNode("div", { style: { "width": "80px", "color": "#969799", "font-size": "0.9rem" } }, [
  120. createBaseVNode("span", null, "设备编号:")
  121. ], -1)),
  122. createBaseVNode("div", _hoisted_7, [
  123. createBaseVNode("span", null, toDisplayString(deviceId.value), 1)
  124. ])
  125. ]),
  126. createBaseVNode("div", _hoisted_8, [
  127. _cache[1] || (_cache[1] = createBaseVNode("div", { style: { "width": "80px", "color": "#969799", "font-size": "0.9rem" } }, [
  128. createBaseVNode("span", null, "坐标(lng):")
  129. ], -1)),
  130. createBaseVNode("div", _hoisted_9, [
  131. createBaseVNode("span", null, [
  132. createBaseVNode("span", null, toDisplayString((_c = (_b = (_a = device.value) == null ? void 0 : _a.data) == null ? void 0 : _b.lng) == null ? void 0 : _c.value), 1)
  133. ])
  134. ])
  135. ]),
  136. createBaseVNode("div", _hoisted_10, [
  137. _cache[2] || (_cache[2] = createBaseVNode("div", { style: { "width": "80px", "color": "#969799", "font-size": "0.9rem" } }, [
  138. createBaseVNode("span", null, "坐标(lat):")
  139. ], -1)),
  140. createBaseVNode("div", _hoisted_11, [
  141. createBaseVNode("span", null, [
  142. createBaseVNode("span", null, toDisplayString((_f = (_e = (_d = device.value) == null ? void 0 : _d.data) == null ? void 0 : _e.lat) == null ? void 0 : _f.value), 1)
  143. ])
  144. ])
  145. ]),
  146. createBaseVNode("div", _hoisted_12, [
  147. _cache[3] || (_cache[3] = createBaseVNode("div", { style: { "width": "80px", "color": "#969799", "font-size": "0.9rem" } }, [
  148. createBaseVNode("span", null, "地址:")
  149. ], -1)),
  150. createBaseVNode("div", _hoisted_13, [
  151. createBaseVNode("span", null, toDisplayString((_i = (_h = (_g = device.value) == null ? void 0 : _g.data) == null ? void 0 : _h.address) == null ? void 0 : _i.value), 1)
  152. ])
  153. ])
  154. ])
  155. ])
  156. ])
  157. ])
  158. ]);
  159. };
  160. }
  161. });
  162. export {
  163. _sfc_main as default
  164. };