对接烟台app的h5页面
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

54 lines
1.7 KiB

// 获取坐标
export function getLocation() {
return new Promise((reslove) => {
uni.getLocation({
type: 'gcj02',
success(res) {
let lat = res.latitude;
let lng = res.longitude;
const { latitude, longitude } = res;
reslove({
msg: 'success',
data: {
latitude,
longitude
}
});
},
fail(err) {
reslove({
data: '',
msg: err.errMsg
});
}
});
});
}
// isQuiet为true时不打扰用户,如未获取授权,不请求
export default (isQuiet = true) => {
return new Promise(async (reslove) => {
const retLocation = await getLocation();
let retData;
if (retLocation.msg === 'success') {
retData = await getLocalData(retLocation.data.latitude, retLocation.data.longitude);
} else {
if (isQuiet) {
retData = retLocation;
} else {
const retAuth = await getAuth();
if (retAuth.msg === 'success') {
const retLocation2 = await getLocation();
if (retLocation2.msg === 'success') {
retData = await getLocalData(retLocation2.data.latitude, retLocation2.data.longitude);
} else {
retData = retLocation2;
}
} else {
retData = retAuth;
}
}
}
return reslove(retData);
});
};