<template>
  <page-layout :menus="state.menus">
    <el-row :gutter="20">
      <el-col v-for="(item, index) in state.data" :key="index" :span="12">
        <el-card class="storage-card" shadow="hover">
          <div class="storage-content">
            <div class="storage-content-top" @click="toLink(item)">
              <el-image :src="item.imageUrl" fit="cover" class="storage-image" />
              <div class="storage-info">
                <h3 class="storage-title">{{ item.title }}</h3>
                <div class="storage-desc">
                  <span>{{ item.description }}</span>
                  <i></i>
                </div>
                <div class="storage-tags">
                  <el-tag effect="plain" round>延长仓储</el-tag>
                  <el-tag effect="plain" round>保鲜储存</el-tag>
                </div>
                <div class="storage-location">
                  <el-icon><Location /></el-icon>
                  {{ item.location }}
                </div>
              </div>
            </div>
            <div class="storage-price">
              <div class="storage-price-left">
                <span class="price-label">报价</span>
                <span class="price-amount">¥{{ item.price }}/间/月</span>
              </div>
              <el-button type="success" class="contact-btn">
                <el-icon><ChatDotRound /></el-icon>
                <span>联系卖家</span>
              </el-button>
            </div>
            <div v-if="item.rank" class="rank-badge">
              {{ item.rank }}
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <page-pagination :total="20" @current-change="currentChange" />
  </page-layout>
</template>
<script setup name="page-menu">
import { ref, reactive, watch } from 'vue';
import { getAssetsFile } from '@/utils';
import { useRoute, useRouter } from 'vue-router';
import warehouseLogisticsRoutes from '@/router/modules/warehouseLogistics';

const route = useRoute();
const router = useRouter();

const state = reactive({
  menus: warehouseLogisticsRoutes[0].children,
  query: {
    current: 1,
  },
  data: [
    {
      imageUrl: '/storage1.jpg',
      title: '果蔬保鲜仓储',
      description: '绿鲜蔬选果蔬仓储中心 ',
      location: '临沧市-耿马县',
      price: '600.0',
      rank: '1',
    },
    {
      imageUrl: '/storage2.jpg',
      title: '果蔬保鲜仓储',
      description: '绿鲜蔬选果蔬仓储中心',
      location: '临沧市-耿马县',
      price: '600.0',
      rank: '',
    },
    {
      imageUrl: '/storage3.jpg',
      title: '果蔬保鲜仓储',
      description: '绿鲜蔬选果蔬仓储中心 ',
      location: '临沧市-耿马县',
      price: '600.0',
      rank: '3',
    },
  ],
});

const currentChange = (current) => {
  state.query.current = current;
};

const toLink = (row) => {
  router.push({
    path: '/sub-operation-service/warehouse-detail',
    query: { id: row?.id ?? '100' },
  });
};
</script>
<style lang="scss" scoped>
.storage-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  border: 0;
  border-radius: 24px;
}
.storage-content {
  @include flex-column;

  gap: 16px;
  &-top {
    @include flex-row;

    align-items: center;
  }
}
.storage-image {
  margin-right: 16px;
  width: 120px;
  height: 120px;
  border-radius: 8px;
  object-fit: cover;
}
.storage-info {
  padding-right: 50px;
  flex: 1;
  cursor: pointer;
}
.storage-title,
.storage-desc,
.storage-tags,
.storage-location {
  overflow: hidden;
  margin: 10px 0;
  width: 100%;
}
.storage-title {
  font-size: 20px;
  font-weight: 700;
  color: #000000;
  @include ellipsis;
}
.storage-desc {
  font-size: 16px;
  color: #999999;
  @include ellipsis;
  i {
    display: inline-block;
    width: 20px;
    height: 20px;
  }
}
.storage-tags {
  span {
    margin-right: 10px;
  }
}
.storage-location {
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 400;
  color: #000000;
}
.storage-price {
  display: flex;
  align-items: center;
  &-left {
    flex: 1;
  }
}
.price-label {
  margin-right: 10px;
  font-size: 16px;
  color: #999999;
}
.price-amount {
  font-size: 20px;
  font-weight: 700;
  color: $color-primary;
}
.contact-btn {
  width: 152px;
  height: 48px;
  font-size: 20px;
  border-radius: 8px;
  background: #25bf82 !important;
  :deep(.el-icon) {
    margin-right: 10px;
  }
}
.rank-badge {
  position: absolute;
  top: 0;
  right: 20px;
  width: 80px;
  height: 80px;
}
</style>
