<template>
	<view>
		<!--mine/page/page.wxml-->
		<!-- <view class="title">{{ title }}</view> -->
		<view class="content"><rich-text :nodes="params"></rich-text></view>
	</view>
</template>

<script>
// mine/page/page.js
const app = getApp();
const req = require('../../utils/request.js');

export default {
	data() {
		return {
			title: '',
			isXieyi: false, //用户协议
			isYinsi: false, //隐私政策
			isOpen: false,
			isGroup: false,
			params: ''
		};
	},

	components: {},
	props: {},
	onLoad: function(options) {
		this.id = options.id;
		if (options.isXieyi) {
			this.isXieyi = true;
		}
		if (options.isYinsi) {
			this.isYinsi = true;
		}
		if (options.isOpen) {
			this.isOpen = true;
		}
		if (options.isGroup) {
			this.isGroup = true;
		}

		this.title = options.title;
		// if (this.title) {
		// 	uni.setNavigationBarTitle({
		// 		title: this.title
		// 	});
		// }
		this.getData();
	},
	methods: {
		getData() {
			var that = this;
			let url = false;
			let form = {};

			if (that.isXieyi) {
				url = '/api/protocol';
			} else if (that.isYinsi) {
				url = '/api/params/value';
				form.type = 'PRIVACY_AGREEMENT';
			} else {
				url = '/api/help/detail';
				form.id = that.id;
			}
			if (that.isOpen) {
				req.getRequest('/api/config', {}, function(res) {
					that.params = res.OPEN_GROUP;
				});
			} else if (that.isGroup) {
				req.getRequest('/api/config', {}, function(res) {
					that.params = res.Head_Agreement;
				});
			} else {
				req.getRequest(url, form, data => {
					that.setData({
						params: data
					});
				});
			}
		}
	}
};
</script>
<style>
@import './page.css';
</style>
