|
@@ -430,7 +430,12 @@ export default {
|
|
|
lat: lat,
|
|
lat: lat,
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
- console.log(res);
|
|
|
|
|
|
|
+ // uni.showToast({
|
|
|
|
|
+ // title: JSON.stringify(res[0]),
|
|
|
|
|
+ // duration: 20000,
|
|
|
|
|
+ // icon:'none'
|
|
|
|
|
+ // });
|
|
|
|
|
+ // console.log(res);
|
|
|
this.weatherinfo = res[0];
|
|
this.weatherinfo = res[0];
|
|
|
},
|
|
},
|
|
|
async getUserlogin() {
|
|
async getUserlogin() {
|
|
@@ -672,6 +677,73 @@ export default {
|
|
|
url: '../expertDiagnosis/introduce?id=' + id + '&title=' + title,
|
|
url: '../expertDiagnosis/introduce?id=' + id + '&title=' + title,
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
+ checkLocationPermission(isTest) {
|
|
|
|
|
+ let session_key = uni.getStorageSync('session_key');
|
|
|
|
|
+ let _this = this;
|
|
|
|
|
+ // 当用户登录之后再弹位置权限框
|
|
|
|
|
+ if(session_key) {
|
|
|
|
|
+ uni.getSetting({
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ console.log(res);
|
|
|
|
|
+ if(res.authSetting['scope.userLocation']) {
|
|
|
|
|
+ uni.getLocation({
|
|
|
|
|
+ type: 'wgs84 ',
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ // console.log(res, 'loacation');
|
|
|
|
|
+ // uni.showToast({
|
|
|
|
|
+ // title: `${res.longitude}, ${res.longitude}`,
|
|
|
|
|
+ // duration: 20000,
|
|
|
|
|
+ // icon:'none'
|
|
|
|
|
+ // });
|
|
|
|
|
+ _this.getcity(res.longitude, res.latitude);
|
|
|
|
|
+ },
|
|
|
|
|
+ fail(e) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: JSON.stringify(e),
|
|
|
|
|
+ duration: 5000,
|
|
|
|
|
+ icon:'none'
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.authorize({
|
|
|
|
|
+ scope: 'scope.userLocation',
|
|
|
|
|
+ success: () => {
|
|
|
|
|
+ // 用户已授权
|
|
|
|
|
+ uni.getLocation({
|
|
|
|
|
+ type: 'wgs84 ',
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ console.log(res, 'loacation');
|
|
|
|
|
+ _this.getcity(res.longitude, res.latitude);
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: () => {
|
|
|
|
|
+ // 用户拒绝授权,可引导用户至设置页手动开启
|
|
|
|
|
+ if(isTest) {
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '需要授权',
|
|
|
|
|
+ content: '天气功能需要获取您的地理位置,请在设置中打开位置权限',
|
|
|
|
|
+ success: (modalRes) => {
|
|
|
|
|
+ if (modalRes.confirm) {
|
|
|
|
|
+ uni.openSetting()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '您拒绝了授权,将无法查看天气信息',
|
|
|
|
|
+ duration: 2000,
|
|
|
|
|
+ icon:'none'
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
onLoad() {
|
|
onLoad() {
|
|
|
console.log(this.$isneutral);
|
|
console.log(this.$isneutral);
|
|
@@ -682,18 +754,13 @@ export default {
|
|
|
} else {
|
|
} else {
|
|
|
this.hello = '下午好!';
|
|
this.hello = '下午好!';
|
|
|
}
|
|
}
|
|
|
- uni.getFuzzyLocation({
|
|
|
|
|
- type: 'wgs84 ',
|
|
|
|
|
- success: (res) => {
|
|
|
|
|
- console.log(res, 'loacation');
|
|
|
|
|
- this.getcity(res.longitude, res.latitude);
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
this.getUserlogin();
|
|
this.getUserlogin();
|
|
|
|
|
+ this.checkLocationPermission(true); // 首次加载弹框提醒
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
this.loadTF = false;
|
|
this.loadTF = false;
|
|
|
this.getUserlogin();
|
|
this.getUserlogin();
|
|
|
|
|
+ this.checkLocationPermission();
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|