<template>
	<view>
		<camera device-position="back" flash="off" class="camera"></camera>
		<button type="primary" class="takeBtn" @click="takePhoto">拍摄</button>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				
			}
		},
		onLoad(){
			
		},
		methods:{
			takePhoto(){
				uni.authorize({
					scope:"scope.camera",
					success(){
						let ctx=uni.createCameraContext();
						ctx.takePhoto({
							quality:"high",
							success(res){
								uni.saveImageToPhotosAlbum({
									filePath: res.tempImagePath,
									success: function () {
										uni.navigateBack({
											delta:1
										})
									}
								});
							},
							fail(){
								
							},
							complete(){
								
							}
						})
					},
					fail(){
						
					},
					complete(){
						
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		width: 100%;
		height: 100%;
		background: $uni-bg-color-normal;
	}
	.camera{
		display: block;
		width: 100%;
		height: 712rpx;
		background: rgba(0,0,0,.48);
		margin-bottom: 60rpx;
	}
	.takeBtn{
		width: calc(100% - 60rpx);
		margin: 0 30rpx;
		background: $uni-btn-bg-color !important;
		height: 76rpx;
		line-height: 76rpx;
	}
</style>
