<template>
  <view class="agreement-page">
    <!-- 顶部渐变背景区域 -->
    <view class="header-bg" :style="{ paddingTop: statusBarHeight + 'px' }">
      <view class="header-content">
        <view class="back-btn" @click="handleBack">
          <text class="back-icon">‹</text>
        </view>
        <text class="header-title">用户协议</text>
        <view class="placeholder"></view>
      </view>
    </view>
    
    <!-- 页面内容 -->
    <view class="page-content">
      <!-- 协议列表 -->
      <view class="agreement-list">
        <!-- 用户协议 -->
        <view class="list-item" @click="handleUserAgreement">
          <view class="item-left">
            <image class="item-icon" src="/static/pages/my/agreement/user.png" mode="aspectFit" />
            <view class="item-info">
              <text class="item-title">用户协议</text>
              <text class="item-desc">了解使用本应用的相关条款</text>
            </view>
          </view>
          <text class="arrow">›</text>
        </view>
        
        <!-- 隐私协议 -->
        <view class="list-item" @click="handlePrivacyPolicy">
          <view class="item-left">
            <image class="item-icon" src="/static/pages/my/agreement/privacy.png" mode="aspectFit" />
            <view class="item-info">
              <text class="item-title">隐私政策</text>
              <text class="item-desc">了解我们如何保护您的隐私</text>
            </view>
          </view>
          <text class="arrow">›</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref, onMounted } from 'vue'

// 状态栏高度
const statusBarHeight = ref(0)

onMounted(() => {
  // 获取系统信息
  const windowInfo = uni.getWindowInfo()
  statusBarHeight.value = windowInfo.statusBarHeight || 0
})

// 返回上一页
const handleBack = () => {
  const pages = getCurrentPages()
  if (pages.length > 1) {
    uni.navigateBack()
  } else {
    uni.reLaunch({
      url: '/pages/home/index'
    })
  }
}

// 用户协议
const handleUserAgreement = () => {
  uni.navigateTo({
    url: '/pages/my/aggreement/detail?type=user'
  })
}

// 隐私协议
const handlePrivacyPolicy = () => {
  uni.navigateTo({
    url: '/pages/my/aggreement/detail?type=privacy'
  })
}
</script>

<style lang="scss" scoped>
.agreement-page {
  width: 100%;
  min-height: 100vh;
  background-color: #f5f5f5;
  
  // 顶部渐变背景
  .header-bg {
    background: linear-gradient(180deg, #1ec9c9 0%, #1eb8b8 100%);
    
    .header-content {
      height: 88rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 24rpx;
      
      .back-btn {
        width: 60rpx;
        height: 60rpx;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        
        .back-icon {
          font-size: 56rpx;
          color: #ffffff;
          font-weight: 300;
        }
      }
      
      .header-title {
        flex: 1;
        text-align: center;
        font-size: 32rpx;
        font-weight: 600;
        color: #ffffff;
      }
      
      .placeholder {
        width: 60rpx;
      }
    }
  }
  
  // 页面内容
  .page-content {
    padding: 24rpx;
    
    // 协议列表
    .agreement-list {
      .list-item {
        background: #ffffff;
        border-radius: 16rpx;
        padding: 32rpx 24rpx;
        margin-bottom: 16rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
        
        &:active {
          background-color: #f8f8f8;
        }
        
        .item-left {
          flex: 1;
          display: flex;
          align-items: center;
          
          .item-icon {
            width: 40rpx;
            height: 40rpx;
            margin-right: 24rpx;
          }
          
          .item-info {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 8rpx;
            
            .item-title {
              font-size: 28rpx;
              color: #333333;
              font-weight: 500;
            }
            
            .item-desc {
              font-size: 24rpx;
              color: #999999;
              line-height: 1.4;
            }
          }
        }
        
        .arrow {
          font-size: 40rpx;
          color: #cccccc;
          font-weight: 300;
          margin-left: 16rpx;
        }
      }
    }
  }
}
</style>
