login.vue 4.19 KB
<template>
  <view class="login-page">
    <view class="header-hero" :style="{ paddingTop: (statusBarHeight + 40) + 'px' }">
      <view class="logo-section">
        <image class="login-logo" src="/static/logo_us.png" mode="aspectFit" />
        <text class="hero-sub">{{ t('login.employeePortal') }}</text>
      </view>
    </view>

    <view class="form-wrap">
      <view class="form-card">
        <view class="form-group">
          <text class="label">{{ t('login.email') }}</text>
          <input
            v-model="email"
            type="text"
            class="input"
            :placeholder="t('login.emailPlaceholder')"
            placeholder-class="placeholder"
          />
        </view>
        <view class="form-group">
          <text class="label">{{ t('login.password') }}</text>
          <input
            v-model="password"
            type="password"
            class="input"
            :placeholder="t('login.passwordPlaceholder')"
            placeholder-class="placeholder"
          />
        </view>
        <view class="form-row">
          <view class="remember-row">
            <switch :checked="rememberMe" @change="rememberMe = $event.detail.value" :color="'#1F3A8A'" />
            <text class="remember-text">{{ t('login.rememberMe') }}</text>
          </view>
          <text class="forgot-link">{{ t('login.forgotPassword') }}</text>
        </view>
        <view
          class="submit-btn"
          :class="{ disabled: isLoading }"
          @click="handleLogin"
        >
          <text class="submit-btn-text">{{ isLoading ? t('login.signingIn') : t('login.signIn') }}</text>
        </view>
      </view>
      <text class="copyright">{{ t('login.copyright') }}</text>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { getStatusBarHeight } from '../../utils/statusBar'

const { t } = useI18n()
const statusBarHeight = getStatusBarHeight()
const email = ref('')
const password = ref('')
const rememberMe = ref(false)
const isLoading = ref(false)

const handleLogin = () => {
  isLoading.value = true
  setTimeout(() => {
    uni.setStorageSync('isLoggedIn', 'true')
    uni.setStorageSync('userName', 'John Smith')
    uni.showToast({ title: t('login.loginSuccess'), icon: 'success' })
    uni.redirectTo({ url: '/pages/store-select/store-select' })
    isLoading.value = false
  }, 1000)
}
</script>

<style scoped>
.login-page {
  min-height: 100vh;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
}

.header-hero {
  background: linear-gradient(135deg, var(--theme-primary), var(--theme-primary-dark));
  padding: 0 48rpx 64rpx;
  text-align: center;
}

.logo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-logo {
  width: 420rpx;
  height: 140rpx;
  margin-bottom: 20rpx;
  background: rgba(255,255,255,0.92);
  border-radius: 16rpx;
  padding: 16rpx;
}

.hero-sub {
  font-size: 28rpx;
  color: rgba(255,255,255,0.85);
}

.form-wrap {
  flex: 1;
  padding: 48rpx;
  margin-top: -32rpx;
}

.form-card {
  background: #fff;
  padding: 48rpx;
  border-radius: 20rpx;
  box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.06);
}

.form-group {
  margin-bottom: 40rpx;
}

.label {
  font-size: 30rpx;
  font-weight: 500;
  color: #374151;
  display: block;
  margin-bottom: 16rpx;
}

.input {
  height: 96rpx;
  padding: 0 24rpx;
  background: #f3f4f6;
  border-radius: 16rpx;
  font-size: 32rpx;
}

.placeholder {
  color: #9ca3af;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40rpx;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 16rpx;
}

.remember-text {
  font-size: 28rpx;
  color: #374151;
}

.forgot-link {
  font-size: 28rpx;
  color: var(--theme-primary);
  font-weight: 500;
}

.submit-btn {
  width: 100%;
  height: 96rpx;
  background: var(--theme-primary);
  border-radius: 16rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.submit-btn.disabled {
  opacity: 0.7;
}

.submit-btn-text {
  font-size: 32rpx;
  font-weight: 600;
  color: #ffffff;
  line-height: 1;
}

.copyright {
  display: block;
  text-align: center;
  font-size: 24rpx;
  color: #9ca3af;
  margin-top: 48rpx;
}
</style>