<template>
  <div class="navbar">
    <div class="left-box">
         <div class="logo-box">
        <img src="../../assets/icon1.svg" alt="" class="outside">
        <img src="../../assets/icon2.svg" alt="" class="inside">
      </div>
      <div class="title">慧研学惠生活</div>
    </div>

    <div class="right-menu">



      <i class="iconfont icon-weibiaoti1"></i>
      <!-- <div class="name">{{name}}</div>
      <div class="msg-box">
        <div class="num-icon"  v-if="num">{{num>99?'99+':num}}</div>
        <i class="iconfont icon-tongzhi4"></i>
        <div class="menu-box">
          <div class="title">订单提示</div>
          <div class="msg" @click="jump">
            <div class="label">待处理提现申请</div>
            <div class="value">(<span class="num">{{num}}</span>)</div>
          </div>
        </div>
      </div> -->
      <i class="iconfont icon-guanji" @click="logout"></i>

      <!-- <el-dropdown class="avatar-container ml10" trigger="click">
        <div class="avatar-wrapper">
          <img src="https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif?imageView2/1/w/80/h/80" class="user-avatar">
          <i class="el-icon-caret-bottom" />
        </div>
        <el-dropdown-menu slot="dropdown" class="user-dropdown">
          <router-link to="/">
            <el-dropdown-item>
              首页
            </el-dropdown-item>
          </router-link>
          <el-dropdown-item divided @click.native="logout">
            <span style="display:block;">登出</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown> -->
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
// import { withdrawApplyType} from '@/api/withdraw'
export default {
  components: {
    Breadcrumb,
    Hamburger
  },
  data() {
    return {
      num:0,
      timer:null,
    }
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'avatar'
    ]),
    name(){
      return localStorage.getItem('name')
    }
  },
  watch: {
    $route(newValue, oldValue) {
      // this.withdrawApplyType()
    }
  },
  created () {
    // this.withdrawApplyType()
  },

  methods: {
    jump(){
      this.$router.push({
        path:'/financeManage/withdrawApply',
        query:{
          type:2
        }
      })
    },
    logout() {
       this.$confirm('确定要退出登录吗？', '退出确认', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$store.dispatch('user/logout')
          this.$router.push(`/login?redirect=${this.$route.fullPath}`)
        })
    },
    withdrawApplyType(){
      withdrawApplyType().then(res=>{
        if(res.code == 200){
          this.num = res.data.pending
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.navbar {
  height: 50px;
  // overflow: hidden;
  position: fixed;
  width: 100vw;
  z-index: 999;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,21,41,.08);
  padding: 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .left-box{
    display: flex;
    align-items: center;

    .logo-box{
      position: relative;
      width: 50px;
      height: 50px;
      .outside{
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
        width: 30px;
      }
      .inside {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
        width: 20px;
      }
    }
    .title{
      font-size: 18px;
      font-weight: 600;
    }
  }

  .right-menu {
    height: 100%;
    line-height: 50px;
    display: flex;
    align-items: center;
    margin-right: 40px;
      color: #fff;
      .name{
        font-size: 12px;
      }
      .iconfont{
        font-size: 20px;
        padding: 0 10px;
        color: black;
      }
      .icon-guanji{
        cursor: pointer;
      }
      .msg-box{
        position: relative;
        padding: 0 15px;
        .num-icon{
          position: absolute;
          top: 0;
          left: 50%;
          transform: translate(2%,30%);
          // width: 20px;
          height: 18px;
          padding: 0 5px;
          border-radius: 9px;
          background: #f04844;
          line-height: 18px;
          font-size: 12px;
          text-align: center;
        }
        .menu-box{
          display: none;
          position: absolute;
          top: 99%;
          left: 50%;
          transform: translate(-70%);
          width: 300px;
          padding: 15px;
          border-radius: 4px;
          box-shadow: 0 1px 4px rgba(0,21,41,.08);
          background: #fff;
          z-index: 9;
          font-size: 12px;
          .title{
            color: #999;
          }
          .msg{
            color: #666;
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: pointer;
            .label{
            }
            .num{
              color: #f04844;
            }
            .value{
            }
          }
          .msg:hover{
            .label{
              color: #1abc9c;
            }
          }
        }
      }
      .msg-box:hover .menu-box{
        display: block;
      }


    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #5a5e66;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background .3s;

        &:hover {
          background: rgba(0, 0, 0, .025)
        }
      }
    }

    .avatar-container {
      margin-right: 30px;

      .avatar-wrapper {
        margin-top: 5px;
        position: relative;

        .user-avatar {
          cursor: pointer;
          width: 40px;
          height: 40px;
          border-radius: 10px;
        }

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
  }
}
</style>
