<template>
	<view class="container">
		<!-- 导航栏 -->
		<view class="navbar">
			<view class="nav-left" @click="goBack">
				<text class="back-icon"><</text>
			</view>
			<view class="nav-title">服务协议</view>
			<view class="nav-right">
				<text class="more-icon">...</text>
				<text class="eye-icon">O</text>
			</view>
		</view>
		
		<!-- 内容区域 -->
		<scroll-view class="content" scroll-y>
			<view class="agreement-list">
				<view class="agreement-item" v-for="(item, index) in agreementList" :key="index" @click="goToDetail(item)">
					<text class="agreement-name">{{ item.name }}</text>
					<text class="arrow-right">></text>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
import { getServiceAgreementList } from '@/api-js/serviceAgreement'
export default {
	data() {
		return {
			agreementList: [
				{ id: 1, name: '用户服务协议', type: 'userService' },
				{ id: 2, name: '用户注册协议', type: 'userRegister' },
				{ id: 3, name: '隐私政策保护', type: 'privacy' }
			]
		}
	},
	onLoad() {
		this.loadAgreementList()
	},
	methods: {
		async loadAgreementList() {
			try {
				const res = await getServiceAgreementList()
				if (res.code === 200 && res.data) {
					this.agreementList = res.data
				}
			} catch (e) {
				console.error('加载服务协议列表失败', e)
			}
		},
		goBack() {
			uni.navigateBack()
		},
		goToDetail(item) {
			uni.navigateTo({
				url: `/pages_user/serviceAgreementDetail?type=${item.type}&id=${item.id}`
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	min-height: 100vh;
	background: #f5f5f5;
	display: flex;
	flex-direction: column;
}

.navbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20rpx 24rpx;
	background: #fff;
	border-bottom: 1rpx solid #f0f0f0;
	
	.nav-left {
		width: 60rpx;
		
		.back-icon {
			font-size: 36rpx;
			color: #333;
			font-weight: bold;
		}
	}
	
	.nav-title {
		flex: 1;
		text-align: center;
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
	}
	
	.nav-right {
		display: flex;
		align-items: center;
		gap: 24rpx;
		width: 60rpx;
		justify-content: flex-end;
		
		.more-icon {
			font-size: 32rpx;
			color: #333;
		}
		
		.eye-icon {
			font-size: 32rpx;
			color: #333;
		}
	}
}

.content {
	flex: 1;
}

.agreement-list {
	background: #fff;
	margin: 24rpx;
	border-radius: 16rpx;
	overflow: hidden;
	
	.agreement-item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 32rpx 24rpx;
		border-bottom: 1rpx solid #f0f0f0;
		
		&:last-child {
			border-bottom: none;
		}
		
		.agreement-name {
			font-size: 28rpx;
			color: #333;
		}
		
		.arrow-right {
			font-size: 32rpx;
			color: #999;
		}
	}
}
</style>


