<template>
  <div class="inandout">
    <!-- <nav-header :title="title" @back="$router.go(-1)" /> -->
    <div class="main">
      <p>请输入工作人员口令</p>
      <input type="password" v-model="command" />
      <van-button class="button" block @click="submit">确定</van-button>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import { Button } from "vant";
// import NavHeader from "@/components/NavHeader";

Vue.use(Button);

export default {
  components: {
    // NavHeader,
  },
  data() {
    return {
      command: "",
      type: null,
      title: "仓储管理人员",
      pas: null,
      name: null,
    };
  },
  methods: {
    submit() {
      if (!this.command) {
        this.$toast("请输入工作人员口令");
        return;
      } else if (this.command !== this.pas) {
        this.$toast("口令错误，请重新输入");
        this.command = "";
        return;
      } else {
        this.$router.push({ name: this.name, query: { type: this.type } });
      }
    },
  },
  created() {
    this.type = parseInt(this.$route.query.type);
    if (this.type === 1) {
      this.title = "出入库管理口令鉴定";
      this.pas = "536856";
      this.name = "ComeIn";
    } else if (this.type === 7) {
      this.title = "消杀管理口令鉴定";
      this.pas = "489325";
      this.name = "Check";
    } else if (this.type === 4) {
      this.title = "核酸检测管理口令鉴定";
      this.pas = "753951";
      this.name = "Check";
    } else if (this.type === 8) {
      this.title = "灭活管理口令鉴定";
      this.pas = "854697";
      this.name = "Check";
    }
    window.document.title = this.title;
  },
};
</script>

<style lang="stylus" scoped>
.main {
  margin: 30px;
  padding: 30px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;

  p {
    font-size: 32px;
    font-weight: 500;
    color: #666666;
  }

  input {
    width: calc(100% - 100px);
    height: 200px;
    padding: 0 50px;
    margin-top: 40px;
    background: #F3F6F9;
    border-radius: 4px;
  }

  .button {
    margin-top: 40px;
    background: #EB4E3F;
    border-radius: 40px;
    font-size: 36px;
    font-weight: 500;
    color: #FFFFFF;
  }
}
</style>
