<template>
  <view class="like-page">
    <!-- 页面标题栏 -->
    <view class="page-header">
      <text class="header-title">喜欢我的</text>
    </view>
    
    <!-- 数据加载状态 -->
    <view class="loading-container" v-if="loading">
      <uni-loading type="circle" color="#E91E63"></uni-loading>
      <text class="loading-text">加载中...</text>
    </view>
    
    <!-- 空数据状态 -->
    <view class="empty-container" v-else-if="users.length === 0">
      <text class="empty-icon">😊</text>
      <text class="empty-text">暂无用户喜欢您</text>
      <view class="empty-action">
        <button class="action-btn" @click="goRecommend">完善资料增加曝光</button>
      </view>
    </view>
    
    <!-- 用户列表 -->
    <scroll-view class="user-list" scroll-y="true">
      <view class="user-item" v-for="user in users" :key="user.userId" @click="goUserDetail(user.userId)">
        <image class="user-avatar" :src="user.avatar" mode="aspectFill"></image>
        <view class="user-info">
          <view class="user-basic">
            <text class="user-nickname">{{ user.nickname }}</text>
            <text class="user-age">{{ user.age }}岁</text>
          </view>
          <view class="user-details">
            <text class="detail-item" v-if="user.height">{{ user.height }}cm</text>
            <text class="detail-item" v-if="user.weight">{{ user.weight }}kg</text>
            <text class="detail-item" v-if="user.educationText">{{ user.educationText }}</text>
            <text class="detail-item" v-if="user.salaryText">{{ user.salaryText }}</text>
          </view>
          <view class="user-location" v-if="user.location">
            <text class="location-text">{{ user.location }}</text>
          </view>
        </view>
        <view class="like-status">
          <text class="like-icon">💖</text>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
import api from '@/utils/api.js'

export default {
  data() {
    return {
      users: [],
      loading: true,
      pageNum: 1,
      pageSize: 20,
      hasMore: true
    }
  },
  onLoad() {
    this.loadUsers()
  },
  methods: {
    // 加载喜欢我的用户列表
    async loadUsers() {
      try {
        this.loading = true
        // 不调用真实API，显示空数据
        this.users = []
      } catch (error) {
        console.error('加载喜欢我的用户失败:', error)
        uni.showToast({
          title: '加载失败，请重试',
          icon: 'none'
        })
      } finally {
        this.loading = false
      }
    },
    
    // 跳转到用户详情页
    goUserDetail(userId) {
      uni.navigateTo({
        url: `/pages/recommend/index?userId=${userId}`,
        fail: (err) => {
          console.error('跳转用户详情失败:', err)
          uni.showToast({
            title: '页面不存在',
            icon: 'none'
          })
        }
      })
    },
    
    // 跳转到推荐页面
    goRecommend() {
      uni.navigateTo({
        url: '/pages/profile/index'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.like-page {
  min-height: 100vh;
  background-color: #F5F5F5;
}

.page-header {
  height: 88rpx;
  line-height: 88rpx;
  background-color: #E91E63;
  text-align: center;
  position: relative;
  
  .header-title {
    font-size: 36rpx;
    font-weight: bold;
    color: #FFFFFF;
  }
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100rpx 0;
  
  .loading-text {
    margin-top: 20rpx;
    font-size: 28rpx;
    color: #999999;
  }
}

.empty-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 150rpx 0;
  
  .empty-icon {
    font-size: 120rpx;
    margin-bottom: 30rpx;
  }
  
  .empty-text {
    font-size: 32rpx;
    color: #999999;
    margin-bottom: 40rpx;
  }
  
  .action-btn {
    background: linear-gradient(135deg, #FF6B9D 0%, #E91E63 100%);
    color: #FFFFFF;
    border: none;
    padding: 18rpx 70rpx;
    border-radius: 45rpx;
    font-size: 28rpx;
    font-weight: 600;
    box-shadow: 0 6rpx 20rpx rgba(233, 30, 99, 0.3);
    transition: all 0.3s ease;
    letter-spacing: 1rpx;
    
    &:active {
      transform: translateY(2rpx);
      box-shadow: 0 3rpx 12rpx rgba(233, 30, 99, 0.4);
      background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
    }
  }
}

.user-list {
  padding: 20rpx;
  height: calc(100vh - 88rpx);
}

.user-item {
  display: flex;
  align-items: center;
  background-color: #FFFFFF;
  border-radius: 20rpx;
  padding: 20rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  
  &:active {
    transform: translateY(2rpx);
    box-shadow: 0 1rpx 5rpx rgba(0, 0, 0, 0.05);
  }
  
  .user-avatar {
    width: 120rpx;
    height: 120rpx;
    border-radius: 50%;
    margin-right: 20rpx;
    border: 4rpx solid #FFF9F9;
    box-shadow: 0 4rpx 15rpx rgba(233, 30, 99, 0.2);
  }
  
  .user-info {
    flex: 1;
    
    .user-basic {
      display: flex;
      align-items: center;
      margin-bottom: 10rpx;
      
      .user-nickname {
        font-size: 32rpx;
        font-weight: bold;
        color: #333333;
        margin-right: 15rpx;
      }
      
      .user-age {
        font-size: 28rpx;
        color: #666666;
      }
    }
    
    .user-details {
      display: flex;
      flex-wrap: wrap;
      gap: 15rpx;
      margin-bottom: 10rpx;
      
      .detail-item {
        font-size: 24rpx;
        color: #999999;
        background-color: #F5F5F5;
        padding: 6rpx 15rpx;
        border-radius: 15rpx;
      }
    }
    
    .user-location {
      .location-text {
        font-size: 24rpx;
        color: #999999;
      }
    }
  }
  
  .like-status {
    .like-icon {
      font-size: 40rpx;
      color: #E91E63;
    }
  }
}
</style>
