<template>
  <div class="bodyBoxs">
    <div class="boxs">
      <sapn style="margin-right: 10px;color: #606266">筛选日期范围</sapn>
      <el-date-picker
        v-model="selectGatheringTime"
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="yyyy-MM-dd" @change="getData">
      </el-date-picker>
      <el-table
        :data="tableData"
        v-loading="loading"
        style="width: 100%">
        <el-table-column
          prop="nick"
          label="昵称">
        </el-table-column>
        <el-table-column
          prop=""
          label="头像">
          <template slot-scope="scope">
            <el-image style="width: 40px;border-radius: 50%" :src="scope.row.headimg"></el-image>
          </template>
        </el-table-column>
        <el-table-column
          prop="ip"
          label="访问IP">
        </el-table-column>
        <el-table-column
          prop="createdAt"
          label="访问时间"
        ></el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage4"
        :page-sizes="[10, 20, 30, 50]"
        :page-size=pageSize
        layout="total, sizes, prev, pager, next, jumper"
        :total=total>
      </el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      loading: false,
      tableData: [],
      page: 1,
      pageSize: 10,
      total: 0,
      currentPage4: 1,
      selectGatheringTime:''
    }
  },
  created() {
    this.getData()
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val;
      this.getData()
    },
    handleCurrentChange(val) {
      console.log('点击了');
      this.page = val;
      this.getData();
    },
    getData() {
      this.loading = true;
      this.$api.getLogs({
        page: this.page,
        size: this.pageSize,
        search: this.selectGatheringTime,
      }).then((res) => {
        this.loading = false;
        this.tableData = res.data.data;
        this.total = res.data.total;
        this.currentPage4 = res.data.current_page;
      });
    },
  }
}
</script>
<style scoped>
.bodyBoxs {
  padding: 40px;
}

.boxs {
  width: 100%;
  background: #fff;
  border-radius: 15px;
  padding: 10px;
  min-height: 700px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 100px;
  height: 100px;
  line-height: 100px;
  text-align: center;
}

.avatar {
  width: 100px;
  height: 100px;
  display: block;
}
</style>
