<template>
  <div class="bogbox">
    <div class="firstpage">
      <img src="./img/introduce_server.png" />
      <button class="login" @click="PostStatus">发布信息</button>
    </div>

  </div>
</template>

<script>
import { mapMutations } from "vuex";
export default {
  name: "TheHome",
  data() {
    return {
      isLogin: false,
    };
  },
  created() {
    if (localStorage.getItem("token") && localStorage.getItem("token") != "") {
      this.token = localStorage.getItem("token");
      this.isLogin = true;
    } else this.isLogin = false;
  },
  methods: {
    ...mapMutations("PerCent", ["convertIndex"]),
    PostStatus() {
      if (
        localStorage.getItem("token") &&
        localStorage.getItem("token") != "" &&
        localStorage.getItem("token") != "undefined"
      ) {
        this.token = localStorage.getItem("token");
        this.isLogin = true;
      } else this.isLogin = false;

      if (!this.isLogin) {
        alert("未登录，请先登录。");
        this.$router.push("./loginview");
      } else {
        // 进行跳转
        this.convertIndex(2);
        this.$router.push("./PerCent");
      }
    },
    go_top() {
      document.documentElement.scrollTop = 0;
    },
  },

};
</script>

<style scoped>
.firstpage {
  width: 100%;
  height: 100%;
  position: relative;
}

img {
  width: 100%;
  height: 100%;
}

.login {
  position: absolute;
  top: 37.5rem;
  left: 70rem;
  width: 13rem;
  height: 3.5rem;
  background-color: #339966;
  border: 1px solid #339966;
  border-radius: 30px;
  color: aliceblue;
  font-size: 1.2rem;
  font-weight: bolder;
  cursor: pointer;
}
</style>