index.vue 3.07 KB
<template>
  <view class="min-h-screen bg-white flex flex-col">
    <!-- Header -->
    <NavHeader title="登录" :show-back="true" />

    <view class="flex-1 flex flex-col px-[48rpx] pt-[80rpx]">
      <!-- Logo/Title -->
      <view class="mb-[80rpx]">
        <view class="text-[48rpx] font-bold text-gray-900 mb-[16rpx]">欢迎登录</view>
        <view class="text-[28rpx] text-gray-500">Manulife 宏利</view>
      </view>

      <!-- Form -->
      <view class="space-y-[48rpx]">
        <!-- Username -->
        <view class="border-b border-gray-200 pb-[16rpx]">
          <view class="text-[28rpx] text-gray-900 font-medium mb-[16rpx]">账号</view>
          <input
            v-model="form.username"
            type="text"
            placeholder="请输入账号"
            placeholder-class="text-gray-300"
            class="w-full text-[32rpx] text-gray-900 h-[80rpx]"
          />
        </view>

        <!-- Password -->
        <view class="border-b border-gray-200 pb-[16rpx]">
          <view class="text-[28rpx] text-gray-900 font-medium mb-[16rpx]">密码</view>
          <input
            v-model="form.password"
            type="password"
            placeholder="请输入密码"
            placeholder-class="text-gray-300"
            class="w-full text-[32rpx] text-gray-900 h-[80rpx]"
          />
        </view>
      </view>

      <!-- Actions -->
      <view class="mt-[80rpx]">
        <button
          class="w-full h-[96rpx] bg-[#2563EB] rounded-[48rpx] flex items-center justify-center text-white text-[32rpx] font-bold active:opacity-90 after:border-none"
          @tap="handleLogin"
        >
          登录
        </button>
      </view>

      <!-- Links -->
      <view class="mt-[48rpx] flex justify-between text-[28rpx]">
        <view class="text-gray-500" @tap="handleForgotPassword">忘记密码</view>
        <view class="text-[#2563EB]" @tap="handleRegister">立即注册</view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { reactive } from 'vue'
import Taro from '@tarojs/taro'
import { useGo } from '@/hooks/useGo'
import NavHeader from '@/components/NavHeader.vue'

const go = useGo()

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

/**
 * Handle login action
 */
const handleLogin = () => {
  if (!form.username) {
    Taro.showToast({ title: '请输入账号', icon: 'none' })
    return
  }
  if (!form.password) {
    Taro.showToast({ title: '请输入密码', icon: 'none' })
    return
  }

  // Mock login success
  Taro.showLoading({ title: '登录中...' })
  setTimeout(() => {
    Taro.hideLoading()
    Taro.showToast({ title: '登录成功', icon: 'success' })
    setTimeout(() => {
      // Redirect to home or previous page
      Taro.reLaunch({ url: '/pages/index/index' })
    }, 1500)
  }, 1000)
}

const handleForgotPassword = () => {
    Taro.showToast({ title: '功能开发中', icon: 'none' })
}

const handleRegister = () => {
    Taro.showToast({ title: '功能开发中', icon: 'none' })
}
</script>

<style lang="less">
/* Reset button default styles if needed */
button::after {
  border: none;
}
</style>