<template>
	<view class="content">
		<u-parse :content="article"></u-parse>
	</view>
</template>

<script>
	import { tipsDetail,aboutUs, gradeAgreement, privacyAgreement, cardDesign, ratingStandard, getServiceStandard } from '@/service/agreementArticle.js';
	
	export default {
		data(){
			return {
				id: '',
				article: '',
				type: ''
			}
		},
		onLoad(options){
			this.id = options.id || '';
			if(options.type === 'about_us'){
				this.getAboutUsDetail();
			}else if(options.type === 'grade_agreement'){
				this.getGradeAgreement();
			}else if(options.type === 'privacy_agreement'){
				this.getPrivacyAgreement();
			}else if(options.type === 'card_design'){
				this.getCardDesign();
			}else if(options.type === 'rating_standard'){
				this.getRatingStandard();
			}else if(options.type === 'service_standard'){
				this.getServiceStandard();
			}else{
				this.getTips();
			}
		},
		methods: {
			// 获取关于我们
			async getTips(){
				let res = await tipsDetail(this.id);
				this.article = res.data.datas.content;
				uni.setNavigationBarTitle({
					title: res.data.datas.title
				})
			},
			
			// 获取关于我们
			async getAboutUsDetail(){
				let res = await aboutUs();
				this.article = res.data.datas.content;
				uni.setNavigationBarTitle({
					title: res.data.datas.title
				})
			},
			// 获取快速评级的相关协议
			async getGradeAgreement(){
				let res = await gradeAgreement();
				this.article = res.data.datas.content;
				uni.setNavigationBarTitle({
					title: res.data.datas.title
				})
			},
			// 获取用户隐私协议协议
			async getPrivacyAgreement(){
				let res = await privacyAgreement();
				this.article = res.data.datas.content;
				uni.setNavigationBarTitle({
					title: res.data.datas.title
				})
			},
			// 获取卡砖设计
			async getCardDesign(){
				let res = await cardDesign();
				this.article = res.data.datas.content;
				uni.setNavigationBarTitle({
					title: res.data.datas.title
				})
			},
			// 获取评级标准
			async getRatingStandard(){
				let res = await ratingStandard();
				this.article = res.data.datas.content;
				uni.setNavigationBarTitle({
					title: res.data.datas.title
				})
			},
			async getServiceStandard(){
				let res = await getServiceStandard();
				this.article = res.data.datas.content;
				uni.setNavigationBarTitle({
					title: res.data.datas.title
				})
			},
		}
	}
</script>

<style>
.content{font-size:16px;padding:20px;line-height:2em;}
</style>
