"use strict"; const common_vendor = require("../common/vendor.js"); const service_mapService = require("../service/mapService.js"); const utils_commUtils = require("../utils/commUtils.js"); if (!Array) { const _component_u_col = common_vendor.resolveComponent("u-col"); const _component_u_row = common_vendor.resolveComponent("u-row"); (_component_u_col + _component_u_row)(); } const _sfc_main = { __name: "Map", props: { initialLongitude: { type: Number, default: null }, initialLatitude: { type: Number, default: null }, iconPath: { type: String, default: "/static/map/self.png" }, locationName: { type: String, default: "本地位置" } }, emits: ["doneFun"], setup(__props, { emit: __emit }) { const props = __props; const longitude = common_vendor.ref(props.initialLongitude || 0); const latitude = common_vendor.ref(props.initialLatitude || 0); const originalLongitude = common_vendor.ref(0); const originalLatitude = common_vendor.ref(0); const scale = common_vendor.ref("16"); const geocode = common_vendor.ref(true); const emit = __emit; const covers = common_vendor.reactive([ { longitude: longitude.value, latitude: latitude.value, iconPath: props.iconPath, width: 30, height: 30, label: { content: props.locationName, textAlign: "center", color: "#FB3109" } } ]); const clickmap = () => { common_vendor.index.chooseLocation({ success: (res) => { longitude.value = res.longitude; latitude.value = res.latitude; covers[0].longitude = res.longitude; covers[0].latitude = res.latitude; }, fail: (err) => { console.log(err); utils_commUtils.toast("获取位置失败"); } }); }; const getLocation = () => { common_vendor.index.getLocation({ type: "gcj02", timeout: 1e3, geocode: geocode.value, success: (res) => { common_vendor.index.hideLoading(); longitude.value = res.longitude; latitude.value = res.latitude; originalLongitude.value = res.longitude; originalLatitude.value = res.latitude; covers[0].longitude = res.longitude; covers[0].latitude = res.latitude; service_mapService.getMapDetailAddress(res.longitude, res.latitude).then((mapDetail) => { mapDetail.location = { longitude: res.longitude, latitude: res.latitude }; emit("doneFun", mapDetail); }); }, fail: (err) => { console.log(err); common_vendor.index.showModal({ title: "提示", content: "位置信息获取失败(请确定定位功能是否打开)", showCancel: false }); } }); }; common_vendor.watch( () => [props.initialLongitude, props.initialLatitude], ([newLongitude, newLatitude]) => { if (newLongitude !== null) { longitude.value = newLongitude; covers[0].longitude = newLongitude; } if (newLatitude !== null) { latitude.value = newLatitude; covers[0].latitude = newLatitude; } } ); common_vendor.onLoad(() => { if (longitude.value === 0 && latitude.value === 0) { getLocation(); } else { covers[0].longitude = longitude.value; covers[0].latitude = latitude.value; service_mapService.getMapDetailAddress(longitude.value, latitude.value).then((mapDetail) => { emit("doneFun", mapDetail); }); } }); return (_ctx, _cache) => { return { a: longitude.value, b: latitude.value, c: scale.value, d: common_vendor.o(clickmap), e: covers, f: common_vendor.p({ span: "12" }) }; }; } }; const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e2082563"]]); wx.createComponent(Component);