<template>
  <div>
    <div class="login_top"></div>
    <div class="login_out">
      <div class="login_logo"></div>
    </div>
    <div class="login_content">
      <div class="">您好~</div>
      <div style="margin-bottom: 20px">享受味蕾的盛宴 从一杯酒开始</div>
      <div class="form_item">
        <input class="form_input" v-model="accountName" type="text" placeholder="请输入登录名">
      </div>
      <div class="form_item">
        <input class="form_input" v-model="password"  type="password" placeholder="请输入密码">
      </div>
      <div class="form_button">
        <nut-button type="success" @click="submit" block>登录</nut-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Login"
}
</script>
<script setup>
  import { ref } from 'vue';
  import { useRouter } from "vue-router";
  import { login } from '../../assets/api/user';
  import utils from '../../utils/lib';
  import { setToken, setIsSuper } from '../../utils/auth'
  import { showToast } from "@nutui/nutui";


  const router = useRouter();

  const accountName = ref('');
  const password = ref('');



  const submit = () => {
    let params = {
      account: accountName.value,
      password: password.value
    }
    login(params).then(res => {
      setToken(res)
      router.replace('/home')
    })

  }
</script>

<style scoped>
  .login_top {
    width: 100%;
    height: 80px;
  }
  .login_out {
    width: 100%;
    height: 140px;
    position: relative;
  }
  .login_logo {
    width: 85px;
    height: 78px;
    /*background: url('https://dam.img.ifarmcloud.com:8030/images/tongwei/logo.png') no-repeat;*/
    /*background-size: 100% 100%;*/
    background: url("../../assets/favicon.png") no-repeat;
    background-size: 100% 100%;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }

  .login_content {
    width: 100%;
    box-sizing: border-box;
    padding: 16px;
  }
  .form_item {
    width: 100%;
    height: 54px;
    background: #FFFFFF;
    box-shadow: 0px 8px 30px 0px rgba(0,0,0,0.06);
    border-radius: 15px;
    box-sizing: border-box;
    padding: 0 14px;
    position: relative;
    margin-bottom: 20px;
  }

  .form_input {
    width: 100%;
    height: 54px;
    line-height: 54px;
    font-size: 16px;
    border: none;
    background: none;
    margin: 0;
    padding: 0;
  }
  .form_input:focus {
    outline: none;
  }
  .form_button {
    width: 100%;
    box-sizing: border-box;
    padding: 0 30px;
  }
</style>
