<template>
	<view class="page">
		<!-- <view class="" style="text-align: center;">{{contenttitle}}</view> -->
		<u-parse :content="content"></u-parse>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: "",
				contenttitle:'',
				language:'zh-CN',
				code:''
			};
		},
		onLoad(options) {
			if (uni.getStorageSync("language") != "") {
				this.language = uni.getStorageSync("language");
			}
			if(options.code){
				this.code = options.code
			}
		},
		methods: {
			
			getAgreementContent(code) {
				uni.$u.http.get(`/api/agreement?code=`+code ).then((res) => {
					if (this.language == 'zh-CN') {
						this.content = res.content_cn
						this.contenttitle = res.name_cn
					}
					if (this.language == 'en-US') {
						this.content = res.content_en
						this.contenttitle = res.name_en
					}
					if (this.language == 'es-ES') {
						this.content = res.content_es
						this.contenttitle = res.content_ita
					}
					if (this.language == 'it-IT') {
						this.content = res.content_cn
						this.contenttitle = res.name_ita
					}
					uni.setNavigationBarTitle({
						title:this.contenttitle
					})
				});
			},
		},
		mounted() {
			this.getAgreementContent(this.code);
		},
	};
</script>

<style>
	.page {
		width: 94vw;
		background-color: #fff;
		padding: 0 24rpx;
		font-size: 28rpx;
		color: #222;
		opacity: 0.6;
		min-height: calc(100vh);
	}
</style>