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"; import { p as post_promise } from "./index-18735c56.js"; import { C as CusNavigation } from "./CusNavigation-87012716.js"; import { s as showToast } from "./function-call-dc072a29.js"; import "./axios-8cd254ce.js"; import "./index-487cde8c.js"; import "./index-eef3af38.js"; import "./use-scope-id-0b5b8615.js"; import "./on-popup-reopen-c5ca1603.js"; import "./mount-component-2b0f7b23.js"; import "./index-217c49a0.js"; const _hoisted_1 = { style: { "display": "flex", "flex-direction": "column", "height": "100vh" } }; const _hoisted_2 = { class: "container", style: { "overflow-y": "auto", "flex-grow": "1", "background-color": "#F7F8FA" } }; const _hoisted_3 = { style: { "height": "100%", "position": "relative" } }; 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" } }; const _hoisted_5 = { style: { "padding": "30px 40px" } }; const _hoisted_6 = { style: { "display": "flex", "align-items": "flex-end" } }; const _hoisted_7 = { style: { "font-weight": "bold" } }; const _hoisted_8 = { style: { "display": "flex", "align-items": "flex-end", "margin-top": "5px" } }; const _hoisted_9 = { style: { "font-weight": "bold" } }; const _hoisted_10 = { style: { "display": "flex", "align-items": "flex-end", "margin-top": "5px" } }; const _hoisted_11 = { style: { "font-weight": "bold" } }; const _hoisted_12 = { style: { "display": "flex", "align-items": "flex-start", "margin-top": "5px" } }; const _hoisted_13 = { style: { "font-weight": "bold", "width": "0px", "flex-grow": "1" } }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "Location", setup(__props) { const BMap = window.BMapGL; const map = ref(null); const init_map = () => { if (map.value) { return; } map.value = new BMap.Map("map_1"); map.value.centerAndZoom(new BMap.Point(116.404, 39.915), 15); map.value.enableScrollWheelZoom(true); }; const update_map = () => { var _a, _b, _c, _d; console.log(device.value); map.value.clearOverlays(); if (((_a = device.value) == null ? void 0 : _a.data.lat) && ((_b = device.value) == null ? void 0 : _b.data.lng)) { const lng = (_c = device.value) == null ? void 0 : _c.data.lng.value; const lat = (_d = device.value) == null ? void 0 : _d.data.lat.value; let point = new BMap.Point(lng, lat); console.log(lng, lat); let marker1 = new BMap.Marker(point); let circle = new BMap.Circle(point, 500, { strokeColor: "red", strokeWeight: 1, strokeOpacity: 1, fillOpacity: 0 }); map.value.addOverlay(marker1); map.value.addOverlay(circle); setTimeout(() => { map.value.setCenter(point); }, 300); } else { console.log("hhhh"); showToast({ message: "暂无定位" }); } }; const device = ref(); const refreshList = async () => { await post_promise({ url: "/device/search", data: { size: 200, page: 1, sort: "createtime", order: "desc", keyWord: deviceId.value } }).then((result) => { if (result.data[0]) { device.value = result.data[0]; device.value.data = JSON.parse(result.data[0].data); console.log(device.value); } else { showToast("设备不存在"); } }); }; const router = useRouter(); const deviceId = ref(""); watch(() => router.currentRoute.value.params, async (newParams, oldParams) => { console.log("路由参数发生了变化", newParams, oldParams); if (newParams.deviceId) { deviceId.value = newParams.deviceId; await refreshList(); init_map(); update_map(); } }); onMounted(async () => { console.log("deviceDetail onMounted"); deviceId.value = router.currentRoute.value.params.deviceId; await refreshList(); init_map(); update_map(); }); return (_ctx, _cache) => { var _a, _b, _c, _d, _e, _f, _g, _h, _i; return openBlock(), createElementBlock("div", _hoisted_1, [ createVNode(unref(CusNavigation), { gobackabled: "", title: "设备位置" }), createBaseVNode("div", _hoisted_2, [ createBaseVNode("div", _hoisted_3, [ _cache[4] || (_cache[4] = createBaseVNode("div", { id: "map_1", style: { "height": "100%", "background-color": "#aaa" } }, null, -1)), createBaseVNode("div", _hoisted_4, [ createBaseVNode("div", _hoisted_5, [ createBaseVNode("div", _hoisted_6, [ _cache[0] || (_cache[0] = createBaseVNode("div", { style: { "width": "80px", "color": "#969799", "font-size": "0.9rem" } }, [ createBaseVNode("span", null, "设备编号:") ], -1)), createBaseVNode("div", _hoisted_7, [ createBaseVNode("span", null, toDisplayString(deviceId.value), 1) ]) ]), createBaseVNode("div", _hoisted_8, [ _cache[1] || (_cache[1] = createBaseVNode("div", { style: { "width": "80px", "color": "#969799", "font-size": "0.9rem" } }, [ createBaseVNode("span", null, "坐标(lng):") ], -1)), createBaseVNode("div", _hoisted_9, [ createBaseVNode("span", null, [ 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) ]) ]) ]), createBaseVNode("div", _hoisted_10, [ _cache[2] || (_cache[2] = createBaseVNode("div", { style: { "width": "80px", "color": "#969799", "font-size": "0.9rem" } }, [ createBaseVNode("span", null, "坐标(lat):") ], -1)), createBaseVNode("div", _hoisted_11, [ createBaseVNode("span", null, [ 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) ]) ]) ]), createBaseVNode("div", _hoisted_12, [ _cache[3] || (_cache[3] = createBaseVNode("div", { style: { "width": "80px", "color": "#969799", "font-size": "0.9rem" } }, [ createBaseVNode("span", null, "地址:") ], -1)), createBaseVNode("div", _hoisted_13, [ 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) ]) ]) ]) ]) ]) ]) ]); }; } }); export { _sfc_main as default };