From 913becb570a5ea222b013a72cebb63c44d4c8281 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Wed, 27 Aug 2025 22:10:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/config.js | 2 +- pages/book/house.vue | 2 +- pages/home/home.vue | 186 +++++++++++++++++++++++++++++++------------ 3 files changed, 137 insertions(+), 53 deletions(-) diff --git a/common/config.js b/common/config.js index 079216e..cad775e 100644 --- a/common/config.js +++ b/common/config.js @@ -1,6 +1,6 @@ const mode = 'production'; //devLocal:本地测试、devOnline:线上测试、production:生产环境 let ROOTPATH = 'https://h5.jscnsaas.cn'; -// let ROOTPATH = 'http://h5.ali251.langye.net'; +// let ROOTPATH = 'https://vr.langye.net'; switch (mode) { case 'devLocal': ROOTPATH = ROOTPATH diff --git a/pages/book/house.vue b/pages/book/house.vue index 664ef83..ab246b0 100644 --- a/pages/book/house.vue +++ b/pages/book/house.vue @@ -376,7 +376,7 @@ align-items: center; justify-content: center; margin-top: -80rpx; - background:linear-gradient(to bottom,transparent,#f6f3ef) ; + background:linear-gradient(to bottom,transparent,#f6f3ef) ; padding-bottom:40rpx; &-item { font-size: 0; diff --git a/pages/home/home.vue b/pages/home/home.vue index 8e4779b..d4702db 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -28,11 +28,11 @@ - + - + @@ -42,16 +42,16 @@ - - - {{item.title}} + + + {{item.title}} - + @@ -63,7 +63,7 @@ 距你{{pointer.distance?pointer.distance:'-'}} - + {{con.value}} @@ -82,6 +82,9 @@ + + 使用完整功能,需要获取您的定位,点击授权 + @@ -158,8 +161,9 @@ showArea: false, tips: '', showLoad: false, - showNear: true, - showLabel:false + showNear: true, + showLabel:false, + showLocationTip: false } }, @@ -170,32 +174,27 @@ return shareInfo }, onReady() { - uni.authorize({ - scope: 'scope.userLocation', - success: (res) => { - this.getUserLocation() - } - }) + this.initLocationAuth() this.mapContext = uni.createMapContext('myMap', this); - // 获取当前地图层级 - let _this = this + // 获取当前地图层级 + let _this = this if (this.mapTimer) { clearInterval(this.mapTimer) - } else { - this.mapTimer = setInterval(function() { - _this.mapContext.getScale({ - success: function(res) { - if(res.scale>12){ - _this.showLabel = true - }else{ - _this.showLabel = false - } - }, - fail: function(error) { - console.log('获取地图缩放级别失败:', error); - } - }); + } else { + this.mapTimer = setInterval(function() { + _this.mapContext.getScale({ + success: function(res) { + if(res.scale>12){ + _this.showLabel = true + }else{ + _this.showLabel = false + } + }, + fail: function(error) { + console.log('获取地图缩放级别失败:', error); + } + }); }, 1000) } @@ -241,19 +240,49 @@ onHide() { this.showTips = false this.showPointer = false - this.pointer = null - if(!this.mapTimer){ - this.mapTimer = null - clearInterval(this.mapTimer) - } + this.pointer = null + if(!this.mapTimer){ + this.mapTimer = null + clearInterval(this.mapTimer) + } }, methods: { + initLocationAuth() { + uni.getSetting({ + success: (res) => { + const setting = res.authSetting || {} + const loc = setting['scope.userLocation'] + if (loc === true) { + this.showLocationTip = false + this.getUserLocation() + } else if (loc === false) { + this.showLocationTip = true + } else { + // undefined: first time, try authorize + uni.authorize({ + scope: 'scope.userLocation', + success: () => { + this.showLocationTip = false + this.getUserLocation() + }, + fail: () => { + this.showLocationTip = true + } + }) + } + }, + fail: () => { + this.showLocationTip = true + } + }) + }, // 我的位置 getUserLocation() { uni.getLocation({ type: 'gcj02', success: (res) => { + this.showLocationTip = false uni.removeStorageSync('vuex_latlng') this.lng = res.longitude this.lat = res.latitude @@ -265,6 +294,47 @@ }, fail: (err) => { console.log("err", err) + this.showLocationTip = true + } + }) + }, + retryLocationAuth() { + // 根据当前授权状态选择 authorize 或直接打开设置 + uni.getSetting({ + success: (res) => { + const setting = res.authSetting || {} + const loc = setting['scope.userLocation'] + if (loc === true) { + this.showLocationTip = false + this.getUserLocation() + } else if (loc === false) { + uni.openSetting({ + success: (rs) => { + if (rs.authSetting && rs.authSetting['scope.userLocation']) { + this.showLocationTip = false + this.getUserLocation() + } + } + }) + } else { + uni.authorize({ + scope: 'scope.userLocation', + success: () => { + this.showLocationTip = false + this.getUserLocation() + }, + fail: () => { + uni.openSetting({ + success: (rs) => { + if (rs.authSetting && rs.authSetting['scope.userLocation']) { + this.showLocationTip = false + this.getUserLocation() + } + } + }) + } + }) + } } }) }, @@ -668,15 +738,29 @@ display: inline-block; } } + + &-tip { + position: absolute; + left: 50%; + bottom: 160rpx; + transform: translate(-50%,-50%); + width: 80%; + z-index: 99; + text-align: center; + background: rgba(0,0,0,0.6); + color: #fff; + padding: 10rpx 30rpx; + border-radius: 40rpx; + } } &-cover { display: flex; align-items: center; - z-index: 9999; + z-index: 9999; flex-wrap: wrap; - position: relative; + position: relative; flex-flow: column; &-wrap { position: relative; @@ -715,12 +799,12 @@ // width: 270rpx; // height: 65rpx; - // } + // } font-size: 22rpx; color: #960909; - width: 200rpx; - text-align: center; + width: 200rpx; + text-align: center; white-space: normal; // cover-view { // padding: 10rpx; @@ -789,16 +873,16 @@ } } } - } - .areaPicker{ - .u-drawer{ - >view{ - .u-picker-body{ - height:750rpx; - } - } - } - + } + .areaPicker{ + .u-drawer{ + >view{ + .u-picker-body{ + height:750rpx; + } + } + } + } }