import{_ as t,bb as e,G as o,aa as i,b as n,d as a,p as s,w as u,H as c,i as l,j as p,o as d,f as r,k as f,v as g,t as h,C as m,R as _}from"./index-2PZN6pGH.js";import{a as y}from"./util.BQsFLuvY.js";var C=y;const L=t({data:()=>({title:"getLocation",hasLocation:!1,location:{},type:""}),methods:{togglePopup(t){this.type=t},showConfirm(){this.type="showpopup"},hideConfirm(){this.type=""},async getLocation(){this.doGetLocation()},doGetLocation(){e({success:t=>{this.hasLocation=!0,this.location=C(t.longitude,t.latitude)},fail:t=>{t.errMsg.indexOf("auth deny")>=0?o({title:"访问位置被拒绝"}):o({title:t.errMsg})}})},getSetting:function(){return new Promise(((t,e)=>{uni.getSetting({success:e=>{void 0!==e.authSetting["scope.userLocation"]?e.authSetting["scope.userLocation"]?t(1):t(2):t(0)}})}))},openSetting:function(){this.hideConfirm(),uni.openSetting({success:t=>{t.authSetting&&t.authSetting["scope.userLocation"]&&this.doGetLocation()},fail:t=>{}})},async checkPermission(){let t=permision.isIOS?await permision.requestIOS("location"):await permision.requestAndroid("android.permission.ACCESS_FINE_LOCATION");return null===t||1===t?t=1:2===t?i({content:"系统定位已关闭",confirmText:"确定",showCancel:!1,success:function(t){}}):t.code?i({content:t.message}):i({content:"需要定位权限",confirmText:"设置",success:function(t){t.confirm&&permision.gotoAppSetting()}}),t},clear:function(){this.hasLocation=!1}}},[["render",function(t,e,o,i,y,C){const L=n(a("page-head"),c),S=l,k=m,w=_,x=n(a("uni-popup"),p);return d(),s(S,null,{default:u((()=>[r(L,{title:y.title},null,8,["title"]),r(S,{class:"uni-padding-wrap"},{default:u((()=>[r(S,{style:{background:"#FFFFFF",padding:"40rpx"}},{default:u((()=>[r(S,{class:"uni-hello-text uni-center"},{default:u((()=>[f("当前位置经纬度")])),_:1}),!1===y.hasLocation?(d(),s(S,{key:0,class:"uni-h2 uni-center uni-common-mt"},{default:u((()=>[f("未获取")])),_:1})):g("",!0),!0===y.hasLocation?(d(),s(S,{key:1,class:"uni-h2 uni-center uni-common-mt"},{default:u((()=>[r(k,null,{default:u((()=>[f("E: "+h(y.location.longitude[0])+"°"+h(y.location.longitude[1])+"′",1)])),_:1}),r(k,null,{default:u((()=>[f("\\nN: "+h(y.location.latitude[0])+"°"+h(y.location.latitude[1])+"′",1)])),_:1})])),_:1})):g("",!0)])),_:1}),r(S,{class:"uni-btn-v"},{default:u((()=>[r(w,{type:"primary",onClick:C.getLocation},{default:u((()=>[f("获取位置")])),_:1},8,["onClick"]),r(w,{onClick:C.clear},{default:u((()=>[f("清空")])),_:1},8,["onClick"])])),_:1})])),_:1}),r(x,{show:"showpopup"===y.type,mode:"fixed",onHidePopup:e[1]||(e[1]=t=>C.togglePopup(""))},{default:u((()=>[r(S,{class:"popup-view"},{default:u((()=>[r(k,{class:"popup-title"},{default:u((()=>[f("需要用户授权位置权限")])),_:1}),r(S,{class:"uni-flex popup-buttons"},{default:u((()=>[r(w,{class:"uni-flex-item",type:"primary","open-type":"openSetting",onClick:C.openSetting},{default:u((()=>[f("设置")])),_:1},8,["onClick"]),r(w,{class:"uni-flex-item",onClick:e[0]||(e[0]=t=>C.togglePopup(""))},{default:u((()=>[f("取消")])),_:1})])),_:1})])),_:1})])),_:1},8,["show"])])),_:1})}],["__scopeId","data-v-d9df7ac7"]]);export{L as default};
