<template>
	<view class="assemble">
		<view class="html-style" v-html="text"></view>
	</view>
</template>

<script>
	import agreement from '@/api/agreement.js';
	export default {
		data() {
			return {
				type: 1, //类型 1为用户协议,2为隐私策略
				text: '',
			}
		},
		onLoad(item) {
			console.log(item.type, '类型')
			this.init(item.type)
		},
		methods: {
			//初始化拿数据的接口
			init(type) {
				if (type == 1) {
					//获取用户协议
					agreement.userAgreement('service').then(res => {
						if(res.code == 1){
							this.text = res.data.content
						}else{
							this.text = ''
						}					
					})
					uni.setNavigationBarTitle({
						title: '用户协议'
					});
				} else if (type == 2) {
					//获取隐私策略
					agreement.userAgreement('privacy').then(res => {
						if(res.code == 1){
							this.text = res.data.content
						}else{
							this.text = ''
						}					
					})
					uni.setNavigationBarTitle({
						title: '隐私策略'
					});
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.assemble {
		width: 100%;
		height: 100vh;
		overflow: auto;
		background-color: #fff;
	}

	.html-style {
		padding: 10rpx 20rpx;
		line-height: 1.8;
		font-size: 30rpx;
	}
</style>