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}`, + }); + } }, }, };