<template>
  <!-- 我关注的人 -->
  <el-card>
    <div class="myAttention">
      <div class="searchDiv">
        <div class="switch">
          <div class="switchDiv">
            <div class="list" :class="activeSwitch == index ? 'active' : ''" v-for="(item, index) in switchData" :key="item" @click="initSwitch(index)">
              {{ item }}
            </div>
          </div>
        </div>

        <div style="display: flex; align-items: center">
          <div class="searchValue">
            <input type="text" placeholder="搜索关键字" v-model="keyword" />
            <div class="searchBtn" @click="getListData">
              <img src="/kczy/searchIcon.png" alt="" />
            </div>
          </div>
        </div>
      </div>

      <div class="teacher-list" v-show="activeSwitch == '0'">
        <el-row :gutter="20" v-for="item in listData" :key="item" v-show="item.uw_user_role_id=='75'">
          <el-col :span="8">
            <div class="item">
              <img :src=" item.user_info.user_avatar" alt="" />

              <div class="js-name">{{ item.user_info.user_realname }}</div>
              <div class="ss-subject">
                {{ item.user_info.subject_name }}
              </div>
              <ul class="">
                <li>
                  <div>{{ item.user_info.ue_wdkc }}</div>
                  课程数量
                </li>
                <li>
                  <div>{{ item.user_info.ue_gksl }}</div>
                  观看数量
                </li>
                <li>
                  <div>{{ item.user_info.ue_bgzs }}</div>
                  被关注数
                </li>
              </ul>
            </div>
          </el-col>
        </el-row>
      </div>
      <div class="teacher-list" v-show="activeSwitch == '1'">
        <el-row :gutter="20" v-for="item in listData" :key="item" v-show="item.uw_user_role_id=='76'">
          <el-col :span="8">
            <div class="item">
              <img :src="item.user_info.user_avatar" alt="" />

              <div class="js-name">{{ item.user_info.user_realname }}</div>
              <div class="ss-subject">
                {{ item.user_info.subject_name }}
              </div>
              <ul>
                <li>
                  <div>{{ item.user_info.ue_zy }}</div>
                  作业
                </li>
                <li>
                  <div>{{ item.user_info.ue_gksl }}</div>
                  观看数量
                </li>
                <li>
                  <div>{{ item.user_info.ue_bgzs }}</div>
                  关注的人
                </li>
              </ul>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div class="footer">
      <div style="width: 1400px; height: 50px; position: relative; margin: 0 auto">
        <el-pagination background layout="total,prev, pager, next" :total="total" style="position: absolute; top: 0; right: 0" @current-change="handleCurrentChange" :page-size="limit">
        </el-pagination>
      </div>
    </div>
  </el-card>
</template>

<script>
import { wgzd_list } from "./api";
export default {
  data() {
    return {
      listData: [],
      infoData: {},
      limit: 10,
      total: 0,
      cur_page: 1,
      https: window.GLOBAL_CONFIG.api,
      switchData: ["教师", "学生"],
      activeSwitch: 0,
      keyword: ""

    };
  },
  methods: {
    initSwitch(index) {
      this.activeSwitch = index;
    },

    getListData() {
      let data = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,

      };

      wgzd_list(data).then((res) => {
        this.listData = res.data.page_data;
        // this.listData.forEach(item => {
        //   this.searchKey = item.uw_keyword
        // });

        console.log(this.keyword, 111);
        this.cur_page = Number(res.data.page_now);
        this.total = Number(res.data.total_rows);
      });
    },
    handleCurrentChange(val) {
      this.cur_page = val;
      this.listData();
    },
  },
  mounted() {
    this.getListData();
  },
};
</script>

<style lang="scss" scoped>
.searchDiv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 80px;
  .searchValue {
    width: 350px;
    height: 50px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    input {
      width: 100%;
      height: 100%;
      outline: 0;
      box-sizing: border-box;
      padding-left: 10px;
      background: #f6f8fa;
    }
    .searchBtn {
      width: 26px;
      height: 26px;
      background: #00a3ff;
      border-radius: 6px;
      position: absolute;
      right: 5px;
      top: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
      vertical-align: middle;
      cursor: pointer;
      img {
        display: block;
        text-align: center;
        margin: 6px auto 0;
      }
    }
  }
}
.myAttention {
  min-height: 400px;
  .switch {
    display: inline-block;
    margin-bottom: 35px;
    border: 1px solid #dbe7ec;
    padding: 3px;
    border-radius: 12px;
    margin-left: 20px;
    .switchDiv {
      display: flex;

      .list {
        cursor: pointer;
        color: #666;
        line-height: 36px;
        padding: 0 20px;
        &.active {
          background: #e8f3fa;
          color: #000;
          border-radius: 12px;
        }
      }
    }
  }
  .el-col {
    margin-bottom: 25px;
  }
  .teacher-list {
    display: flex;
    flex-wrap: wrap;
    padding: 0px 100px;
  }
  .item {
    width: 380px;
    height: 320px;
    border-radius: 8px;
    padding: 30px;
    margin-right: 15px;
    cursor: pointer;
    background: #fcfeff;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.08),
      0 6px 20px 0 rgba(0, 0, 0, 0.08);
    img {
      width: 70px;
      height: 70px;
      margin: 0 auto;
      border-radius: 50%;
    }
    .js-name {
      font-size: 20px;
      font-family: PingFangSC, PingFangSC-Semibold;
      font-weight: 600;
      text-align: center;
      color: #171721;
      margin-top: 30px;
    }
    .ss-subject {
      font-size: 16px;
      font-family: PingFangSC, PingFangSC-Regular;
      font-weight: 400;
      text-align: center;
      color: #949494;
      margin-top: 8px;
    }
  }
  ul {
    display: flex;
    align-items: flex-start;
    margin-top: 30px;
    li {
      width: 90px;
      height: 60px;
      border: 1px dashed #e4e6ef;
      border-radius: 6px;
      padding: 5px 10px;
      color: #949494;
      & + li {
        margin-left: 30px;
      }
      div {
        color: #5e6278;
      }
    }
  }
}
</style>