<template>
	<view class="privacy-page">
		<erp-nav-bar :title="title" />

		<scroll-view scroll-y class="content-scroll" :style="{ height: scrollHeight }">
			<view class="article-body">
				<rich-text :nodes="privacyNodes"></rich-text>
			</view>
		</scroll-view>
	</view>
</template>

<script>
import { getAgreement } from '@/api/system/agreement.js';
import ErpNavBar from '@/components/erp-nav-bar.vue';
export default {
	components: { ErpNavBar },
	data() {
		return {
			statusBarHeight: 20,
			title: '',
			privacyNodes: ''
		}
	},
	computed: {
		scrollHeight() {
			return `calc(100vh - ${this.statusBarHeight + 44}px)`;
		}
	},
	async onLoad() {
		this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 20;
		try {
			const res = await getAgreement(2);
			this.title = res.data.title;
			this.privacyNodes = res.data.content;
		} catch (e) {
			console.error('[隐私政策] 加载失败', e);
			uni.showToast({ title: e || '加载隐私政策失败', icon: 'none' });
		}
	},
	methods: {
		goBack() { uni.navigateBack(); }
	}
}
</script>

<style scoped>
.privacy-page {
	width: 100vw;
	height: 100vh;
	background: #ffffff;
	display: flex;
	flex-direction: column;
}


.content-scroll {
	width: 100%;
}

.article-body {
	padding: 40rpx;
	padding-top: 20rpx;
}

.title {
	font-size: 40rpx;
	font-weight: bold;
	color: #1a1a1a;
	margin-bottom: 16rpx;
	text-align: center;
}

.update-time {
	font-size: 24rpx;
	color: #999;
	margin-bottom: 40rpx;
	text-align: center;
}

.safe-bottom-hint {
	margin-top: 80rpx;
	text-align: center;
	color: #52c41a;
	font-size: 24rpx;
	opacity: 0.6;
}
</style>
