<template>
	<uni-popup ref="agreeFirstDialog" :animation="false" :is-mask-click="false"
	 mask-background-color="rgba(255, 255, 255, 0.6);">
	 <view class="agree-first-sections-dialog">
			<view class="sections-content-box">
				<view class="agree-tip">我们将通过<text @click="agreeBtn('yhxy')">《用户协议》</text>和<text @click="agreeBtn('ystk')">《隐私政策》</text> 向您介绍我们为您提供的服务、我们如何处理个人信息以及您享有的权利。点击“同意”按钮，表示您已知情并同意以上协议。</view>
				<view class="first-confirm-btn" @click="confirmBtn">同意</view>
				<text class="not-confirm-btn" @click="handleClose">不同意</text>
			</view>
	 </view>
	</uni-popup>
	<agree-content-dialog ref="agreeContentDialogRef" :agreeType="agreeType"></agree-content-dialog>
</template>

<script setup>
	import { ref } from 'vue';
	import agreeContentDialog from './agreeContentDialog.vue';
	const agreeContentDialogRef = ref(null);
	const agreeType = ref(null);
	const agreeFirstDialog = ref(null); // 索引
	const $emit = defineEmits(['first-confirm-btn'])
	const agreeBtn = (data) => {
		if (data === 'yhxy') {
			agreeType.value = 'yhxy'
		} else {
			agreeType.value = 'ystk'
		}
		agreeContentDialogRef.value.handleShow();
	};
	// 打开弹窗
	function handleShow() {
		agreeFirstDialog.value.open();
	}
	// 关闭弹窗
	function handleClose() {
		agreeFirstDialog.value.close();
	}
	// 同意并登录按钮
	function confirmBtn(){
		$emit('first-confirm-btn');
		agreeFirstDialog.value.close();
	}
	defineExpose({
			handleShow
		})
</script>

<style>
</style>