<template>
  <div class="virtual">
    <!-- <NavBar /> -->
    <!-- <h1>虚拟展厅</h1> -->
    <!-- <Footer /> -->
    <div class="empty-space"></div>
    <div class="main">
      <div class="content-wrapper">
        <el-row :gutter="20">
          <el-col :span="24" class="rclist">
            <div class="search">
              <SearchBar @search="search" :keyword="keyword" />
            </div>
            <div class="display-group">
              <el-row :gutter="40" class="list">
                <el-col
                  :span="8"
                  v-for="(item, index) in list.records"
                  :key="index"
                >
                  <div class="img" @click="handleClick(item.url)">
                    <img :src="item.faceImageUrl" alt="" />
                    <div class="desc">
                      <span class="name">{{ item.name }}</span>
                    </div>
                    <div class="play">
                      <i class="el-icon-caret-right"></i>
                    </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>
  </div>
</template>

<script>
import NavBar from "@/components/NavBar";
import Footer from "@/components/Footer";
import { getVirtualList } from "@/api/vitual";
import SearchBar from "@/components/SearchBar";
export default {
  name: "Virtual",
  components: { NavBar, Footer, SearchBar },
  data() {
    return {
      list: {
        records: [],
        size: 10,
        current: 1,
        total: 0,
      },
      keyword: "",
    };
  },
  mounted() {
    this.loadData();
  },
  methods: {
    //   加载表格数据
    async loadData() {
      var params = {
        page: this.list.current,
        limit: this.list.size,
      };
      let res = await getVirtualList(params);
      if (res.code == 0) {
        this.list = res.data;
      }
    },

    async search(keyword) {
      var params = {
        page: this.list.current,
        limit: this.list.size,
        name: keyword,
      };
      let res = await getVirtualList(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(url) {
      window.open(url);
    },
  },
};
</script>

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

    .img {
      width: 100%;
      position: relative;
      overflow: hidden;
      height: 350px;
      margin-bottom: 20px;
      // background-color: #fff;
      cursor: pointer;
      &:hover {
        img {
          transform: scale(1.1);
        }
      }
      img {
        width: 100%;
        height: 100%;
        transition: all 0.5s ease;
      }
      .desc {
        position: absolute;
        width: 100%;
        padding: 10px;
        background-color: #fff;
        opacity: 0.7;
        bottom: 0;
        left: 0;
      }
      .play {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: 2px solid #fff;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        display: flex;
        justify-content: center;
        align-items: center;
        i {
          font-size: 40px;
          color: #fff;
        }
      }
    }
  }

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