acdr-ui/dist/build/mp-weixin/service/mapService.js
2024-10-01 09:15:35 +08:00

2 lines
805 B
JavaScript

"use strict";var t=(t,e,n)=>new Promise(((o,r)=>{var a=t=>{try{i(n.next(t))}catch(e){r(e)}},c=t=>{try{i(n.throw(t))}catch(e){r(e)}},i=t=>t.done?o(t.value):Promise.resolve(t.value).then(a,c);i((n=n.apply(t,e)).next())}));const e=require("../common/vendor.js"),n=require("../utils/http.js"),o="lastLocation";exports.getLocation=()=>t(exports,null,(function*(){const t=Date.now(),n=e.index.getStorageSync(o);if(n&&t-n.time<3e4)return n.data;try{const n=yield new Promise(((t,n)=>{e.index.getLocation({type:"gcj02",success:e=>{t(e)},fail:t=>{n(t)}})}));return e.index.setStorageSync(o,{data:n,time:t}),n}catch(r){throw r}})),exports.getMapDetailAddress=(e,o)=>t(exports,null,(function*(){try{const t=yield n.httpGet("/map/detail",{longitude:e,latitude:o});return 200==t.code?t.data:null}catch(t){throw t}}));