<template>
  <div class="order-management">
    <!-- 导航栏 -->
    <div class="nav-bar">
      <div class="back-btn" @click="$router.back()">
        <i class="arrow-left"></i>
      </div>
      <div class="title">订单管理</div>
    </div>

    <!-- 订单列表 -->
    <div class="content">
      <div class="order-list">
        <div class="mining-card" v-for="item in miningList" :key="item.id">
          <div class="mining-card-header">
            <div class="header-left">
              <div class="mining-image">
                <img :src="item.miner_datail.images" alt="mining image">
              </div>
              <div class="mining-title">{{ item.miner_datail.title }}</div>
            </div>
            <div class="earnings-amount">收益中</div>
          </div>
          
          <div class="u-line"></div>
          
          <div class="earnings-details">
            <div class="detail-item">
              <span class="detail-label">日收益</span>
              <span class="detail-value">{{ ((item.money * item.start_output) / 100).toFixed(2) }} 元</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">收益期限</span>
              <span class="detail-value">{{ item.cycle }} 天</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">已获得医疗补贴</span>
              <span class="detail-value">{{ item.miner_datail.computing_power }}.00元</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">参与价格</span>
              <span class="detail-value">{{ item.money }} 元</span>
            </div>
          </div>
          
          <div class="u-line"></div>
          
          <div class="order-footer">
            <div class="order-date">{{ item.addtime }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getMinerInfo } from '@/api/profile';

export default {
  name: 'OrderManagement',
  data() {
    return {
      miningList: [],
      page: 1,
      size: 10
    }
  },
  methods: {
    async fetchMinerInfo() {
      try {
        const formData = new FormData();
        formData.append('page', this.page);
        formData.append('size', this.size);
        
        const response = await getMinerInfo(formData);
        if (response.data && response.data.mining_list) {
          this.miningList = response.data.mining_list;
        }
      } catch (error) {
        console.error('获取矿机信息失败:', error);
      }
    }
  },
  created() {
    this.fetchMinerInfo();
  }
}
</script>

<style scoped>
.order-management {
  min-height: 100vh;
  background: linear-gradient(to bottom, #2f9580 0%, #4fb3a1 100%);
}

.nav-bar {
  height: 56px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: #fff;
  display: flex;
  align-items: center;
  position: relative;
  padding: 0 15px;
}

.back-btn {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.arrow-left {
  width: 12px;
  height: 12px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}

.title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: 600;
}

.content {
  padding: 20px;
  min-height: calc(100vh - 56px);
}

.order-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mining-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.mining-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.mining-card-header {
  background: linear-gradient(135deg, #2f9580 0%, #4fb3a1 100%);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mining-image {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.mining-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mining-title {
  font-size: 16px;
  color: #fff;
  font-weight: 600;
}

.earnings-amount {
  color: #fff;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 500;
}

.u-line {
  margin: 0;
  border-bottom: 1px solid #f3f4f6;
  width: 100%;
}

.earnings-details {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-label {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

.detail-value {
  font-size: 15px;
  color: #374151;
  font-weight: 600;
}

.order-footer {
  padding: 16px 20px;
  background: #f8f9fa;
}

.order-date {
  font-size: 14px;
  color: #6b7280;
  font-weight: 500;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .nav-bar {
    height: 50px;
    padding: 0 12px;
  }
  
  .back-btn {
    width: 36px;
    height: 36px;
  }
  
  .title {
    font-size: 16px;
  }
  
  .content {
    padding: 16px;
  }
  
  .order-list {
    gap: 12px;
  }
  
  .mining-card-header {
    padding: 12px 16px;
  }
  
  .header-left {
    gap: 10px;
  }
  
  .mining-image {
    width: 40px;
    height: 40px;
  }
  
  .mining-title {
    font-size: 14px;
  }
  
  .earnings-amount {
    font-size: 12px;
    padding: 4px 10px;
  }
  
  .earnings-details {
    padding: 16px;
    gap: 16px;
  }
  
  .detail-item {
    gap: 6px;
  }
  
  .detail-label {
    font-size: 12px;
  }
  
  .detail-value {
    font-size: 14px;
  }
  
  .order-footer {
    padding: 12px 16px;
  }
  
  .order-date {
    font-size: 13px;
  }
}
</style> 