<template>
  <div class="display">
    <!-- <NavBar /> -->
    <div class="main">
      <div class="content">
        <el-row :gutter="20">
          <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> -->
              <SearchBar @search="search" />
            </div>
            <div class="display-group">
              <!-- <div class="total">
                <span>{{ list.total }}</span
                >件
              </div>
              <div class="divider"></div> -->
              <el-row :gutter="60">
                <el-col
                  :span="6"
                  class="display-item"
                  @click.native="handleClick(item)"
                  v-for="(item, index) in list.records"
                  :key="index"
                >
                  <div class="img" v-if="item.faceImageUrl">
                    <img
                      :src="item.faceImageUrl"
                      alt=""
                      srcset=""
                      v-if="item.faceImageUrl"
                      width="100%"
                      @error="defImg"
                    />
                    <img
                      v-else
                      src="@/assets/404_images/no-pic.png"
                      alt=""
                      width="100%"
                      height="100%"
                    />
                    <div class="desc">
                      <span class="name">{{ item.title }}</span>
                      <!-- <span class="deptName">{{ item.deptName }}</span> -->
                    </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 { getList } from "@/api/display";
// import defaultImg from "@/assets/404_images/no-pic.png";
export default {
  name: "CulturalRelic",
  // components: { SearchBar, NavBar, Footer },
  components: { SearchBar },
  data() {
    return {
      selectValue: "",
      keyword: "",
      currentType: "all",
      list: {
        records: [],
        size: 40,
        current: 1,
        total: 0,
      },
      // years: ["新石器时代", "夏", "商", "春秋", "战国", "秦", "汉", "三国"],
      // types: ["青铜", "石器"],
    };
  },
  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 getList(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 getList(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 { exhibitionId } = item;
      this.$router.push({
        path: "display/" + exhibitionId,
      });
    },

    defImg(e) {
      e.target.src = require("@/assets/404_images/no-pic.png");
    },
  },
};
</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: center;
      // justify-content: flex-end;
      // margin-top: 20px;
      .search-bar {
        margin-bottom: 20px;
        // width: 400px;
        width: 1200px;
        // 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%;
          }
          .desc {
            position: absolute;
            width: 100%;
            padding: 10px;
            background-color: #fff;
            opacity: 0.7;
            bottom: 0;
            left: 0;
          }

          .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;
              }
            }
          }
        }

        .display-item {
          cursor: pointer;
          .img {
            img {
              width: 100%;
              height: 250px;
            }
          }
        }
      }
    }
  }

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