<!-- ============================= 隐私政策/用户服务条款 ============================= -->
<template>
	<view class="u-content">
		<u-parse :html="content"></u-parse>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: ''
			}
		},
		onLoad(query) {
			const termsType = query?.termsType
			if (termsType) {
				switch (Number(termsType)) {
					case 1:
						uni.setNavigationBarTitle({
							title: '用户服务条款'
						})
						break
					case 2:
						uni.setNavigationBarTitle({
							title: '隐私政策'
						})
						break
				}
				this.getSysterms(termsType)
			}
		},
		methods: {
			getSysterms(termsType) {
				this.$u.api.getSysterms({
						termsType: Number(termsType)
					})
					.then(res => {
						if (res.code === 200) {
							this.content = res.data?.content
						} else {
							this.$refs.uToast.show({
								title: res.msg,
								type: 'error',
							})
						}
					})
					.catch(err => {
						this.$refs.uToast.show({
							title: '系统错误!',
							type: 'error',
						})
					})
			}
		}
	}
</script>

<style lang="scss" scoped>
.u-content {
	padding: 20rpx;
}
</style>
