<template>
	<view class="content">
		<view class="textBoard">
			<text style="color: #fff; font-size: 48rpx;">Need permissions?</text>
		</view>
		<view class="textBoard">
			<text style="color: #fff; font-size: 36rpx;">Camera permission is requeired to</text>
		</view>
		<view class="textBoard">
			<text style="color: #0186FF; font-size: 36rpx;">QR Code Scanner & barcode Reader.</text>
		</view>
		<view class="textBoard">
			<tn-button @click="openPermission()" :backgroundColor="btnBackgroundColor" :fontColor="btnFontColor" width="300rpx" height="100rpx"
			:fontSize="btnFontSize">Allow</tn-button>
		</view>
	</view>
</template>

<script>
	import permision from "@/js_sdk/wa-permission/permission.js"
	export default {
		data() {
			return {
				btnFontSize: 36,
				btnBackgroundColor: '#0186ff',
				btnFontColor: '#fff'
			}
		},
		onLoad() {
			
		},
		onHide() {
			
		},
		methods: {
			
			//打开授权
			async openPermission(){
				let that = this;
				console.log('打开授权')
				var result = await permision.requestAndroidPermission('android.permission.CAMERA')
				if (result == 1) {
					//有权限,跳转到扫码界面
					that.jumpToRights('/pages/scan/Scan');
				}else if(result == -1) {
					//禁止权限，跳转到权限设置页面
				    that.jumpToRights('/pages/rights/RightsSetting');
				}
			},
			
			//跳转到授权设置页面
			jumpToRights(url){
				uni.switchTab({
					url: url
				})
			}
			
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		background-color: #1F222B;
		height:100vh;
	}
	
	.textBoard{
		margin-top: 1vh;
	}
</style>