<template>
  <view class="">
    <uv-form>
      <uv-form-item>
        <view class="h-92rpx bg-white rounded-full w-full flex-center">
          <uv-input
            v-model="form.username"
            shape="circle"
            maxlength="11"
            placeholder="请输入帐号"
            type="text"
            border="none1"
            fontSize="27rpx"
          >
          </uv-input>
        </view>
      </uv-form-item>

      <uv-form-item>
        <view class="h-92rpx bg-white rounded-full w-full flex-center">
          <uv-input
            v-model="form.password"
            shape="circle"
            placeholder="请输入密码"
            type="password"
            border="none1"
            fontSize="27rpx"
          >
          </uv-input>
        </view>
      </uv-form-item>
    </uv-form>
    <view class="mt-115rpx">
      <uv-button block type="primary" shape="circle" @click="handleClick"
        >登录</uv-button
      >
    </view>
  </view>
</template>
<script setup>
import { ref, reactive, computed } from 'vue'
import { useUserStore } from '@/store/modules/user'

const userStore = useUserStore()

const form = ref({
  username: '',
  password: '',
})

const handleClick = async () => {
  try {
    const { username, password } = form.value
    await userStore.login({
      username,
      password,
    })
    uni.switchTab({
      url: '/pages/home/index',
    })
  } catch (e) {
    console.log(e)
  }
}
</script>
