android位置授权优化

feature/v-xuexi
wangdong 8 months ago
parent 4c766f5cf5
commit 467d9805e6
  1. 37
      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}`,
});
}
},
},
};

Loading…
Cancel
Save