<template>
	<view class="login-box">
		登录
		<button type="primary" :loading="loginStatus" @tap="handleLogin">登录</button>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {
		useUserStore
	} from '@/store';
	const userStore = useUserStore();

	const loginStatus = ref(false);

	const handleLogin = async () => {
		loginStatus.value = true
		let loginRes = await userStore.loginAction({
			usernam: 'admin',
			password: 'tofly028'
		});
		if (loginRes) {
			uni.switchTab({
				url: '/pages/index/index'
			})
		} else {
			uni.showToast({
				title: '登录失败',
				duration: 1500
			})
		}
		loginStatus.value = false
	}
</script>

<style>
</style>