<template>
  <div class="admin-login">
    <form class="admin-login__panel" @submit.prevent="submit">
      <span class="eyebrow">ADMIN</span>
      <h1>萧康云医后台</h1>
      <p>管理官网线索、套餐订单、角色权限和菜单布局。</p>
      <input v-model="form.account" class="form-input" placeholder="账号" />
      <input v-model="form.password" class="form-input" type="password" placeholder="密码" />
      <button class="primary-button justify-center" type="submit">登录后台</button>
    </form>
  </div>
</template>

<script setup>
import { reactive } from 'vue'
import { useRouter } from 'vue-router'
import { adminLogin } from '@/api/request/admin'

const router = useRouter()
const form = reactive({ account: 'admin', password: '123456' })

const submit = async () => {
  const res = await adminLogin(form)
  localStorage.setItem('token', res.token)
  localStorage.setItem('user', JSON.stringify(res.user))
  router.push('/admin/dashboard')
}
</script>
