<template>
  <div class="el-common_header_pc_3">
    <div class="common_header_pc_3">
   <div class="top">
      <div class="container">
         <div class="row">
            <div class="col-lg-10 col-md-9 col-sm-8 col-xs-7">
               <div class="top-left">
                  <span  class="sp1">
                    <span  id="djs">{{CUR_TIME}}</span>
                    ，欢迎来到江苏老年开放大学！</span>
                  <!--<span class="sp2">总访问量 <i>5,7812</i></span>
                  <span class="sp3"><a href="">访问量统计</a></span> -->
               </div>
            </div>
           <!-- <div class="col-lg-2 col-md-3 col-sm-4 col-xs-5">
               <span class="top-right">
                  <a href="">无障碍浏览</a>
               </span>
            </div>-->
         </div>
      </div>
   </div>
   <div class="second">
      <div class="container">
         <div class="row">
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
               <span class="second-logo"><a href="/index?type=sy"><img src="../../theme-chalk/src/images/zyk-logo.png" alt=""></a></span>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
               <div class="second-right">
                 <!-- <span class="second-search clearfix">
                     <input type="text" class="inp1">
                     <input type="button" class="btn1">
                  </span> -->
                  <span  v-if="userData && userData.custName" class="second-login">
                     <img v-if="userData.photo" :src="userData.photo" alt="" class="header1">
                     <img v-else src="../../theme-chalk/src/images/zyk-header.png" alt="" class="header1">
                     <a href="/personcenter" target="_blank" style="margin-left:2px;" >{{userData.custName}}</a>，欢迎您登录~
                     <a href="javascript:void(0)"  @click="logout" class="redtxt">退出登录</a>
                     <!--<a href="/personcenter" class="a2">进入个人空间</a>-->
                  </span>
                  <span v-else class="second-login">
                     <a href="javascript:void(0)"  @click="toLogin" class="a1">登录</a>丨
                     <a href="javascript:void(0)"  @click="toReg" class="a1">注册</a>
                  </span>


               </div>
            </div>
         </div>
      </div>
   </div>
   <div class="menu">
      <div class="container">
         <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
               <ul class="menu-ul"  id="hearderul">
                  <li><a @click="jump($event)" href="/index?type=sy">首页</a></li>
                  <li><a  @click="jump($event)" href="/resourcelist?name=专题资源&type=ztzy&class=1">专题资源</a></li>
                  <li><a  @click="jump($event)" href="/courselist?name=课程资源&type=kczy&class=2">课程资源</a></li>
                  <li><a  @click="jump($event)" href="/resourcelist?name=媒体资源&type=mtzy&class=1">媒体资源</a></li>
                  <li><a  @click="jump($event)" href="/courselist?name=国开课程&type=gkkc&class=2">国开课程</a></li>
                  <li><a  @click="jump($event)" href="/courselist?name=老年教育&type=lnjy&class=1">老年教育</a></li>
                  <!--<li><a  @click="jump($event)" href="/resourcelist?name=资源建设中心&type=zyjszx&class=1">资源建设中心</a></li>-->
               </ul>
            </div>
         </div>
      </div>
   </div>
</div>
<ElLoginPop ref="loginpop"></ElLoginPop>
<ElRegPop ref="regpop"></ElRegPop>
  </div>
</template>

<script>
  import $ from 'fy-kit';
  import formMixin from '../../../src/mixins/formMixin';
  import lenye_base from 'lenye_base';
  import msg from '../../message';
  import ElLoginPop  from '../../login-pop'
  import ElRegPop from '../../reg-pop'
export default {
  name: 'ElCommonHeaderPc3',
  mixins: [formMixin],
  model: {},
  data(){
    return {
      CUR_TIME:'',
      userData: {},
      isearch: "",
      isLogin:false
    }
   },
    created() {
     if($.util.storage('userData').get().getValue()){
       this.isLogin = true;
     }
   },
   mounted() {
      this.init();
     if($.util.storage('userData').get().getValue()){
         this.info();
    }
   },
   computed: {},
   methods: {
     toLogin(){
       this.$refs.loginpop.showPop();
     },
     toReg(){
      this.$refs.regpop.showPop();
     },
     info(){
        $.util
        .ajax(
          lenye_base.base_data.getapiUrl() +
            "/base-service/api/cust/userSelf/detail.do",
          lenye_base.base_data.getformatting({})
        )
        .then(res => {
            if(res.success == '1'){
                this.userData = res.data;
            }else{
                msg.error(res.message);
            }
        })
    },
      logout() {
      localStorage.clear();
      lenye_base.user_data.loginOut();
      // todo
      setTimeout(function() {
        window.location.href = "/?type=sy";
        window.parent.location = "/?type=sy";
      },1000)

     // window.location.reload();
    },
      jump(ev) {
      var ele = $._.default(ev.target);
      ele
        .parent("li")
        .addClass("active")
        .siblings("li")
        .removeClass("active");//infolist
    },
      setActive(num) {
        var ul = $._.default("#hearderul");
        ul
          .find("li")
          .eq(num)
          .addClass("active")
          .siblings("li")
          .removeClass("active");
      },
     init() {
      //
      $.util
        .ajax(
          lenye_base.base_data.getapiUrl() + "/base-service/common/sysdate.do",
          lenye_base.base_data.getformatting({})
        )
        .then(res => {
          if (res.success === "1") {
            this.datas = res.data;
            var t = 1000;
            setInterval(() => {
              t += 1000;
              this.CUR_TIME = $.date
                .moment(
                  new Date(
                    res.data.CUR_DATE + " " + res.data.CUR_TIME
                  ).getTime() + t
                )
                .format("YYYY年MM月DD日 HH:mm:ss");
            }, 1000);
            switch ($.util.urlParams('type')) {
              case "sy":
                this.setActive(0);
                break;
              case "ztzy":
                this.setActive(1);
                break;
              case "kczy":
                this.setActive(2);
                break;
              case "mtzy":
                this.setActive(3);
                break;
              case "gkkc":
                this.setActive(4);
                break;
              case "lnjy":
                this.setActive(5);
                break;
              case "zyjszx":
                this.setActive(6);
                break;

            }
          } else {
            msg.error(res.message);
          }
        });
    },
   },
};
</script>
