"use strict";const e=require("../common/vendor.js"),t=require("../common/assets.js");if(!Array){e.resolveComponent("uv-icon")()}Math;const o={__name:"MapComponent",props:{userLocation:{type:Object,default:null},positionList:{type:Array,default:()=>[]},filteredPositions:{type:Array,default:()=>[]},searchKeyword:{type:String,default:""}},emits:["relocate","scan","showList","markerTap","mapCenterChange"],setup(o,{expose:i,emit:a}){const l=e.ref(null);e.ref([{title:"扫码使用",desc:"找到附近设备，扫描设备上的二维码"},{title:"免押金支付",desc:"无需支付押金，使用支付分免押即可完成租借"},{title:"开始使用",desc:"设备自动解锁，风扇弹出后取出即可开始使用"},{title:"归还设备",desc:"使用完毕后，按照设备规格要求将风扇还入即可结束订单"}]);const n=o,u=a,d=e.ref(!0),r=e.ref({longitude:116.397128,latitude:39.916527}),s=e.ref(17),c=e.ref([]),p=e.ref(null),f=()=>{c.value=[],n.userLocation&&c.value.push({id:0,width:32,height:32,latitude:n.userLocation.latitude,longitude:n.userLocation.longitude,title:"我的位置",callout:{content:"我的位置",color:"#ffffff",fontSize:12,borderRadius:4,bgColor:"#2196F3",padding:6,display:"BYCLICK"},customCallout:{anchorX:0,anchorY:0}}),n.filteredPositions&&n.filteredPositions.length>0&&n.filteredPositions.forEach(((e,t)=>{if(e.longitude&&e.latitude){const o=parseFloat(e.latitude),i=parseFloat(e.longitude);o>=-90&&o<=90&&i>=-180&&i<=180?c.value.push({id:t+1,width:30,height:30,latitude:o,longitude:i,title:e.name,position:e,callout:{content:e.name,color:"#333333",fontSize:12,borderRadius:4,bgColor:"#ffffff",padding:6,display:"BYCLICK"}}):console.warn(`忽略无效坐标: ${e.name}, 纬度=${o}, 经度=${i}`)}})),d.value=!1},v=e=>{e&&e.longitude&&e.latitude&&p.value&&p.value.moveToLocation({longitude:e.longitude,latitude:e.latitude,success:()=>{console.log("地图已移动到指定位置")},fail:e=>{console.error("移动地图失败:",e)}})};e.watch((()=>n.userLocation),(e=>{e&&e.longitude&&e.latitude&&(r.value={longitude:e.longitude,latitude:e.latitude},f(),v(e))}),{immediate:!0,deep:!0}),e.watch((()=>n.filteredPositions),(e=>{f()}),{deep:!0});const m=()=>{d.value=!1},g=e=>{"end"===e.type&&"drag"===e.causedBy&&p.value&&p.value.getCenterLocation({success:e=>{e.longitude&&e.latitude&&(r.value={longitude:e.longitude,latitude:e.latitude},u("mapCenterChange",r.value))}})},h=t=>{const o=t.markerId,i=c.value.find((e=>e.id===o));if(i){if(0===o)return void e.index.showToast({title:"这是您的位置",icon:"none"});i.position&&u("markerTap",i.position)}},C=e=>{const t=e.markerId,o=c.value.find((e=>e.id===t));o&&o.position&&u("markerTap",o.position)},L=e=>{console.error("地图加载失败:",e),d.value=!1},y=()=>{u("relocate")},w=()=>{u("scan")},_=()=>{u("showList")};return e.onMounted((()=>{e.nextTick$1((()=>{p.value=e.index.createMapContext("map"),f(),l.value&&l.value.init()}))})),e.onUnmounted((()=>{p.value=null})),i({mapCenter:e.computed((()=>r.value)),moveToLocation:v,updateMapMarkers:f,initCollapse:()=>{l.value&&l.value.init()}}),(o,i)=>e.e({a:r.value.longitude,b:r.value.latitude,c:c.value,d:s.value,e:e.o(g),f:e.o(h),g:e.o(C),h:e.o(m),i:e.o(L),j:d.value},(d.value,{}),{k:e.p({name:"map-fill",size:"18"}),l:e.o(y),m:t._imports_0,n:e.o(w),o:t._imports_1$1,p:e.o(_)})}},i=e._export_sfc(o,[["__scopeId","data-v-bb5e40bd"]]);wx.createComponent(i);
