<template>
	<view class="page">
		<!-- 自定义导航栏 -->
		<view class="navbar">
			<view class="nav-back" @click="goBack">
				<image src="/static/ic_back.png" class="back-icon" mode="aspectFit"></image>
			</view>
			<text class="nav-title">{{ $t('me.privacyPolicy') }}</text>
		</view>
		
		<!-- 内容区域 -->
		<view class="content-container">
			<view class="content-box">
				<text v-if="loading" class="loading-text">加载中...</text>
				<text v-else-if="!content" class="empty-text">暂无内容</text>
				<text v-else class="content-text">{{ content }}</text>
			</view>
		</view>
	</view>
</template>

<script>
import Config from '@/modules/Config.js'

export default {
	data() {
		return {
			content: '',
			loading: true
		}
	},
	onLoad() {
		this.loadContent()
	},
	methods: {
		goBack() {
			uni.navigateBack()
		},
		async loadContent() {
			try {
				this.loading = true
				const config = await Config.getPublicConfig()
				this.content = config.privacy_policy || ''
			} catch (error) {
				console.error('加载隐私政策失败:', error)
			} finally {
				this.loading = false
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.page {
	height: 100vh;
	background-color: #F3F4F8;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.navbar {
	width: 100%;
	padding-top: 100rpx;
	padding-bottom: 20rpx;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	position: relative;
	background-color: #fff;
	flex-shrink: 0;
	
	.nav-back {
		position: absolute;
		left: 32rpx;
		width: 80rpx;
		height: 50rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		
		.back-icon {
			width: 48rpx;
			height: 48rpx;
		}
	}
	
	.nav-title {
		font-size: 34rpx;
		font-weight: 500;
		color: #333;
	}
}

.content-container {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.content-box {
	padding: 30rpx;
	background-color: #fff;
	margin: 20rpx;
	border-radius: 16rpx;
	min-height: 200rpx;
}

.content-text {
	font-size: 28rpx;
	color: #333;
	line-height: 1.8;
	white-space: pre-wrap;
	word-break: break-all;
}

.loading-text,
.empty-text {
	font-size: 28rpx;
	color: #999;
	text-align: center;
	display: block;
	padding: 60rpx 0;
}
</style>
