<template>
  <div id="request">
    <el-row>
      <pages-one
        :newList="newList"
        :gongList="gongList"
        :listSchIn="listSchIn"
        :jobfairList="jobfairList"
        :listSchOut="listSchOut"
        :PostInfos="PostInfos"
        :causeList="causeList"
        :teacherList="teacherList"
        :tagsIns="tagsIns"
        :tagsCiv="tagsCiv"
        :tagsSel="tagsSel"
        :tagsWes="tagsWes"
        :tagsSpe="tagsSpe"
        :tagsThr="tagsThr"
        :tagsCol="tagsCol"
        :tagsOne="tagsOne"
        :site="site"
      ></pages-one>
    </el-row>
  </div>
</template>

<script>
import pagesOne from './index.vue';
import { mapActions, mapState } from 'vuex';
export default {
  name: 'request',
  props: {},
  components: {
    pagesOne,
  },
  data: () => ({
    limit: 4,
    newList: [
      { url: require('@/assets/a1.jpg'), id: 1, name: '应用技术学院召开首届专场人才招聘会' },
      { url: require('@/assets/a2.jpg'), id: 2, name: '浙江湖州城市综合推介会暨2019年重点用人单位招聘会在我校举行' },
      { url: require('@/assets/a3.jpg'), id: 3, name: '我校与亚信科技（中国）有限公司举行校企战略合作签约暨客座教授聘任仪式' },
      { url: require('@/assets/a4.jpg'), id: 4, name: '求职创业补贴学生名单公示' },
      { url: require('@/assets/a5.jpg'), id: 5, name: '学校隆重举行2019届毕业生春季供需洽谈会' },
    ],
    gongList: [{ date: '07-21', title: '关于举办全国民营科技企业面向2019届高校毕业生网上招聘会活动的通知' }],
    listSchIn: [],
    jobfairList: [],
    listSchOut: [],
    PostInfos: [],
    causeList: [{ title: '【吉林省人事考试网】2019年吉林省省直事业单位公开招聘高级人才公告（17号）', date: '2019-10-18' }],
    teacherList: [{ title: '【吉林教师】2019年松原前郭县城区学校选拔农村教师实施方案(75人) ', date: '2019-10-18' }],
    tagsIns: [{ title: '【事业单位】2019年中国科技大学附属中学教师招聘公告', date: '2019-10-14' }],
    tagsCiv: [{ title: '【公务员】2020年国家公务员考试公告', date: '2019-10-14' }],
    tagsSel: [{ title: '【吉林选调生】2018年吉林把选调生工作作为建设高素质专业化干部队伍', date: '2019-3-11' }],
    tagsWes: [{ title: '【西部计划】甘肃省张掖市引导525名高校毕业生进疆稳定就业', date: '2019-3-20' }],
    tagsSpe: [{ title: '【特岗教师】2019承德宽城满族自治县公开招聘“地方特岗教师”228人公告', date: '2019-7-28' }],
    tagsThr: [{ title: '【三支一扶】2020中央机关及其直属机构公务员考试公告', date: '2019-10-14' }],
    tagsCol: [{ title: '【村官】2019江苏高邮市龙虬镇招聘村会计3人公告', date: '2019-10-14' }],
    tagsOne: [{ title: '[广西] 中国建筑材料工业地质勘查中心广西总队', date: '10-15' }],
    site: {},
  }),
  created() {
    this.getSite();
    this.search();
  },
  computed: {},
  methods: {
    ...mapActions(['jobfairOperation', 'postTalksInfo', 'jobinfoOperation', 'getBugInfo', 'siteOperation', 'newsOperation']),
    async getSite() {
      let site = sessionStorage.getItem('site');
      if (site) {
        site = JSON.parse(site);
        this.$set(this, `site`, site);
        return;
      } else {
        let site = '99991';
        let result = await this.siteOperation({ type: 'search', data: { site: this.$site } });
        if (`${result.errcode}` === `0`) {
          sessionStorage.setItem('site', JSON.stringify(result.data));
          this.$set(this, `site`, result.data);
          console.log(site);
        }
      }
    },
    async search() {
      console.log(this.$site);

      // 1直接拿着参数发送请求
      let result = await this.postTalksInfo({ type: 'list', data: { schid: this.$site } });
      if (`${result.errcode}` === '0') {
        //给this=>vue的实例下在中的list属性，赋予result。data的值
        this.$set(this, `listSchIn`, result.data);
      } else {
        this.$message.error(result.errmsg ? result.errmsg : 'error');
      }
      result = await this.jobfairOperation({ type: 'list', data: { schid: this.$site } });
      if (`${result.errcode}` === '0') {
        //给this=>vue的实例下在中的list属性，赋予result。data的值
        this.$set(this, `jobfairList`, result.data);
      } else {
        this.$message.error(result.errmsg ? result.errmsg : 'error');
      }
      result = await this.postTalksInfo({ type: 'list', data: {} });
      if (`${result.errcode}` === '0') {
        //给this=>vue的实例下在中的list属性，赋予result。data的值
        this.$set(this, `listSchOut`, result.data);
      } else {
        this.$message.error(result.errmsg ? result.errmsg : 'error');
      }
      result = await this.jobinfoOperation({ type: 'list', data: { limit: this.limit } });
      if (`${result.errcode}` === '0') {
        //给this=>vue的实例下在中的list属性，赋予result。data的值
        this.$set(this, 'PostInfos', result.data);
      } else {
        this.$message.error(result.errmsg ? result.errmsg : 'error');
      }
      result = await this.newsOperation({ type: 'list', data: { site: this.$site, limit: 4, skip: 0 } });
      if (`${result.errcode}` === '0') {
        //给this=>vue的实例下在中的list属性，赋予result。data的值
        this.$set(this, 'newList', result.data);
      } else {
        this.$message.error(result.errmsg ? result.errmsg : 'error');
      }

      // result = await this.getBugInfo({ data: { skip: 0, limit: this.$limit } });
      // if (`${result.errcode}` === '0') {
      //   //给this=>vue的实例下在中的list属性，赋予result。data的值
      //   this.$set(this, 'cause', result.data);
      // } else {
      //   this.$message.error(result.errmsg ? result.errmsg : 'error');
      // }
    },
  },
};
</script>

<style lang="scss" scoped></style>
