<template>
	<up-popup :show="showDialog" round mode="bottom" @close="close()" catchtouchmove="preventD" :zIndex="202">
		<view class="pageBox">
			<view class="title">温馨提示</view>
			<view class="box">
				<view class="text">为给您提供更好的服务，允许我们在必要场景下，合理使用您的个人信息，并充分保障您的合法权利。
				请您在使用前仔细查阅以下协议条款，点击"允许"即表示您已阅读并同意对应的协议内容。
				</view>
				<view class="link" @click="openPrivacyContract">《隐私协议》</view>
			</view>
			<view class="btnbox">
				<button type="default" open-type="agreePrivacyAuthorization" id="agree-btn" class="agree" @agreeprivacyauthorization="handleAgree">允许</button>
				<view class="btn" @click="refuse()">拒绝</view>
			</view>
		</view>
	</up-popup>
</template>

<script>
	import { ref, reactive, toRefs } from 'vue'
	import { get, post } from '@/Api/request.js'
	export default {
		props: {
			showDialog: {
				type: Boolean,
				default: false
			}
		},
		setup(props, context) {
			const data = reactive({
				Color: uni.getStorageSync('theme_color')
			})
	
			function handleAgree() {
				context.emit('agree')
			}
			
			const preventD = () => {
				return
			}
			
			function openPrivacyContract() {
				uni.openPrivacyContract({
					success: res => {
						console.log('openPrivacyContract success')
					},
					fail: res => {
						console.error('openPrivacyContract fail', res)
					}
				})
			}
			
			// 拒绝
			function refuse() {
				context.emit('refuse')
			}
			
			function close() {
				context.emit('close')
			}
	
			return {
				...toRefs(data),
				handleAgree,
				openPrivacyContract,
				preventD,
				refuse,
				close
			}
		}
	}
</script>

<style lang="scss" scoped>
	.pageBox{
		padding-bottom: 200rpx;
		.title{
			font-size: 32rpx;
			color: #000;
			font-weight: bold;
			padding: 30rpx 0;
			text-align: center;
		}
		.box{
			padding: 0 30rpx;
			font-size: 28rpx;
			.text{
				color: #555;
				line-height: 50rpx;
			}
			.link{
				color: #155BD4;
			}
		}
		.btnbox{
			width: 100%;
			padding: 0 30rpx;
			box-sizing: border-box;
			font-size: 28rpx;
			text-align: center;
			margin-top: 60rpx;
			.agree {
				height: 70rpx;
				display: flex;
				font-size: 28rpx;
				align-items: center;
				justify-content: center;
				width: 100%;
				background-color: v-bind('Color');
				color: #fff;
				border-radius: 10rpx;
			}
			.btn{
				padding: 30rpx 0;
				color: #666;
			}
		}
	}
</style>