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