zhangsijie 1 год назад
Родитель
Сommit
3af53df556

+ 3 - 1
pages/identifyPest/identifyPestIndex/identifyPestIndex.vue

@@ -58,7 +58,7 @@
 		</view>
 		</view>
 
 
 		<!-- 裁剪组件 -->
 		<!-- 裁剪组件 -->
-		<kps-image-cutter @ok="axiosData" @cancel="oncancle" :url="url" :fixed="false" :blob="false" :maxWidth="500"
+		<kps-image-cutter @ok="axiosData" @cancel="oncancle" :url="url" v-if="url" :fixed="false" :blob="false" :maxWidth="500"
 			:maxHeight="500"></kps-image-cutter>
 			:maxHeight="500"></kps-image-cutter>
 
 
 		<!-- 弹框 -->
 		<!-- 弹框 -->
@@ -127,6 +127,7 @@
 		methods: {
 		methods: {
 			recognizeData(num, name, index) {
 			recognizeData(num, name, index) {
 				console.log(index);
 				console.log(index);
+				this.url = '';
 				uni.setStorage({
 				uni.setStorage({
 					key: this.type,
 					key: this.type,
 					data: index,
 					data: index,
@@ -271,6 +272,7 @@
 		},
 		},
 		onLoad(option) {
 		onLoad(option) {
 			console.log(option)
 			console.log(option)
+			this.url = '';
 			this.type = option.type;
 			this.type = option.type;
 			uni.setNavigationBarTitle({
 			uni.setNavigationBarTitle({
 			  title: `选择${this.identifyPestObj[option.type].title}`  // 设置为你想要的标题
 			  title: `选择${this.identifyPestObj[option.type].title}`  // 设置为你想要的标题

+ 75 - 8
pages/index/index.vue

@@ -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>

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/index.js.map


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
unpackage/dist/dev/mp-weixin/pages/index/index.js