<template>
  <div class="display">
    <!-- <NavBar /> -->
    <div class="main">
      <div class="content">
        <el-row :gutter="20">
          <el-col :span="4" class="selectors">
            <!-- <el-row class="select-card">
              <div class="title">
                <span>年代</span>
              </div>
              <div class="body">
                <div class="select-group">
                  <div
                    class="select-items"
                    v-for="(item, index) in years"
                    :key="index"
                  >
                    <div class="check-box"></div>
                    <div class="check-value">{{ item }}</div>
                  </div>
                </div>
              </div>
            </el-row> -->
            <!-- <el-row class="select-card">
              <div class="title">
                <span>分类</span>
              </div>
              <div class="body">
                <div class="select-group">
                  <div
                    class="select-items"
                    v-for="(item, index) in dict.culturalRelicType"
                    :key="index"
                  >
                    <div class="check-box">
                    </div>
                    <div class="check-value">{{ item }}</div>
                  </div>
                </div>
              </div>
            </el-row> -->
          </el-col>
          <el-col :span="24" class="rclist">
            <div class="search">
              <el-input
                v-model="keyword"
                class="search-bar"
                @keyup.enter.native="search" clearable
                ><i slot="suffix" class="el-input__icon el-icon-search"></i
              ></el-input>
            </div>
            <div class="display-group">
              <div class="total">
                <span>{{ list.total }}</span
                >件
              </div>
              <!-- <div class="divider"></div> -->
              <el-row :gutter="10">
                <el-col
                  :span="6"
                  class="cr-box"
                  display-item
                  @click.native="handleClick(item)"
                  v-for="(item, index) in list.records"
                  :key="index"
                >
                  <div class="img">
                    <img :src="item.faceImageUrl" alt="" srcset="" />
                    <!-- <div class="collect">
                      <div class="collect-box">
                        <img src="@/assets/imgs/like.png" alt="" srcset="" />
                      </div>
                    </div> -->
                  </div>
                </el-col>
              </el-row>
              <div class="pagination">
                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="Number(list.current)"
                  :page-sizes="[10, 20, 40, 50]"
                  :page-size="Number(list.size)"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="Number(list.total)"
                  class="pagination"
                >
                </el-pagination>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <!-- <Footer /> -->
  </div>
</template>

<script>
// import SearchBar from "@/components/SearchBar";
// import NavBar from "@/components/NavBar";
// import Footer from "@/components/Footer";
import { getCulturalRelicList } from "@/api/culturalRelic";
export default {
  name: "CulturalRelic",
  // components: { SearchBar, NavBar, Footer },
  // components: { SearchBar },
  data() {
    return {
      options: [
        {
          value: "name",
          label: "文物名称",
        },
      ],
      selectValue: "",
      keyword: "",
      currentType: "all",
      list: {
        records: [],
        size: 40,
        current: 1,
        total: 0,
      },
      // years: ["新石器时代", "夏", "商", "春秋", "战国", "秦", "汉", "三国"],
      // types: ["青铜", "石器"],
    };
  },
  // dicts: ["culturalRelicYears", "cultural_relic_texture", "culturalRelicType"],
  created() {
    setTimeout(() => {
      // console.log(this.dicts);
    });
  },
  mounted() {
    this.loadData();
  },
  methods: {
    async loadData() {
      var params = {
        page: this.list.current,
        limit: this.list.size,
      };
      let res = await getCulturalRelicList(params);
      if (res.code == 0) {
        this.list = res.data;
      }
    },

    async search() {
      var params = {
        page: this.list.current,
        limit: this.list.size,
        name: this.keyword,
      };
      console.log("params", params);
      let res = await getCulturalRelicList(params);
      if (res.code == 0) {
        this.list = res.data;
      }
    },
    // 改变页容量
    handleSizeChange(value) {
      this.list.size = value;
      this.loadData();
    },

    // 改变当前显示页
    handleCurrentChange(value) {
      this.list.current = value;
      this.loadData();
    },

    handleClick(item) {
      console.log(item);
      const { crId } = item;
      this.$router.push({
        path: "culturalRelic/" + crId,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
$blue: #1e5fbb;
$text-indent: 16px;
.display {
  width: 100%;
  // background-color: #2069c4;
  // color: #fff;
  .main {
    display: flex;
    align-items: center;
    flex-direction: column;
    padding: 0 60px;
    .search {
      display: flex;
      justify-content: flex-end;
      margin-top: 20px;
      .search-bar {
        margin-bottom: 20px;
        width: 400px;
        border-radius: 48px !important;
      }
    }

    .total {
      margin-bottom: 40px;
    }
    .divider {
      width: 100%;
      height: 1px;
      background-color: $blue;
      margin-bottom: 20px;
    }

    .content {
      width: 100%;
      .selectors {
        margin-top: 80px;

        .select-card {
          width: 100%;
          box-shadow: 0 2px 10px 6px rgba(0, 0, 0, 0.12);
          border-radius: 8px;
          margin-bottom: 16px;
          .title {
            padding: 10px 20px;
            background-color: #1e5fbb;
            border-radius: 8px 8px 0 0;
            color: #fff;
            font-weight: bold;
          }
          .body {
            padding: 10px 20px;
            background-color: #fff;
            border-radius: 0 0 8px 8px;
            .select-items {
              display: flex;
              margin-bottom: 20px;
              cursor: pointer;
              margin-top: 24px;
              .check-box {
                border: 2px solid #563f17;
                width: 20px;
                height: 20px;
                margin-right: 15px;
                i {
                  color: $blue;
                  width: 2px;
                  font-weight: bold;
                }
              }
              .check-value {
                color: #563f17;
                font-size: 14px;
                font-weight: bold;
              }
            }
          }
        }
      }
      .rclist {
        .img {
          width: 100%;
          margin-bottom: 10px;
          position: relative;
          img {
            width: 100%;
          }
          .collect {
            position: absolute;
            right: 20px;
            bottom: 20px;
            .collect-box {
              width: 40px;
              height: 40px;
              display: flex;
              justify-content: center;
              align-items: center;
              background-color: rgba(0, 0, 0, 0.15);
              border-radius: 8px;
              cursor: pointer;
              img {
                width: 20px;
                height: 20px;
                opacity: 0.5;
              }
            }
          }
        }
      }
    }
  }

  .pagination {
    margin-top: 24px;
    display: flex;
    justify-content: center;
  }
}
</style>