<template>
  <common-header />
  <div class="content">
    <div class="title">
      <div>学校 <span>艺术广场-专题艺术活动-{{sm_name}}-</span><span>活动列表</span></div>
    </div>
    <div class="main">
      <div class="nav">
        <div class="search-list">
          <div class="label">年级</div>
          <div class="valueDiv">
            <div class="item pointer" :class="activeGrade==item.grade_id?'active':''" @click="initGrade(item)" v-for="item in gradeData" :key="item.grade_id">{{item.grade_name}}</div>
          </div>
        </div>
        <div class="search-list">
          <div class="label">分类</div>
          <div class="valueDiv">
            <div class="item pointer" :class="activeType==item.v?'active':''" @click="initType(item)" v-for="item in typeData" :key="item.v">{{item.n}}</div>
          </div>
        </div>
      </div>
      <div class="inp">
        <input v-model="keyword" type="text" placeholder="搜索关键字" />
        <span class="inp-sear" @click="getSchoolZpData"></span>
      </div>
      <div class="hd-list">
        <ul class="hd-content">
          <li class="hd" v-for="(item,index) in schoolZpData" :key="index">
            <img @click="toDetail(item.yzcz_id)" class="hd-back" :src="item.yzcz_img" alt="" />
            <div class="hd-des">
              <p class="p-content">{{item.yzcz_name}}</p>
            </div>
          </li>

        </ul>

      </div>
    </div>
    <div class="z-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>
  </div>
  <common-footer />
</template>

<script>
import {
  schoolZp_list, grade_list,
} from "./api";
import { download } from "~/utils/request";
import CommonHeader from "@/components/CommonHeader/index.vue";
import CommonFooter from "@/components/CommonFooter/index.vue";
export default {
  name: "index",
  components: {
    CommonHeader,
    CommonFooter,
    download,
  },
  data() {
    return {
      schoolZpData: [],
      https: window.GLOBAL_CONFIG.api,
      gradeData: [],
      activeGrade: "",
      detailData: {},
      yzcz_id: "",
      typeData: [],
      activeType: "",
      limit: 12,
      cur_page: 1,
      total: 0

    };
  },
  methods: {
    //学校
    getSchoolZpData() {
      let data = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
        grade_id: this.activeGrade,
        cate_id: this.activeType,
        sm_id: this.sm_id
      };
      schoolZp_list(data).then((res) => {
        this.schoolZpData = res.data.page_data;
        this.cur_page = Number(res.data.page_now);
        this.total = Number(res.data.total_rows);

      });
    },
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getSchoolZpData();
    },
    //分类
    initTypeData() {
      this.typeData = [
        {
          v: "",
          n: "全部"
        }
      ];
      schoolZp_list().then((res) => {
        if (res.code == 1) {
          this.typeData = this.typeData.concat(res.data.table_structure.field.yzcz_cate.option);
        }
      });
    },
    initType(value) {
      this.activeType = value.v;

      this.getSchoolZpData();
    },
    //年级
    initGradeData() {
      this.gradeData = [
        {
          grade_id: "",
          grade_name: "全部",
        }
      ];
      grade_list().then((res) => {
        if (res.code == 1) {
          this.gradeData = this.gradeData.concat(res.data.page_data);
        }
      });
    },

    initGrade(value) {
      this.activeGrade = value.grade_id;
      this.getSchoolZpData();
    },
    toDetail(id) {
      this.$router.push({
        name: "ysgc_zpDetail", params: { id: id }
      });
    },
  },
  mounted() {
    if (this.$route.params.id != "") {
      this.sm_id = this.$route.params.id;
      this.sm_name = this.$route.query.sm_name;
      this.getSchoolZpData();
      this.initGradeData();
      this.initTypeData();

    }
  },
};
</script>

<style lang="scss" scoped>
.content {
  width: 100%;
  min-width: 1800px;
  margin: 0 auto;
  background-image: url("@/assets/img/zhjy/xq_bg.png");
  background-repeat: no-repeat;
}
.title {
  width: 100%;

  height: 60px;
  line-height: 60px;
  font-size: 18px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  color: #050026;
  background: #ffffff;
  margin-bottom: 20px;
  box-shadow: 0px 1px 10px 0px rgba(17, 46, 74, 0.1);
  div {
    width: 1400px;

    margin: 0 auto;
    span:first-of-type {
      width: 56px;
      height: 20px;
      font-size: 14px;
      font-family: PingFangSC, PingFangSC-Regular;
      font-weight: 400;
      text-align: left;
      color: #949494;
      line-height: 20px;
      margin-left: 30px;
    }
    span:last-of-type {
      width: 56px;
      height: 20px;
      font-size: 14px;
      font-family: PingFangSC, PingFangSC-Regular;
      font-weight: 400;
      text-align: left;
      color: #000000;
      line-height: 20px;
    }
  }
}
.main {
  width: 1800px;
  margin: 0 auto;

  border-radius: 12px;
  padding: 30px;
  .search-list {
    display: flex;
    align-items: baseline;
    font-size: 14px;
    margin: 20px 0;
    .label {
      color: #000;
      margin-right: 25px;
    }
    .valueDiv {
      flex: 1;
      display: flex;
      color: #949494;
      border-bottom: 1px dashed #e4e6e8;
      padding-bottom: 15px;
      font-weight: 400;
      cursor: pointer;
      .item + .item {
        margin-left: 20px;
      }
      .item {
        padding: 3px 5px;
        &.active {
          color: #00a3ff;
          border-radius: 6px;
          background: rgba($color: #00a3ff, $alpha: 0.1);
        }
      }
    }
  }
  .inp {
    width: 497px;
    margin: 20px 0 25px 0;
    height: 50px;
    line-height: 50px;
    position: relative;
    input {
      background: #ffffff;
      border-radius: 8px;
      border: 1px solid #00a3ff;
      outline: none;
      width: 100%;
      height: 100%;
      padding-left: 17px;
      font-size: 16px;
    }
    .inp-sear {
      display: block;
      width: 26px;
      height: 26px;
      background: #00a3ff;
      border-radius: 6px;
      position: absolute;
      top: 12px;
      right: 15px;
      background-image: url("../../../assets/ysgc/search.png");
      background-size: 60%;
      background-position: center;
      background-repeat: no-repeat;
      cursor: pointer;
    }
  }
  .hd-list {
    width: 1800px;
    min-width: 1280px;
    margin: 0 auto;

    .hd-content {
      width: 100%;
      display: flex;
      flex-wrap: wrap;

      .hd {
        width: 268px;
        height: 234px;
        border-radius: 12px 12px 0px 0px;
        box-shadow: 0px 10px 24px 0px rgba(161, 153, 168, 0.18);
        position: relative;
        margin: 25px 16px;
        .hd-back {
          width: 268px;
          height: 157px;
          border-radius: 12px 12px 0px 0px;
          cursor: pointer;
        }
        .hd-des {
          width: 268px;
          height: 77px;
          padding: 11px;
          font-size: 16px;
          font-family: PingFangSC, PingFangSC-Medium;
          font-weight: 500;
          text-align: left;
          color: #050026;
        }
        .p-content {
          width: 100%;
          height: 25px;
          word-wrap: break-word;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          overflow: hidden;
        }
      }
    }
  }
}
.z-footer {
  width: 100%;
  height: 50px;
  margin-top: 100px;
  display: inline-block;
}
</style>

