<template>
	<view class="container">
		<u-modal :title="$tt('bindRegister.policy5')" :show="true" width="600rpx" closeOnClickOverlay showCancelButton>
			<text class="content">
				<text>{{$tt('bindRegister.policy6')}}</text>
				<text class="link" @click="handleGoToPrivacy">{{$tt('bindRegister.policy1')}}</text>
				<text class="link" @click="handleGoToService">{{$tt('bindRegister.policy2')}}</text>
				<text class="link" @click="handleGoToStatement">{{$tt('bindRegister.policy3')}}</text>
				<text class="link" @click="handleGoToCommonBill">{{$tt('bindRegister.policy4')}}</text>
				<text>{{$tt('bindRegister.policy7')}}</text>
			</text>
			<u-button slot="confirmButton" type="primary" customStyle=" color: #fff; border-radius: 15rpx;" :text="$tt('bindRegister.agree0')"
				@click="handleAgree"></u-button>
			<u-button slot="confirmButton" customStyle="margin-top: 10px; border: none; background-color: transparent;"
				:text="$tt('bindRegister.agree1')" @click="handleDisagree"></u-button>
		</u-modal>
	</view>
</template>

<script>
	import projectConfig from '@/env.config.js';

	export default {
		data() {
			return {};
		},
		onLoad() {
			this.loadSelectedLanguage();
		},
		methods: {
			// 隐私政策
			handleGoToPrivacy() {
				let title = this.$tt('login.privacyPolicy');
				let url = projectConfig.officialWebUrl + 'privacy-policy.html';
				uni.navigateTo({
					url: `/pages/common/webview/index?title=${title}&url=${url}`
				});
			},
			// 服务协议
			handleGoToService() {
				let title = this.$tt('login.serviceAgreement');
				let url = projectConfig.officialWebUrl + 'service-agreement.html';
				uni.navigateTo({
					url: `/pages/common/webview/index?title=${title}&url=${url}`
				});
			},
			// 儿童隐私保护声明
			handleGoToStatement() {
				let title = this.$tt('login.childProtectionStatement');
				let url = projectConfig.officialWebUrl + 'child-protection-statement.html';
				uni.navigateTo({
					url: `/pages/common/webview/index?title=${title}&url=${url}`
				});
			},
			// 第三方信息共享清单
			handleGoToCommonBill() {
				let title = this.$tt('login.commonBill');
				let url = projectConfig.officialWebUrl + 'common-bill.html';
				uni.navigateTo({
					url: `/pages/common/webview/index?title=${title}&url=${url}`
				});
			},
			//点击同意
			handleAgree() {
				uni.setStorageSync('isFirstOpen', true);
				uni.switchTab({
					url: '/pages/tabBar/home/index',
				});
			},
			//点击不同意
			handleDisagree() {
				uni.setStorageSync('isFirstOpen', false);
				this.exitApp(); // 调用退出方法  
				// uni.navigateBack({
				// 	delta: 50
				// });
			},
			exitApp() {
				// #ifdef APP
				// App 退出  
				uni.exit();
				// #endif
				// #ifdef MP-WEIXIN
				// 小程序退出
				uni.exitMiniProgram();
				// #endif
				// #ifdef H5
				// H5退出
				window.close(); //关闭窗口 
				// #endif
			},
			//获取语言
			loadSelectedLanguage() {
				// 获取之前保存的语言设置
				const selectedLanguage = wx.getStorageSync('language');
				// 如果获取到了，使用该语言设置
				if (selectedLanguage) {
					this.$i18n.locale = this.applicationLocale;
				} else {
					// 如果没有获取到，使用默认设置
					this.$i18n.locale = 'zh-CN';
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		text-align: center;

		.content {
			font-size: 28rpx;

			.link {
				color: #00aaff;
			}
		}
	}
</style>