<template>
  <div class="login" :style="{ backgroundImage: `url(${bg})` }">
    <div class="title">
      <div class="login-logo">
        <van-image :src="require('@/assets/login/login-logo.png')" />
      </div>
      <div class="login-name">首开集团安全隐患排查治理体系</div>
    </div>

    <div class="con" :style="{ backgroundImage: `url(${conBg})` }">
      <div class="hello">Hello!</div>
      <div class="welcome">
        欢迎登录<span>首开集团安全隐患排查治理体系</span>!
      </div>
      <div class="login-form">
        <van-form @submit="onSubmit">
          <div class="username-wrap">
            <div class="username-icon">
              <van-image :src="require('@/assets/login/login-username.png')" />
            </div>
            <van-field
              v-model="username"
              name="username"
              label=""
              placeholder="账号"
              :rules="[{ required: true, message: '请填写用户名' }]"
            />
          </div>
          <div class="passworld-wrap">
            <div class="passworld-icon">
              <van-image :src="require('@/assets/login/login-passworld.png')" />
            </div>
            <van-field
              v-model="password"
              name="password"
              placeholder="密码"
              :rules="[{ required: true, message: '请填写密码' }]"
            />
          </div>

          <div style="margin: 16px;">
            <van-button round block type="info" native-type="submit"
              >登录</van-button
            >
          </div>
        </van-form>
      </div>
    </div>
  </div>
</template>

<script>
import { getFun,postFun } from '@/service/table'
import { setToken } from '@/utils/auth'
export default {
  data() {
    return {
      bg: require("@/assets/login/login-bg.png"),
      conBg: require("@/assets/login/login-center.png"),
      username: "",
      password: ""
    };
  },
  mounted() {
  },
  methods: {
     onSubmit(values) {
        if(values.username=='admin'&&values.password=='123456'){
            getFun('check/token',{a:122}).then((Response)=>{
                if(Response.code==0){
                    this.$notify({
                        message:'登录成功',
                        background:'green',
                        duration: 1000
                    })
                    setToken(Response.data)
                    this.$router.push('/message-center')
                }
            })
            
            // localStorage.setItem('admin_token','2dsfewr')
            // this.$router.push('/MessageCenter')
            // location.reload();
        }else{
            this.$notify({
                message:'账号或密码不正确',
                background:'red',
                duration: 1000
            })
        }
    }
  }
};
</script>
<style lang="less" scoped>
/* @import url(); 引入css类 */
.login {
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
  .login-logo {
    width: 120px;
    margin: 22% auto 0px;
  }
  .login-name {
    width: 100%;
    text-align: center;
    margin-top: 20px;
    color: #fafbfe;
    font-size: 18px;
    font-weight: bold;
  }
  .con {
    width: 345px;
    height: 340px;
    margin: 62px auto 0;
    padding: 35px 25px;
    box-sizing: border-box;
    background-size: cover;
    background-repeat: no-repeat;
    .hello {
      color: #004fb1;
      font-size: 20px;
      font-weight: bold;
    }
    .welcome {
      margin: 15px 0;
      color: #7795e0;
      span {
        color: #71aaf2;
      }
    }
    .login-form {
      .username-wrap {
        position: relative;
        border-bottom: 1px solid #d2dcf5;
        .username-icon {
          width: 20px;
          position: absolute;
          left: 5px;
          top: 9px;
          z-index: 100;
        }
        /deep/ .van-field__body {
          padding-left: 20px;
          box-sizing: border-box;
        }
        /deep/ .van-field__error-message{
          padding-left: 20px;
        }
      }
       .passworld-wrap {
        position: relative;
        border-bottom: 1px solid #d2dcf5;
        .passworld-icon {
          width: 20px;
          position: absolute;
          left: 5px;
          top: 9px;
          z-index: 100;
        }
        /deep/ .van-field__body {
          padding-left: 20px;
          box-sizing: border-box;
        }
        /deep/ .van-field__error-message{
          padding-left: 20px;
        }
      }

    }
  }
}

</style>