twt 10 місяців тому
батько
коміт
fa54f7c3e3
1 змінених файлів з 94 додано та 38 видалено
  1. 94 38
      pages/index/index.vue

+ 94 - 38
pages/index/index.vue

@@ -171,45 +171,101 @@
 			 },
 			 stBtn(){
 				 var that = this;
-				
-				 uni.chooseImage({
-				 	sourceType: ['album','camera'],
-				 	count:1, 
-				 	success: (chooseImageRes) => {
-				 		console.log(chooseImageRes)
-				 		const tempFilePaths = chooseImageRes.tempFilePaths;
-				 		this.fileURl=tempFilePaths[0]
-				 		 uni.showLoading({ title: '加载中'});
-				 		 uni.uploadFile({
-				 	            url: that.$baseURL+'scanner?action=/vinByOpenApi/scanner', //仅为示例,非真实的接口地址
-				 	            filePath: tempFilePaths[0],
-				 	            name: 'photo',
-				 	           /* formData: {
-				 	                'user': 'test'
-				 	            }, */
-				 	            success: (uploadFileRes) => {
-				 					var data=JSON.parse(uploadFileRes.data);
-				 					uni.hideLoading();
-				 					if(data.code!=1){
-				 						console.log(data.data)
-				 						that.vinNum=data.data;
+				 console.log("识图识图识图识图")
+				 uni.authorize({
+				     scope: 'scope.camera',
+				     success() {
+				        console.log("chengg");
+				uni.chooseImage({
+					sourceType: ['album','camera'],
+					count:1, 
+					success: (chooseImageRes) => {
+						console.log(chooseImageRes)
+						const tempFilePaths = chooseImageRes.tempFilePaths;
+						this.fileURl=tempFilePaths[0]
+						 uni.showLoading({ title: '加载中'});
+						 uni.uploadFile({
+								url: that.$baseURL+'scanner?action=/vinByOpenApi/scanner', //仅为示例,非真实的接口地址
+								filePath: tempFilePaths[0],
+								name: 'photo',
+							   /* formData: {
+									'user': 'test'
+								}, */
+								success: (uploadFileRes) => {
+									var data=JSON.parse(uploadFileRes.data);
+									uni.hideLoading();
+									if(data.code!=1){
+										console.log(data.data)
+										that.vinNum=data.data;
 										that.queryCarModelGroupByVinAggregation()
-				 					}else{
-				 						uni.showToast({
-				 						    title: data.msg,
-				 						    duration: 3000,
-				 							icon:'none',
-				 						});
-				 					}
-				 					
-				 	                //console.log(JSON.parse(uploadFileRes.data).data );
-				 					
-				 	            }
-				 	        }); 
-				 
-				 		
-				 	}
-				 });
+									}else{
+										uni.showToast({
+											title: data.msg,
+											duration: 3000,
+											icon:'none',
+										});
+									}
+									
+									//console.log(JSON.parse(uploadFileRes.data).data );
+									
+								},fail(err) {
+								   console.log(err)
+								   uni.showToast({
+									   title: '拉取失败',
+									   icon:'none',
+									   duration: 3000,
+								   });
+								},
+								complete(obj){
+									uni.hideLoading();
+									if(obj.statusCode!=200){
+										uni.showToast({
+											title: 'vin扫描失败,请重试',
+											icon:'none',
+											duration: 3000,
+										}); 
+										console.log("vin扫描失败,请重试")
+									}
+									
+									
+								}
+							}); 
+				
+								
+							},fail(err){
+								console.log("上传失败")
+								console.log(err)
+							}
+						});
+				     },fail(err) {
+						 uni.showToast({
+							 title: '授权失败',
+							   icon:'none',
+							 duration: 3000,
+						 });
+				     	console.log("授权失败")
+						uni.showModal({
+							title: '是否重新授权识图功能',
+							success(res) {
+								if (res.confirm) {
+									uni.openSetting({
+										success() {
+											console.log('开启权限成功');
+										},
+										fail() {
+											console.log('开启权限失败');
+										}
+									});
+								} else if (res.cancel) {
+									console.log('拒绝开启开启权限');
+								}
+							}
+						});
+				 						
+				 						
+				     }
+				 })
+			
 			 },
 			 queryCarModelGroupByVinAggregation(){
 				 this.$http('matchingByOpen/queryCarModelGroupByVinAggregation', {