<template>
  <div class="flex w-screen h-screen justify-center items-center bg ">
    <div class="w-1/4 flex justify-center items-center rounded-xl bg-white">
      <!--            <img src="@/assets/images/login-icon.png" alt="" class="mr-1 w-2/4">-->
      <div class="flex justify-center items-center flex-col w-full p-4 shadow-xl rounded-xl">
<!--        <img src="@/assets/images/logo.jpg" alt="" style="height: 5rem">-->
        <span class="text-center my-3 text-2xl font-bold">营业端管理登录</span>
        <el-form class="w-full flex flex-col items-end" label-width="80">
          <el-form-item label="用户名" class="w-full">
            <el-input v-model="username" placeholder="请输入用户名"/>
          </el-form-item>
          <el-form-item label="密码" class="w-full">
            <el-input v-model="password" type="password" @keyup.enter.native="login"
                      placeholder="请输入密码"/>
          </el-form-item>
          <el-button @click.native="login" type="primary" class="w-11/12" color="#27AB49">登录</el-button>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script setup>
import {ref} from 'vue'
import {useRouter} from 'vue-router'
import {loginReq} from '@/api/admin.js'
import {setUserInfo} from '@/api/common.js'
import {ElMessage} from 'element-plus'

const router = useRouter()

let username = ref(null)
let password = ref(null)

const login = async () => {
  const res = await loginReq({username: username.value, password: password.value})
  if (res.data) {
    ElMessage.success({
      message: '登陆成功'
    });
    setUserInfo(res.data)
    await router.push('/Index')
  }
}


</script>

<style scope>
.bg {
  background-image: url("@/assets/bg.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  width: 100vw;
  height: 100vh;
}
</style>
