Browse Source

2021-2-10-16.53

zhangyun 4 years ago
parent
commit
c374e513ed
2 changed files with 43 additions and 43 deletions
  1. 2 1
      pages/fourBase/allocation.vue
  2. 41 42
      pages/index/index.vue

+ 2 - 1
pages/fourBase/allocation.vue

@@ -128,7 +128,8 @@
 			},
 		},
 		onLoad(option) {
-			if(option.type!=''){
+			console.log(option)
+			if(option.type){
 				this.addtype = option.type.split("#")
 				console.log(this.addtype)
 			}

+ 41 - 42
pages/index/index.vue

@@ -15,6 +15,8 @@
 				</view>
 			</view>
 		</view>
+		<u-modal v-model="show" :mask-close-able="true" title="" :show-cancel-button="true" confirm-text="拍病害" cancel-text="拍虫害"
+		 content="拍照识别病虫害" @confirm="confirm" @cancel="cancel"></u-modal>
 		<kps-image-cutter @ok="onok" @cancel="oncancle" :url="url" :fixed="false" :blob="false" :maxWidth="500" :maxHeight="500"></kps-image-cutter>
 	</view>
 </template>
@@ -68,9 +70,10 @@
 					}
 				],
 				url: '',
-				res:{},
-				path:'',
-				flag:1
+				res: {},
+				path: '',
+				flag: 1,
+				show: false
 			}
 		},
 		onLoad() {
@@ -104,35 +107,7 @@
 					})
 				} else if (index == 1) {
 					var that = this
-					uni.showModal({
-						content: '拍照识别病虫害',
-						confirmText: "拍病害",
-						cancelText: "拍虫害",
-						success: function(res) {
-							if (res.confirm) {
-								that.flag = 1
-								uni.chooseImage({
-									count: 1, //默认9
-									// sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
-									sourceType: ['camera'], //从相册选择
-									success: (res) => {
-										that.url = res.tempFilePaths[0]
-									}
-								});
-							} else if (res.cancel) {
-								that.flag = 2
-								uni.chooseImage({
-									count: 1, //默认9
-									// sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
-									sourceType: ['camera'], //从相册选择
-									success: (res) => {
-										console.log(1)
-										that.url = res.tempFilePaths[0]
-									}
-								});
-							}
-						}
-					});
+					this.show = true
 				} else if (index == 2) {
 					uni.navigateTo({
 						url: "../expertDiagnosis/index"
@@ -152,11 +127,11 @@
 					uni.navigateTo({
 						url: "../prevention/index"
 					})
-				}else if(index==2){
+				} else if (index == 2) {
 					uni.navigateTo({
-						url:"/pages/monitor/index"
+						url: "/pages/monitor/index"
 					})
-				}else if(index==3){
+				} else if (index == 3) {
 					uni.navigateTo({
 						url: "../environment/index"
 					})
@@ -178,22 +153,46 @@
 					},
 					success: (uploadFileRes) => {
 						console.log(this.flag)
-						if(this.flag == 1){
-						}else if(this.flag == 2){
+						if (this.flag == 1) {
+							this.disease(JSON.parse(uploadFileRes.data).data.src)
+						} else if (this.flag == 2) {
 							this.worm(JSON.parse(uploadFileRes.data).data.src)
 						}
 						uni.navigateTo({
-							url:"../disandpests/index?datas="+JSON.stringify(this.res)+"&path="+JSON.parse(uploadFileRes.data).data.src
-						}) 
-						
+							url: "../disandpests/index?datas=" + JSON.stringify(this.res) + "&path=" + JSON.parse(uploadFileRes.data).data
+								.src
+						})
+
 					}
 				});
 				this.url = "";
-				
 			},
 			oncancle() {
 				// url设置为空,隐藏控件
 				this.url = ''
+			},
+			confirm() {
+				this.flag = 1
+				uni.chooseImage({
+					count: 1, //默认9
+					// sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
+					sourceType: ['camera'], //从相册选择
+					success: (res) => {
+						this.url = res.tempFilePaths[0]
+					}
+				});
+			},
+			cancel() {
+				this.flag = 2
+				uni.chooseImage({
+					count: 1, //默认9
+					// sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
+					sourceType: ['camera'], //从相册选择
+					success: (res) => {
+						console.log(1)
+						this.url = res.tempFilePaths[0]
+					}
+				});
 			}
 		}
 	}
@@ -254,4 +253,4 @@
 			}
 		}
 	}
-</style>
+</style>