<template>
	<u-popup :show="showPrivateBox" @close="" @open="" :round="10">
		<view class="popup-box">
			<view class="weui-half-screen-dialog__hd">
				{{title}}
			</view>
			<view class="weui-half-screen-dialog__bd">
				<text class="weui-half-screen-dialog__tips">{{desc1}}</text>
				<text class="weui-half-screen-dialog__tips color-8BC21F" @click="openPrivacyContract">
					{{urlTitle}}
				</text>
				<text class="weui-half-screen-dialog__tips">{{desc2}}</text>
			</view>
			<view class="weui-half-screen-dialog__ft">
				<button class="weui-btn" @click="handleDisagree">拒绝</button>
				<button id="agree-btn" type="default" open-type="agreePrivacyAuthorization" class="weui-btn agree"
					@agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
			</view>
		</view>
	</u-popup>
</template>

<script>
	export default {
		data() {
			return {
				title: "用户隐私保护提示",
				desc1: "感谢您使用本产品，您使用本产品前应当仔细阅读并同意",
				// urlTitle: "《小程序隐私保护指引》",
				desc2: "当您点击同意并开始使用产品服务时，即表示你已理解并同意该条款内容，该条款将对您产生法律约束力。如您拒绝，将无法更好的体验产品。",
			};
		},

		props: ['showPrivateBox', 'urlTitle'],
		created() {
			console.log('showPrivateBox-----', this.showPrivateBox);
		},
		methods: {
			openPrivacyContract() {
				wx.openPrivacyContract({
					// success: () => {}, // 打开成功
					// fail: () => {}, // 打开失败
					// complete() => {}
				});
			},
			handleAgreePrivacyAuthorization() {
				getApp().globalData.showPrivacy = false;
				this.$emit('confirmP');
			},
			handleDisagree() {

				console.log('handleDisagree()');
				this.$emit('cancleP');
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "./index.scss";
</style>