Sfoglia il codice sorgente

相册权限问题

twt 1 anno fa
parent
commit
7246091548
1 ha cambiato i file con 61 aggiunte e 38 eliminazioni
  1. 61 38
      pages/index/index.vue

+ 61 - 38
pages/index/index.vue

@@ -37,6 +37,7 @@
 			</view>
 		</view>
 		<!-- <view :style="{height: aaa}" class="aaaaa"></view> -->
+		<!-- <view @click="wy">asdfasdfasdfas</view> -->
 		<carModel ref="carModelView" :iStatusBarHeight="iStatusBarHeight" :svHeight="aaa"></carModel>
 		
 		<!-- 选择车型 -->
@@ -96,6 +97,17 @@
 			}
 		},
 		methods: {
+			wy(){
+				
+				uni.chooseImage({
+					count: 6, //默认9
+					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
+					sourceType: ['album'], //从相册选择
+					success: function (res) {
+						console.log(JSON.stringify(res.tempFilePaths));
+					}
+				});
+			},
 			
 			 uniLogin(){
 				 var that=this;
@@ -169,45 +181,56 @@
 			 },
 			 stBtn(){
 				 var that = this;
+				 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 );
+											
+							            },fail(err) {
+								           console.log(err)
+							            }
+							        }); 
+						
+								
+							}
+						});
+				     },fail() {
+				     	console.log("授权失败")
+				     }
+				 })
 				
-				 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 );
-				 					
-				 	            }
-				 	        }); 
-				 
-				 		
-				 	}
-				 });
 			 },
 			 queryCarModelGroupByVinAggregation(){
 				 this.$http('matchingByOpen/queryCarModelGroupByVinAggregation', {