<template>
  <div>
    <!-- tabber -->
    <div v-if="show">
      <van-nav-bar title="领导信箱" left-arrow @click-left="onClickLeft" />
    </div>
    <!-- 列表 -->
    <ul class="leader-home">
      <!-- 提交信件 -->
      <li @click="leader_home_list1">
        <img
          src="../../../assets/images/leader-mailbox/领导信箱图标1.png"
          alt=""
        />
        <p>提交信件</p>
      </li>
      <!-- 查看信箱 -->
      <li @click="leader_home_list2">
        <img
          src="../../../assets/images/leader-mailbox/领导信箱图标2.png"
          alt=""
        />
        <p>查看信箱</p>
      </li>
      <!-- 我的提交 -->
      <li @click="leader_home_list3">
        <img
          src="../../../assets/images/leader-mailbox/领导信箱图标3.png"
          alt=""
        />
        <p>我的提交</p>
      </li>
    </ul>
  </div>
</template>

<script>
import { getAllUrlParams } from "../plugins/admin/url-encapsulation.js"; //获取url上的token和tabber
export default {
  data() {
    return {
      token: sessionStorage.getItem("mytoken")
        ? sessionStorage.getItem("mytoken")
        : "", //token值保存在本地，有的话取值，没有为空
      show: false, //tabber是否显示
      gettoken: "", //从url获取到token值
    };
  },
  methods: {
    //提交信件
    leader_home_list1() {
      this.$router.push(
        `/xixuanzhongxin/leader-mailbox/leader-mailbox?token=${this.token}`
      );
    },
    //查看信箱
    leader_home_list2() {
      this.$http
        .post(
          "http://xixuan.nxjiewei.com:8011/api/workbench/leader_mailbox/check"
        )
        .then((res) => {
          //获取是否为领导
          this.leader = res.data.data;
          if (this.leader == true) {
            this.$router.push(
              `/xixuanzhongxin/leader-mailbox/leader-mailbox-list2?token=${this.token}`
            );
          } else {
            this.$dialog.alert({
              message: "暂无权限",
              theme: "round-button",
            });
          }
        });
    },
    //我的提交
    leader_home_list3() {
      this.$router.push(
        `/xixuanzhongxin/leader-mailbox/leader-mailbox-reply?token=${this.token}`
      );
    },
    //tabber返回按钮
    onClickLeft() {
      window.history.back();
    },
  },
  mounted() {
    document.body.style.backgroundColor = "#fff"; //背景色
    this.gettoken =getAllUrlParams(window.location.href).token;
    this.token = `Bearer ${this.gettoken}`; //获取token值
    sessionStorage.setItem("mytoken", this.token); //存入token值
    this.show = Boolean(getAllUrlParams(window.location.href).tabber); //获取tabber
  },
};
</script>

<style scoped>
.leader-home {
  width: 90%;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
}
.leader-home li {
  width: 33%;
  text-align: center;
}
.leader-home li img {
  width: 100%;
}
.van-nav-bar {
  background: #39f;
}
>>> .van-nav-bar__title {
  color: #fff;
}
>>> .van-nav-bar .van-icon {
  color: #fff;
}
[class*="van-hairline"]:after {
  border: none;
}
</style>