<template>
  <div class="cultural-relic">
    <!-- <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" :keyword="keyword"/>
              <el-checkbox v-model="show3d">只看3D</el-checkbox>
            </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"
                      class="cr-img"
                    />
                    <img
                      v-else
                      src="@/assets/404_images/no-pic.png"
                      alt=""
                      width="100%"
                      height="100%"
                    />
                    <div class="showIcon" v-show="item.url3d">
                      <img src="@/assets/imgs/cr/3d.png" class="icon" />
                    </div>
                    <div class="desc">
                      <span class="name">{{ item.name }}</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 { getCulturalRelicList } from "@/api/culturalRelic";
// 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,
      },
      show3d: false,
    };
  },
  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(keyword) {
      var params = {
        page: this.list.current,
        limit: this.list.size,
        name: 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,
      });
    },

    defImg(e) {
      e.target.src = require("@/assets/404_images/no-pic.png");
    },
  },
};
</script>

<style lang="scss" scoped>
$blue: #1e5fbb;
$text-indent: 16px;
.cultural-relic {
  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;
      align-items: center;
      margin-bottom: 40px;
      // margin-top: 20px;
    }
    .search-bar {
      width: 1200px;
      margin-right: 10px;
      // 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;
          .cr-img {
            width: 100%;
          }
          .showIcon {
            position: absolute;
            opacity: 0.7;
            top: 10px;
            right: 10px;
            width: 24px;
            height: 24px;
            background-color: #fff;
            opacity: 0.2;
            border-radius: 4px;
            padding: 2px;
            .icon {
              width: 100%;
              height: 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>