<template>
  <div class="w-full vh100">
    <div class="w-full flex-wrap ">
      <img class="w-full" src="@/assets/img/login/top_bg.png" />
      <div class="w-full bg-primary-yellow h46 lh46 pl30 flex-wrap flex cursor-pointer">
        <div class="w80 bg-primary-darkyellow">首页</div>
        <div class="w80">体验</div>
      </div>
    </div>
    <div class="mid">
      <div class="left">
        <div class="title">登录</div>
        <div class="content">
          <div class="row">
            <img class="preicon" src="@/assets/img/login/username_icon.png" />
            <input
              v-model="loginForm.username"
              placeholder="请输入账号"
              class="username"
            />
          </div>
          <div class="row">
            <img class="preicon" src="@/assets/img/login/password_icon.png" />
            <input
              v-model="loginForm.password"
              :checked="isSavePassword"
              placeholder="请输入密码"
              type="password"
              class="password"
            />
          </div>
          <div class="row mt20 flex justify-between">
            <img class="w80 h30" v-if="codeUrl" :src="codeUrl" />
            <input
              v-model="loginForm.code"
              placeholder="验证码"
              type="text"
              class="w160 h30 pl10 border-0 outline-0 border-light-gray"
            />
          </div>

          <div class="w-full save">
            <input class="save-input" type="checkbox" />
            <span class="save-text">记住用户名和密码</span>
          </div>
          <div class="submit">
            <button @click="loginByPassword" class="confirm">确定</button>
            <button class="cancel">取消</button>
          </div>
        </div>
      </div>

      <div class="right">
        <img class="w-full" src="@/assets/img/login/right_bg.png" />
      </div>
    </div>
    <div>
      <div class="w-full tip">
        <div>
          <div>
            1、请注意：第一次使用时需要安装播放电脑插件，否则不能登陆哦，<a
              class="tip-download"
              href="https://www.google.cn/chrome/index.html"
              >点击下载插件</a
            >
            看安装说明
          </div>
          <div>2、本网站推荐用360浏览器，分辨率为1024*768以上</div>
        </div>
      </div>
    </div>
    <div class="mt25">闽ICP备05017640号-10</div>
  </div>
</template>

<script lang="ts">
import api from "@/api";
import router from "@/router";
import { defineComponent, reactive, toRefs } from "vue";
export default defineComponent({
  setup() {
    const state = reactive({
      codeUrl: "",
      isSavePassword: false,
      loginForm: {
        uuid: "",
        code: "",
        username: "hc",
        password: "123456",
      },
    });
    return {
      ...toRefs(state),
    };
  },
  mounted() {
    this.getCaptchaImage()
  },
  methods: {
    loginByPassword() {
      console.log("登录了");
      api.login.login(this.loginForm).then(res=>{
        window.localStorage.setItem('token',res.data.token)
        router.push('/home/sysconfig')
        console.log(res.data.token)
     

      })

    },
    getCaptchaImage() {
      api.login.captchaImage().then((res) => {
        // console.log(res)
        this.codeUrl = "data:image/gif;base64," + res.data.img;
        this.loginForm.uuid = res.data.uuid;
      });
    },
  },
});
</script>

<style lang="scss"  scoped>
.border-light-gray {
  border: 1px solid #d9d9d9;
}
.mid {
  display: flex;
  justify-content: space-between;
  width: 1109px;
  margin: 0 auto;
  margin-top: 58px;
  align-content: center;
  align-items: center;
  .left {
    width: 351px;
    background: #fffcef;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    align-items: flex-start;
    justify-content: center;
    border-radius: 10px 10px 10px 10px;
    height: 451px;

    .submit {
      margin-top: 50px;
      display: flex;
      justify-content: space-between;
      .confirm {
        width: 110px;
        height: 40px;
        background: #f9de5b;
        opacity: 1;
        border: none;
        cursor: pointer;
      }
      .confirm:hover {
        background: #f2c901;
      }
      .cancel:hover {
        background: #f2c901;
      }
      .cancel {
        width: 110px;
        height: 40px;
        background: #f9de5b;
        opacity: 1;
        border: none;
        cursor: pointer;
      }
    }
    .save {
      text-align: left;
      margin-top: 15px;
      .save-input {
      }
      .save-text {
        font-size: 14px;
      }
    }

    input[type="checkbox"] {
      margin-right: 5px;

      cursor: pointer;

      font-size: 14px;

      width: 15px;

      height: 12px;

      position: relative;
    }

    input[type="checkbox"]:after {
      position: absolute;

      width: 16px;

      height: 16px;

      top: 0;
      left: 0px;

      content: " ";

      background-color: #f9de5b;

      color: #fff;

      display: inline-block;

      visibility: visible;

      border-radius: 3px;
    }

    input[type="checkbox"]:checked:after {
      width: 16px;
      height: 16px;
      background-size: 100%;
      background-image: url("./../../assets/img/login/checked_icon.png");
    }

    .title {
      padding-top: 55px;
      padding-bottom: 40px;
      font-size: 24px;
      color: #333;
      width: 100%;
    }
    .row {
      position: relative;
      width: 100%;
      .preicon {
        position: absolute;
        top: 7.5px;
        left: 10px;
        width: 15px;
      }
      .username {
        width: 286px;
        height: 30px;
        background: #ffffff;
        border-radius: 4px 4px 4px 4px;
        opacity: 1;
        border: 1px solid #d9d9d9;
        margin-bottom: 15px;
        outline: none;
        padding-left: 30px;
      }
      .password {
        width: 286px;
        height: 30px;
        background: #ffffff;
        border-radius: 4px 4px 4px 4px;
        opacity: 1;
        border: 1px solid #d9d9d9;
        outline: none;
        padding-left: 30px;
      }
    }
  }
  .right {
    width: 672px;
  }
}
.tip {
  display: flex;
  justify-content: center;
  text-align: left;
  line-height: 1.5;
  margin-top: 35px;
  .tip-download {
    text-decoration: underline;
    text-underline-offset: 4px;
    color: #333;
  }
}

.bg-primary-yellow {
  background-color: #f9de5b;
}
.bg-primary-darkyellow {
  background-color: #f2c900;
}
</style>