This commit is contained in:
chenrx
2024-06-04 22:24:39 +08:00
parent 697cb6c7e1
commit f513a1f4b0
4 changed files with 143 additions and 139 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
const env = "d";
const env = "p";
const version = 1,
@@ -18,7 +18,7 @@ if (env == "d") {
} else if (env == "t") {
baseUrl = "https://api.test.liche.cn/hd/";
} else if (env == "p") {
baseUrl = "https://api.liche.cn/hd/";
baseUrl = "https://sapi.liche.cn/hd/";
}
api = {
baseUrl: baseUrl,
+137 -137
View File
@@ -141,145 +141,145 @@ function _ModelForGetLocationModel(resolve, reject, errMsg) {
}
const getUserAuthLocation = () => {
let that = this
return new Promise(function (resolve, reject) {
if (app.getStorageByKey('isAgreeAuthLocation')) {
wx.startLocationUpdate({
success() {
wx.onLocationChange(function (res) {
app.setStorage('u_lat', res.latitude)
app.setStorage('u_lng', res.longitude)
resolve({
lat: res.latitude,
lng: res.longitude,
from_storage: false,
});
wx.stopLocationUpdate()
})
},
fail(){
app.printErrorClient('userLocationFail', ['错误信息:用户拒绝授权LocationUpdate'])
getCityLocation().then(res => {
app.setStorage('isAgreeAuthLocation', 1)
resolve({
lat: res.lat,
lng: res.lng,
from_storage: false,
})
})
}
})
} else if(app.getStorageByKey('isRefuseAuthLocation')) {
wx.showModal({
title: '',
content: '开启地理位置权限,获得更精准的体验哦~',
showCancel: true,
cancelText: '我再想想',
confirmText: '前往开启',
success(res) {
if (res.confirm) {
//成功的时候只执行一次(通过手动的时候就没执行了)
wx.openSetting({
success(res) {
wx.authorize({
scope: 'scope.userLocation',
success() {
// resolve("toggle");
wx.getLocation({
type: 'gcj02',
success(res) {
app.setStorage('u_lat', res.latitude)
app.setStorage('u_lng', res.longitude)
app.setStorage('isAgreeAuthLocation', 1)
resolve({
lat: res.latitude,
lng: res.longitude,
from_storage: false,
});
}
})
// const getUserAuthLocation = () => {
// let that = this
// return new Promise(function (resolve, reject) {
// if (app.getStorageByKey('isAgreeAuthLocation')) {
// wx.startLocationUpdate({
// success() {
// wx.onLocationChange(function (res) {
// app.setStorage('u_lat', res.latitude)
// app.setStorage('u_lng', res.longitude)
// resolve({
// lat: res.latitude,
// lng: res.longitude,
// from_storage: false,
// });
// wx.stopLocationUpdate()
// })
// },
// fail(){
// app.printErrorClient('userLocationFail', ['错误信息:用户拒绝授权LocationUpdate'])
// getCityLocation().then(res => {
// app.setStorage('isAgreeAuthLocation', 1)
// resolve({
// lat: res.lat,
// lng: res.lng,
// from_storage: false,
// })
// })
// }
// })
// } else if(app.getStorageByKey('isRefuseAuthLocation')) {
// wx.showModal({
// title: '',
// content: '开启地理位置权限,获得更精准的体验哦~',
// showCancel: true,
// cancelText: '我再想想',
// confirmText: '前往开启',
// success(res) {
// if (res.confirm) {
// //成功的时候只执行一次(通过手动的时候就没执行了)
// wx.openSetting({
// success(res) {
// wx.authorize({
// scope: 'scope.userLocation',
// success() {
// // resolve("toggle");
// wx.getLocation({
// type: 'gcj02',
// success(res) {
// app.setStorage('u_lat', res.latitude)
// app.setStorage('u_lng', res.longitude)
// app.setStorage('isAgreeAuthLocation', 1)
// resolve({
// lat: res.latitude,
// lng: res.longitude,
// from_storage: false,
// });
// }
// })
},
fail() {
app.printErrorClient('userLocationFail', ['错误信息:打开打开地理位置的权限,未设置'])
// _ModelForGetLocationModel(resolve, reject);
getIpCtiy().then(res => {
getCityLocation(res.cname).then(res => {
app.setStorage('isRefuseAuthLocation', 1)
resolve({
lat: res.lat,
lng: res.lng,
from_storage: false,
})
})
})
}
})
}
})
} else if (res.cancel) {
app.printErrorClient('userLocationFail', ['错误信息:用户点击取消'])
getIpCtiy().then(res => {
getCityLocation(res.cname).then(res => {
app.setStorage('isRefuseAuthLocation', 1)
resolve({
lat: res.lat,
lng: res.lng,
from_storage: false,
})
})
}).catch(res=>{
console.log(1)
})
}
}
})
}else{
wx.getLocation({
type: 'gcj02', //wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
success(res) {
app.setStorage('u_lat', res.latitude)
app.setStorage('u_lng', res.longitude)
app.setStorage('isAgreeAuthLocation', 1)
resolve({
lat: res.latitude,
lng: res.longitude,
from_storage: false,
});
},
fail(res) {
console.log(res)
app.printErrorClient('userLocationFail', ['错误信息:' + JSON.stringify(res)])
getIpCtiy().then(res => {
getCityLocation(res.cname).then(res => {
app.setStorage('isRefuseAuthLocation', 1)
resolve({
lat: res.lat,
lng: res.lng,
from_storage: false,
})
})
}).catch(res=>{
getCityLocation().then(res => {
app.setStorage('isRefuseAuthLocation', 1)
resolve({
lat: res.lat,
lng: res.lng,
from_storage: false,
})
}).catch(res=>{
console.log(2)
})
})
// _ModelForGetLocationModel(resolve, reject,res.errMsg);
// },
// fail() {
// app.printErrorClient('userLocationFail', ['错误信息:打开打开地理位置的权限,未设置'])
// // _ModelForGetLocationModel(resolve, reject);
// getIpCtiy().then(res => {
// getCityLocation(res.cname).then(res => {
// app.setStorage('isRefuseAuthLocation', 1)
// resolve({
// lat: res.lat,
// lng: res.lng,
// from_storage: false,
// })
// })
// })
// }
// })
// }
// })
// } else if (res.cancel) {
// app.printErrorClient('userLocationFail', ['错误信息:用户点击取消'])
// getIpCtiy().then(res => {
// getCityLocation(res.cname).then(res => {
// app.setStorage('isRefuseAuthLocation', 1)
// resolve({
// lat: res.lat,
// lng: res.lng,
// from_storage: false,
// })
// })
// }).catch(res=>{
// console.log(1)
// })
// }
// }
// })
// }else{
// wx.getLocation({
// type: 'gcj02', //wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
// success(res) {
// app.setStorage('u_lat', res.latitude)
// app.setStorage('u_lng', res.longitude)
// app.setStorage('isAgreeAuthLocation', 1)
// resolve({
// lat: res.latitude,
// lng: res.longitude,
// from_storage: false,
// });
// },
// fail(res) {
// console.log(res)
// app.printErrorClient('userLocationFail', ['错误信息:' + JSON.stringify(res)])
// getIpCtiy().then(res => {
// getCityLocation(res.cname).then(res => {
// app.setStorage('isRefuseAuthLocation', 1)
// resolve({
// lat: res.lat,
// lng: res.lng,
// from_storage: false,
// })
// })
// }).catch(res=>{
// getCityLocation().then(res => {
// app.setStorage('isRefuseAuthLocation', 1)
// resolve({
// lat: res.lat,
// lng: res.lng,
// from_storage: false,
// })
// }).catch(res=>{
// console.log(2)
// })
// })
// // _ModelForGetLocationModel(resolve, reject,res.errMsg);
}
})
}
// }
// })
// }
})
}
// })
// }
module.exports = {
getAjaxUserInfo,
@@ -287,5 +287,5 @@ module.exports = {
isBindMobile,
isOpenCard,
getUserLocation,
getUserAuthLocation
// getUserAuthLocation
}