From 467d9805e640a6b611473943f868085a1d3a3fa0 Mon Sep 17 00:00:00 2001 From: wangdong <1551135706@qq.com> Date: Fri, 19 Apr 2024 10:25:42 +0800 Subject: [PATCH] =?UTF-8?q?android=E4=BD=8D=E7=BD=AE=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 52ab9fa..7553d8e 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -628,16 +628,10 @@ export default { wx.setNavigationBarTitle({ title:"一合知道" }); - if (!this.$util.getStorage('position')) { - getLocation(() => { - this.$store.commit("app/" + SET_POSITION, '南京'); - }).then(res => { - console.log(res); - this.getPositionAddress(res.lng, res.lat); - }); - } else { - this.$store.commit("app/" + SET_POSITION, this.$util.getStorage('position')); - } + let platform = uni.getSystemInfoSync().platform; + if (platform !== 'android') { + this.authPosition(); + } this.getIndexData(); this.getNewsList(); this.getgroupWork(); @@ -675,6 +669,18 @@ export default { uni.setStorageSync('showWeixinLogin', 0); } }, + authPosition() { + if (!this.$util.getStorage('position')) { + getLocation(() => { + this.$store.commit("app/" + SET_POSITION, '南京'); + }).then(res => { + console.log(res); + this.getPositionAddress(res.lng, res.lat); + }); + } else { + this.$store.commit("app/" + SET_POSITION, this.$util.getStorage('position')); + } + }, getPositionAddress(longitude, latitude,) { qqmapsdk.reverseGeocoder({ location: { @@ -916,9 +922,14 @@ export default { ); }, toPosition() { - uni.navigateTo({ - url: `/pages/index/position?position=${this.currentPosition}`, - }); + let platform = uni.getSystemInfoSync().platform; + if (platform === 'android' && !this.currentPosition) { + this.authPosition(); + } else { + uni.navigateTo({ + url: `/pages/index/position?position=${this.currentPosition}`, + }); + } }, }, };