<template>
  <view class="profile-page">
    <!-- 状态栏 -->
    <view class="status-bar">
      <text class="time">9:41</text>
      <view class="status-icons">
        <text class="signal">📶</text>
        <text class="wifi">📶</text>
        <text class="battery">🔋</text>
      </view>
    </view>

    <!-- 头部用户信息 -->
    <view class="user-header">
      <view class="user-info">
        <view class="avatar">
          <text class="avatar-text">张</text>
        </view>
        <view class="user-details">
          <text class="user-name">张珊珊</text>
          <text class="user-phone">138****8888</text>
        </view>
      </view>
      <view class="edit-btn">
        <text class="edit-icon">✏️</text>
      </view>
    </view>

    <!-- 统计信息 -->
    <view class="stats-section">
      <view class="stat-item">
        <text class="stat-number">2</text>
        <text class="stat-label">租赁设备</text>
      </view>
      <view class="stat-item">
        <text class="stat-number">¥200.20</text>
        <text class="stat-label">累计租金</text>
      </view>
      <view class="stat-item">
        <text class="stat-number">365</text>
        <text class="stat-label">租赁天数</text>
      </view>
    </view>

    <!-- 功能菜单 -->
    <view class="menu-section">
      <view class="menu-group">
        <view class="menu-item" @click="goToMyLeases">
          <view class="menu-left">
            <text class="menu-icon">📋</text>
            <text class="menu-title">我的租赁</text>
          </view>
          <text class="menu-arrow">></text>
        </view>
        
        <view class="menu-item" @click="goToPayments">
          <view class="menu-left">
            <text class="menu-icon">💰</text>
            <text class="menu-title">支付记录</text>
          </view>
          <text class="menu-arrow">></text>
        </view>
        
        <view class="menu-item" @click="goToAddress">
          <view class="menu-left">
            <text class="menu-icon">📍</text>
            <text class="menu-title">收货地址</text>
          </view>
          <text class="menu-arrow">></text>
        </view>
      </view>

      <view class="menu-group">
        <view class="menu-item" @click="goToSettings">
          <view class="menu-left">
            <text class="menu-icon">⚙️</text>
            <text class="menu-title">设置</text>
          </view>
          <text class="menu-arrow">></text>
        </view>
        
        <view class="menu-item" @click="goToHelp">
          <view class="menu-left">
            <text class="menu-icon">❓</text>
            <text class="menu-title">帮助中心</text>
          </view>
          <text class="menu-arrow">></text>
        </view>
        
        <view class="menu-item" @click="goToAbout">
          <view class="menu-left">
            <text class="menu-icon">ℹ️</text>
            <text class="menu-title">关于我们</text>
          </view>
          <text class="menu-arrow">></text>
        </view>
      </view>
    </view>

    <!-- 退出登录 -->
    <view class="logout-section">
      <button class="logout-btn" @click="handleLogout">退出登录</button>
    </view>
  </view>
</template>

<script>
export default {
  name: 'ProfilePage',
  data() {
    return {
      userInfo: {
        name: '张珊珊',
        phone: '138****8888',
        avatar: '张'
      },
      stats: {
        leaseCount: 2,
        totalRent: '¥200.20',
        leaseDays: 365
      }
    }
  },
  methods: {
    goToMyLeases() {
      uni.showToast({
        title: '我的租赁',
        icon: 'none'
      })
    },
    goToPayments() {
      uni.showToast({
        title: '支付记录',
        icon: 'none'
      })
    },
    goToAddress() {
      uni.showToast({
        title: '收货地址',
        icon: 'none'
      })
    },
    goToSettings() {
      uni.showToast({
        title: '设置',
        icon: 'none'
      })
    },
    goToHelp() {
      uni.showToast({
        title: '帮助中心',
        icon: 'none'
      })
    },
    goToAbout() {
      uni.showToast({
        title: '关于我们',
        icon: 'none'
      })
    },
    handleLogout() {
      uni.showModal({
        title: '确认退出',
        content: '确定要退出登录吗？',
        success: (res) => {
          if (res.confirm) {
            uni.showToast({
              title: '已退出登录',
              icon: 'success'
            })
            // 跳转到登录页
            setTimeout(() => {
              uni.reLaunch({
                url: '/pages/login/login'
              })
            }, 1500)
          }
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.profile-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
  padding-bottom: 120rpx; /* 为tabBar留出空间 */
}

// 状态栏
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20rpx 40rpx;
  color: #fff;
  font-size: 28rpx;
  
  .status-icons {
    display: flex;
    gap: 10rpx;
  }
}

// 用户头部
.user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 40rpx;
  color: #fff;
  
  .user-info {
    display: flex;
    align-items: center;
    
    .avatar {
      width: 120rpx;
      height: 120rpx;
      background: rgba(255, 255, 255, 0.2);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-right: 30rpx;
      
      .avatar-text {
        font-size: 48rpx;
        font-weight: bold;
        color: #fff;
      }
    }
    
    .user-details {
      .user-name {
        display: block;
        font-size: 36rpx;
        font-weight: bold;
        margin-bottom: 10rpx;
      }
      
      .user-phone {
        font-size: 28rpx;
        opacity: 0.8;
      }
    }
  }
  
  .edit-btn {
    width: 60rpx;
    height: 60rpx;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    
    .edit-icon {
      font-size: 32rpx;
    }
  }
}

// 统计信息
.stats-section {
  background: #fff;
  margin: 0 40rpx;
  border-radius: 20rpx;
  padding: 40rpx;
  display: flex;
  justify-content: space-around;
  box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.1);
  
  .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    
    .stat-number {
      font-size: 36rpx;
      font-weight: bold;
      color: #ff9a9e;
      margin-bottom: 10rpx;
    }
    
    .stat-label {
      font-size: 24rpx;
      color: #666;
    }
  }
}

// 菜单区域
.menu-section {
  margin: 40rpx;
  
  .menu-group {
    background: #fff;
    border-radius: 20rpx;
    margin-bottom: 30rpx;
    overflow: hidden;
    box-shadow: 0 5rpx 20rpx rgba(0, 0, 0, 0.05);
    
    .menu-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 30rpx 40rpx;
      border-bottom: 2rpx solid #f5f5f5;
      
      &:last-child {
        border-bottom: none;
      }
      
      .menu-left {
        display: flex;
        align-items: center;
        
        .menu-icon {
          font-size: 40rpx;
          margin-right: 30rpx;
        }
        
        .menu-title {
          font-size: 32rpx;
          color: #333;
        }
      }
      
      .menu-arrow {
        font-size: 28rpx;
        color: #999;
      }
      
      &:active {
        background: #f8f9fa;
      }
    }
  }
}

// 退出登录
.logout-section {
  margin: 40rpx;
  
  .logout-btn {
    width: 100%;
    height: 100rpx;
    background: #fff;
    color: #ff4757;
    border: 2rpx solid #ff4757;
    border-radius: 50rpx;
    font-size: 32rpx;
    font-weight: bold;
    
    &:active {
      background: #ff4757;
      color: #fff;
    }
  }
}
</style> 