<template>
	<view class="page-protocal">
		<view class="logs">  
			<view class="and-home">
				<image src="/static/images/log2.png" mode="heightFix" class="img"></image>
			</view>
			<view class="log">
				<image src="/static/images/log1.png" mode="heightFix" class="img"></image>
			</view>
		</view> 
		<uni-popup ref="popProtocal" :is-mask-click="false" mask-background-color="rgba(0,0,0,0)">
			<view class="protocal-content">
				<view class="title">服务协议与隐私政策</view>
				<view class="content">
						<view class="pro"> 
							<rich-text :nodes="info"></rich-text>
						</view> 
				</view> 
				<view class="btns">
					<view class="btn"><button class="btn-disagree" @click="disagree">不同意</button></view>
					<view class="btn" v-if="delay>0"><button class="btn-agree">({{delay}})同意</button></view>
					<view class="btn" v-else><button class="btn-agree1" @click="onAgree">同意</button></view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info:null,
				delay:6,
				timer:null,
			};
		}, 
		onReady() {
			this.$refs.popProtocal.open("bottom"); 
			this.initProtocal();
			this.delay=3;
			this.timer=setInterval(()=>{
				this.delay--;
				if(this.delay<=0){
					clearInterval(this.timer);
				}
			},1000);
		},
		methods:{
			
			disagree(e){
				this.$refs.popProtocal.close();
			},
				
			onAgree(e){
				uni.setStorageSync("protocal",true);
				uni.switchTab({
					url:'/pages/home/home'
				})
			},
			initProtocal(e){ 
				let _this=this; 
				_this.$http.request('system/protocal', { 
				}, "", "", true).then(res => { 
					 _this.info=res.data.info;  
				}).catch(err => {}) 
			},
		}
	}
</script>

<style lang="scss">
@import './protocal.scss'
</style>
