<template>
	<div class="agreement_index">
		<div class="item mx-1px-bottom" @tap="chageAgreement('privite')">
			<div class="txt">
				隐私协议
			</div>
			<div class="rigth iconfont icon--xiangyoujiantou">
				
			</div>
		</div>
		<div class="item" @tap="chageAgreement('serve')">
			<div class="txt">
				服务协议
			</div>
			<div class="rigth iconfont icon--xiangyoujiantou">
				
			</div>
		</div>
		<view class="mask" v-if="showAgreement">
		
		</view>
		<view class="greement-box" v-if="showAgreement">
			<view class="title mx-1px-bottom">
				{{message}}
			</view>
			<view class="content">
				<u-parse :content="contents" />
			</view>
			<view class="btn mx-1px-top" @tap="chageAgreement">
				确定
			</view>
		</view>
	</div>
</template>

<script>
	import {
		pageLogin,
		getUrl,
		config,
		is
	} from '@/common/js/utils.js';
	import uParse from '@/components/gaoyia-parse/parse.vue';
	export default{
		components: {
			uParse
		},
		data() {
			return{
				showAgreement:false,
				message:'隐私协议',
				contents:''
			}
			
		},
		onLoad(){
		this.getGreementInfo();	
		},
		methods:{
			chageAgreement(type) {
				if(type == 'privite'){
					this.message = '隐私协议';
					this.contents = this.agreement.privacy_agreement
				} else{
					this.message = '服务协议';
					this.contents = this.agreement.service_agreement
				}
				this.showAgreement = !this.showAgreement
			},
			// 获取用户协议
			getGreementInfo() {
				this.$http.get({
					api: 'api/user/agreement'
				}).then(res => {
						res = res.data;
			
						if (res.status) {
							this.agreement =  res.data;
						}
			
				});
			},
		}
	}
	
</script>

<style rel="stylesheet/less" lang="less">
    @import "agreement";
</style>
