2024-10-01 09:15:35 +08:00
|
|
|
"use strict";const e=require("../common/vendor.js"),t=require("../service/mapService.js"),i=require("../utils/commUtils.js");if(!Array){(e.resolveComponent("u-col")+e.resolveComponent("u-row"))()}const l={__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(l,{emit:a}){const u=l,n=e.ref(u.initialLongitude||0),o=e.ref(u.initialLatitude||0),d=e.ref(0),c=e.ref(0),r=e.ref("16"),s=e.ref(!0),g=a,v=e.reactive([{longitude:n.value,latitude:o.value,iconPath:u.iconPath,width:30,height:30,label:{content:u.locationName,textAlign:"center",color:"#FB3109"}}]),p=()=>{e.index.chooseLocation({success:e=>{n.value=e.longitude,o.value=e.latitude,v[0].longitude=e.longitude,v[0].latitude=e.latitude},fail:e=>{i.toast("获取位置失败")}})};return e.watch((()=>[u.initialLongitude,u.initialLatitude]),(([e,t])=>{null!==e&&(n.value=e,v[0].longitude=e),null!==t&&(o.value=t,v[0].latitude=t)})),e.onLoad((()=>{0===n.value&&0===o.value?e.index.getLocation({type:"gcj02",timeout:1e3,geocode:s.value,success:i=>{e.index.hideLoading(),n.value=i.longitude,o.value=i.latitude,d.value=i.longitude,c.value=i.latitude,v[0].longitude=i.longitude,v[0].latitude=i.latitude,t.getMapDetailAddress(i.longitude,i.latitude).then((e=>{e.location={longitude:i.longitude,latitude:i.latitude},g("doneFun",e)}))},fail:t=>{e.index.showModal({title:"提示",content:"位置信息获取失败(请确定定位功能是否打开)",showCancel:!1})}}):(v[0].longitude=n.value,v[0].latitude=o.value,t.getMapDetailAddress(n.value,o.value).then((e=>{g("doneFun",e)})))})),(t,i)=>({a:n.value,b:o.value,c:r.value,d:e.o(p),e:v,f:e.p({span:"12"})})}},a=e._export_sfc(l,[["__scopeId","data-v-4aae03c3"]]);wx.createComponent(a);
|