"use strict"; const common_vendor = require("../../common/vendor.js"); const utils_homeApi = require("../../utils/homeApi.js"); const common_assets = require("../../common/assets.js"); if (!Array) { const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput"); const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup"); const _easycom_uni_popup_dialog2 = common_vendor.resolveComponent("uni-popup-dialog"); (_easycom_uni_easyinput2 + _easycom_uni_popup2 + _easycom_uni_popup_dialog2)(); } const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js"; const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"; const _easycom_uni_popup_dialog = () => "../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.js"; if (!Math) { (_easycom_uni_easyinput + _easycom_uni_popup + _easycom_uni_popup_dialog)(); } const _sfc_main = { __name: "index", setup(__props) { const mapContext = common_vendor.ref(null); const longitude = common_vendor.ref(113.943); const latitude = common_vendor.ref(30.926); const searchVal = common_vendor.ref(""); const searchList = common_vendor.ref([]); const popupSearch = common_vendor.ref(null); const popup = common_vendor.ref(null); const popupImg = common_vendor.ref(null); const weatherContent = common_vendor.ref(""); const showCount = common_vendor.ref(false); const markerList = common_vendor.ref([]); const activeIndex = common_vendor.ref("3"); const normal = common_vendor.ref(0); const earlyWarn = common_vendor.ref(0); const warn = common_vendor.ref(0); function initMap() { mapContext.value = common_vendor.index.createMapContext("mapUni"); mapContext.value.moveToLocation({ longitude: longitude.value, latitude: latitude.value }); } function searchPosition() { if (!!!searchVal.value) { common_vendor.index.showToast({ title: "请输入搜索关键字", icon: "error" }); return false; } common_vendor.index.showLoading({ title: "搜索中...", mask: true }); common_vendor.index.request({ url: "https://apis.map.qq.com/ws/place/v1/suggestion", //关键词输入提示 data: { key: "GRBBZ-L5KWQ-LCA5Q-2VNXD-JT3N6-YUFJZ", keyword: searchVal.value, region: "孝感", //限制城市范围 page_index: 1, page_size: 20 }, header: { "Content-Type": "application/json;charset=UTF-8" //自定义请求头信息 }, success: (res) => { let datas = res.data; if (datas.status == 0) { searchList.value = datas.data; if (searchList.value.length == 0) { common_vendor.index.showToast({ title: "未搜到相应结果,请重新输入搜索关键字", icon: "error" }); return false; } else { popupSearch.value.open(); } } else { common_vendor.index.showToast({ title: datas.message, icon: "error" }); } common_vendor.index.hideLoading(); } }); } function gotoTask(item) { mapContext.value.moveToLocation({ longitude: item.location.lng, latitude: item.location.lat }); popupSearch.value.close(); } function setWaterLogging(val) { activeIndex.value = val; showCount.value = false; markerList.value = []; mapContext.value.removeGroundOverlay({ id: 1 }); mapContext.value.addGroundOverlay({ id: 1, //图片图层 id src: "https://server1.wh-nf.cn:9000/newfiber-standard/2024/01/29/step0_20240129112143A406.png", bounds: { northeast: { longitude: 113.97755595251466, latitude: 30.95586958507055 }, //东北角经纬度 southwest: { longitude: 113.94202204748537, latitude: 30.901680738004675 } //西南角经纬度 }, success: (res) => { console.log("success:", res); }, fail: (err) => { console.log("失败:", err); } }); } function setLandWater(val) { activeIndex.value = val; showCount.value = true; markerList.value = []; mapContext.value.removeGroundOverlay({ id: 1 }); utils_homeApi.rtuWarnList().then((res) => { let datas = res.data; normal.value = datas.normal; earlyWarn.value = datas.earlyWarn; warn.value = datas.warn; if (res.code == 200 && datas.siteList.length > 0) { datas.siteList.map((item, index) => { if (!!!item.lonLat) return false; markerList.value.push({ id: index, longitude: item.lonLat.split(",")[0], latitude: item.lonLat.split(",")[1], width: 30, height: 30, iconPath: item.warnLevel == "normal" ? common_assets.markerG : item.warnLevel == "earlyWarn" ? common_assets.markerY : common_assets.markerR, callout: { content: item.stName, borderRadius: 8, bgColor: "#fff", padding: 6, display: "ALWAYS" } }); }); longitude.value = markerList.value[0].longitude; latitude.value = markerList.value[0].latitude; initMap(); } else { common_vendor.index.showToast({ icon: "none", title: "暂无路面积水报警" }); } }); } function markerClick(e) { console.log("marker点击事件--", e); popupImg.value.open(); } function checkWeather(val) { activeIndex.value = val; showCount.value = false; utils_homeApi.getWeatherWarn().then((res) => { if (!!res.data.desc) { weatherContent.value = res.data.desc; popup.value.open(); } else { common_vendor.index.showToast({ icon: "none", title: "暂无气象预警" }); } }); } function closePopup() { popup.value.close(); } common_vendor.onTabItemTap((e) => { initMap(); setLandWater("3"); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.o(searchPosition), b: common_vendor.o(($event) => searchVal.value = $event), c: common_vendor.p({ suffixIcon: "search", placeholder: "请输入搜索关键词", modelValue: searchVal.value }), d: common_vendor.f(searchList.value, (item, k0, i0) => { return { a: common_vendor.t(item.address), b: item.id, c: common_vendor.o(($event) => gotoTask(item), item.id) }; }), e: common_vendor.sr(popupSearch, "9b027dbc-1", { "k": "popupSearch" }), f: common_vendor.p({ type: "bottom", ["is-mask-click"]: true }), g: longitude.value, h: latitude.value, i: markerList.value, j: common_vendor.o(markerClick), k: common_vendor.n(activeIndex.value == "1" ? "active" : ""), l: common_vendor.o(($event) => checkWeather("1")), m: common_vendor.n(activeIndex.value == "2" ? "active" : ""), n: common_vendor.o(($event) => setWaterLogging("2")), o: common_vendor.n(activeIndex.value == "3" ? "active" : ""), p: common_vendor.o(($event) => setLandWater("3")), q: common_vendor.o(closePopup), r: common_vendor.o(closePopup), s: common_vendor.p({ type: "success", cancelText: "关闭", confirmText: "收到", title: "气象预警提醒", content: weatherContent.value }), t: common_vendor.sr(popup, "9b027dbc-2", { "k": "popup" }), v: common_vendor.p({ type: "center", ["is-mask-click"]: false }), w: common_vendor.sr(popupImg, "9b027dbc-4", { "k": "popupImg" }), x: common_vendor.p({ type: "center" }), y: showCount.value }, showCount.value ? { z: common_vendor.t(normal.value), A: common_vendor.t(earlyWarn.value), B: common_vendor.t(warn.value) } : {}); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "E:/项目/孝感海绵城市/XiaoGanWXMini/pages/riskWarn/index.vue"]]); wx.createPage(MiniProgramPage);