|  |  | @ -17,13 +17,13 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | 				</view> |  |  |  | 				</view> | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 				<view class="photo_cartoon_2_2"> |  |  |  | 				<view class="photo_cartoon_2_2"> | 
			
		
	
		
		
			
				
					
					|  |  |  | 					<view class="photo_cartoon_2_2_1"> |  |  |  | 					<view class="photo_cartoon_2_2_1" @click="viewAlbum"> | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 						<image src="/static/img/photo/cartoon_4.png" /> |  |  |  | 						<image src="/static/img/photo/cartoon_4.png" /> | 
			
		
	
		
		
			
				
					
					|  |  |  | 					</view> |  |  |  | 					</view> | 
			
		
	
		
		
			
				
					
					|  |  |  | 					<view class="photo_cartoon_2_2_2" @click="goTo('/pagesA/photo/cartoon_3')"> |  |  |  | 					<view class="photo_cartoon_2_2_2" @click="takePhoto"> | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 						<image src="/static/img/photo/cartoon_3.png" /> |  |  |  | 						<image src="/static/img/photo/cartoon_3.png" /> | 
			
		
	
		
		
			
				
					
					|  |  |  | 					</view> |  |  |  | 					</view> | 
			
		
	
		
		
			
				
					
					|  |  |  | 					<view class="photo_cartoon_2_2_1"> |  |  |  | 					<view class="photo_cartoon_2_2_1" @click="back2front"> | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 						<image src="/static/img/photo/cartoon_5.png" /> |  |  |  | 						<image src="/static/img/photo/cartoon_5.png" /> | 
			
		
	
		
		
			
				
					
					|  |  |  | 					</view> |  |  |  | 					</view> | 
			
		
	
		
		
			
				
					
					|  |  |  | 				</view> |  |  |  | 				</view> | 
			
		
	
	
		
		
			
				
					|  |  | @ -49,26 +49,23 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | 				margin_top: 0, |  |  |  | 				margin_top: 0, | 
			
		
	
		
		
			
				
					
					|  |  |  | 				loaded: false, |  |  |  | 				loaded: false, | 
			
		
	
		
		
			
				
					
					|  |  |  | 				cameraEnable: true, |  |  |  | 				cameraEnable: true, | 
			
		
	
		
		
			
				
					
					|  |  |  | 				loop: false, |  |  |  | 		 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 				devicePosition: "back", |  |  |  | 				devicePosition: "back", | 
			
		
	
		
		
			
				
					
					|  |  |  | 				use_camera: 1, |  |  |  | 				use_camera: 1, | 
			
		
	
		
		
			
				
					
					|  |  |  | 				cameraContext: {}, |  |  |  | 				cameraContext: {}, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				users_image:'', //拍照路径 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				cartoon_id:0, | 
			
		
	
		
		
			
				
					
					|  |  |  | 			} |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		}, |  |  |  | 		}, | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		mounted() { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			setTimeout(() => { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 				this.loaded = true; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 				this.loopGetCameraInfo(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			}, 500); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		}, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		onShow() { |  |  |  | 		onShow() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 			if (this.loaded && !this.loop) { |  |  |  | 			var _this =this; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 				// 轮询当前相机权限状态,当用户授权则将cameraEnable设置为true |  |  |  | 			_this.checkAuth(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 				this.loopGetCameraInfo(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			} |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		}, |  |  |  | 		}, | 
			
		
	
		
		
			
				
					
					|  |  |  | 		onLoad() { |  |  |  | 		onLoad(options) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			var _this =this; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			console.log('options',options); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			_this.cartoon_id = options.id; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			if (uni.createCameraContext) { |  |  |  | 			if (uni.createCameraContext) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 				this.cameraContext = uni.createCameraContext() |  |  |  | 				this.cameraContext = uni.createCameraContext() | 
			
		
	
		
		
			
				
					
					|  |  |  | 			} else { |  |  |  | 			} else { | 
			
		
	
	
		
		
			
				
					|  |  | @ -80,7 +77,31 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | 			} |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		}, |  |  |  | 		}, | 
			
		
	
		
		
			
				
					
					|  |  |  | 		methods: { |  |  |  | 		methods: { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			//判断 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			checkAuth() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				var _this = this; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				console.log('已授权---'); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				uni.authorize({ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					scope: 'scope.camera', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					success(res) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						console.log('已授权', res); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						_this.loaded=true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						_this.cameraEnable=true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					}, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					fail(err) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 			 |  |  |  | 			 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						uni.showModal({ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							title: '授权失败', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							content: '请在设置界面打开摄像头相关权限', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							success: (res) => { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								if (res.confirm) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									uni.openSetting() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						}) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					}, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				}) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			}, | 
			
		
	
		
		
			
				
					
					|  |  |  | 			getNavHeight(e) { |  |  |  | 			getNavHeight(e) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 				this.margin_top += e; |  |  |  | 				this.margin_top += e; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			}, |  |  |  | 			}, | 
			
		
	
	
		
		
			
				
					|  |  | @ -90,6 +111,86 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | 					url:url, |  |  |  | 					url:url, | 
			
		
	
		
		
			
				
					
					|  |  |  | 				}) |  |  |  | 				}) | 
			
		
	
		
		
			
				
					
					|  |  |  | 			}, |  |  |  | 			}, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			errorCamera(e) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				var _this =this; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				_this.$com.alertDo('请打开摄像头权限',function(res){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					_this.checkAuth(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				}); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			}, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			//查看相册 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			viewAlbum(){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				var _this =this; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				uni.chooseMedia({ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				  count: 1, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				  mediaType: ['image'], | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				  sourceType: ['album'], | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				  camera: 'back', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				  success(res) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  console.log('相册',res); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				     //console.log(res.tempFiles) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					 var  edetail= res.tempFiles[0].tempFilePath; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					 //上传 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					 var upData = {filePath:edetail,fileType:'image',scene:'user_centre'}; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  _this.$api.ossUpload(upData,function(res){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  	console.log('ossUpload success',res); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  	var d = res.data; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  	_this.users_image = d.file_url; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  	uni.navigateTo({ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  		url:'/pagesA/photo/cartoon_3?cartoon_id='+_this.cartoon_id+'&users_image='+encodeURIComponent(_this.users_image), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  	}) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					   | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  },function(err){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  	console.log('ossUpload fail',err); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					  });	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				  } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				}) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			}, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			//发起拍照 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			takePhoto(){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				var _this =this; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				const ctx = uni.createCameraContext(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				ctx.takePhoto({ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				       quality: 'high', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				       success: (res) => { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							  console.log('拍照',res); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							  var  edetail= res.tempImagePath; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							  //上传 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							  var upData = {filePath:edetail,fileType:'image',scene:'user_centre'}; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   _this.$api.ossUpload(upData,function(res){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   	console.log('ossUpload success',res); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   	var d = res.data; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   	_this.users_image = d.file_url; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   	uni.navigateTo({ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   		url:'/pagesA/photo/cartoon_3?cartoon_id='+_this.cartoon_id+'&users_image='+encodeURIComponent(_this.users_image), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   	}) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							    | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   },function(err){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   	console.log('ossUpload fail',err); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							   });	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				               | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				       } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				}); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			}, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			back2front() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				var _this =this; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				if(_this.devicePosition == 'back') | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					_this.devicePosition = 'front'; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					console.log('切换----前'); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					_this.devicePosition = 'back'; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					console.log('切换----后') | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			}, | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | </script> |  |  |  | </script> | 
			
		
	
	
		
		
			
				
					|  |  | 
 |