<template>
	<view>
		<navBar :leftText="navTitle"></navBar>
		<image class="topBg absolute" src="/static/image/mine/myTopBg.png" mode="widthFix"></image>
		<view class="contentC fixed" :style="'top:'+navH+'px;'">
			<text>{{webContent}}</text>
		</view>
	</view>
</template>

<script>
	import { inject } from 'vue'
	import { agreements } from '@/request/api'

	export default {
		data() {
			return {
				navH:inject('navHeight'),
				navTitle:'',
				type:'',	//1.关于我们2.服务条款3.隐私协议
				webContent:'',
			}
		},
		onLoad(e) {
			if(e.type)
			{
				this.type = e.type
				this.getUserInfoData()
				if(e.type==1)
				{
					this.navTitle = '关于我们'
				}else if(e.type==2)
				{
					this.navTitle = '服务条款'
				}else if(e.type==3)
				{
					this.navTitle = '隐私协议'
				}
			}
		},
		methods: {
			/**
			 * 获取用户信息数据
			 */
			getUserInfoData()
			{
				agreements().then(res=>{
					if(res.code==200)
					{
						if(this.type==1)
						{
							//关于我们
							this.webContent = res.data.agreements.about_us.content
						}else if(this.type==2)
						{
							//服务条款
							this.webContent = res.data.agreements.service_terms.content
						}else if(this.type==3)
						{
							//隐私协议
							this.webContent = res.data.agreements.privacy_policy.content
						}
					}else 
						wx.showToast({
							title:res.message,
						})
				}).catch(error=>{
					
				})
			}	
		}
	}
</script>

<style lang="less">
.topBg
{
	top: 0;
	left: 0;
	width: 100%;
	height: auto;
}
.contentC 
{
	background-color: white;
	left: 0;
	right: 0;
	bottom: 0;
	margin-top: 10rpx;
	padding: 50rpx 25rpx;
	overflow-y: scroll;
}
</style>
