From f513a1f4b0f69502cd43f97159b84d87f727ced5 Mon Sep 17 00:00:00 2001 From: chenrx Date: Tue, 4 Jun 2024 22:24:39 +0800 Subject: [PATCH] 20240604 --- app.json | 3 + commons/js/config.js | 4 +- commons/js/utils/user-manager.js | 274 +++++++++++++++---------------- pages/signup/index.js | 1 + 4 files changed, 143 insertions(+), 139 deletions(-) diff --git a/app.json b/app.json index d9eaf69..9f94b2b 100644 --- a/app.json +++ b/app.json @@ -102,5 +102,8 @@ "plugins": {}, "navigateToMiniProgramAppIdList": [ "wx98e64c11aac45966" + ], + "requiredPrivateInfos":[ + "getLocation" ] } \ No newline at end of file diff --git a/commons/js/config.js b/commons/js/config.js index 5cf35fe..316d20f 100644 --- a/commons/js/config.js +++ b/commons/js/config.js @@ -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, diff --git a/commons/js/utils/user-manager.js b/commons/js/utils/user-manager.js index d52900c..232e0cc 100644 --- a/commons/js/utils/user-manager.js +++ b/commons/js/utils/user-manager.js @@ -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 } \ No newline at end of file diff --git a/pages/signup/index.js b/pages/signup/index.js index e306cc4..c61cb7a 100644 --- a/pages/signup/index.js +++ b/pages/signup/index.js @@ -137,6 +137,7 @@ Page({ * 授权地理位置 */ getUserLocation() { + console.log("333") let that = this return new Promise(function (resolve, reject) { if (app.getStorageByKey('u_lat') && app.getStorageByKey('u_lng')) {