feat: add static A01 A02 auth UI

This commit is contained in:
rain
2026-07-13 14:31:19 +08:00
parent 89dd20cec0
commit 134ae75c2b
8 changed files with 708 additions and 84 deletions
+297 -62
View File
@@ -1,84 +1,319 @@
<template>
<view class="page-shell login-page">
<view class="ceremony-top">
<text class="seal-word"></text>
<text class="eyebrow">家脉绵延 · 生生不息</text>
<text class="brand-title">家谱</text>
<text class="brand-subtitle">为家族留存可传承的记忆</text>
</view>
<view class="auth-page login-page">
<image class="paper-background" src="/static/assets/backgrounds/auth-rice-paper-v1.jpg" mode="aspectFill" />
<image class="scenery-background" src="/static/assets/backgrounds/auth-ink-scenery-v1.png" mode="aspectFill" />
<view class="login-paper">
<view class="section-title">登录家谱</view>
<text class="form-note">使用已注册手机号和密码登录</text>
<text class="form-label">手机号</text>
<input v-model="phone" class="line-input" type="number" maxlength="11" placeholder="请输入手机号" placeholder-class="placeholder" />
<text class="form-label">密码</text>
<input v-model="password" class="line-input" password placeholder="请输入密码" placeholder-class="placeholder" />
<text v-if="errorMessage" class="error-message">{{ errorMessage }}</text>
<button class="primary-button login-button" :loading="isSubmitting" :disabled="isSubmitting" @click="login">进入家谱</button>
<text class="login-tip">短信登录将在验证码服务联调后开放</text>
<text class="terms">登录即表示同意用户协议隐私政策</text>
<view class="auth-content">
<view class="auth-header">
<image class="header-background" src="/static/assets/backgrounds/auth-ancestral-header-v1.png" mode="aspectFill" />
<image class="header-seal" src="/static/assets/icons/brand/jiapu-seal-logo-header.png" mode="aspectFit" />
</view>
<view class="login-panel">
<view class="page-heading">
<view class="back-button" hover-class="back-hover" @click="goBack"></view>
<view>
<text class="page-title">登录家谱</text>
<text class="page-subtitle">欢迎回到家族记忆</text>
</view>
</view>
<view class="login-tabs">
<view class="login-tab" :class="{ active: activeTab === 'password' }" @click="activeTab = 'password'">
<text>账号密码登录</text>
</view>
<view class="login-tab" :class="{ active: activeTab === 'sms' }" @click="activeTab = 'sms'">
<text>手机验证码登录</text>
</view>
</view>
<view v-if="activeTab === 'password'" class="form-content">
<view class="input-row">
<text class="input-label">账号</text>
<input v-model.trim="account" class="auth-input" placeholder="请输入账号或手机号" placeholder-class="placeholder" />
</view>
<view class="input-row">
<text class="input-label">密码</text>
<input v-model="password" class="auth-input" password placeholder="请输入密码" placeholder-class="placeholder" />
</view>
<view class="secondary-action" hover-class="text-hover" @click="prepareForgotPassword">忘记密码</view>
</view>
<view v-else class="form-content">
<view class="input-row">
<text class="input-label">手机</text>
<input v-model.trim="smsPhone" class="auth-input" type="number" maxlength="11" placeholder="请输入手机号" placeholder-class="placeholder" />
</view>
<view class="input-row code-row">
<text class="input-label">验证码</text>
<input v-model.trim="verificationCode" class="auth-input" type="number" maxlength="6" placeholder="请输入验证码" placeholder-class="placeholder" />
<view class="get-code" hover-class="text-hover" @click="prepareGetCode">获取验证码</view>
</view>
</view>
<view class="login-submit" hover-class="button-hover" @click="submitLogin">登录</view>
<text class="agreement-reminder">请先在登录引导页阅读并确认协议</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { appApi } from '@/utils/api.js'
import { calcMD5 } from '@/utils/md5.js'
import { onLoad } from '@dcloudio/uni-app'
const phone = ref('')
const activeTab = ref('password')
const account = ref('')
const password = ref('')
const isSubmitting = ref(false)
const errorMessage = ref('')
const smsPhone = ref('')
const verificationCode = ref('')
const agreedFromEntry = ref(false)
const login = async () => {
if (!/^1\d{10}$/.test(phone.value)) {
uni.showToast({ title: '请输入正确手机号', icon: 'none' })
return
}
if (!password.value) {
uni.showToast({ title: '请输入登录密码', icon: 'none' })
return
onLoad((options) => {
agreedFromEntry.value = options?.agreed === '1'
})
const goBack = () => {
uni.navigateBack()
}
const prepareForgotPassword = () => {
uni.showToast({ title: '忘记密码页面准备中', icon: 'none' })
}
const prepareGetCode = () => {
uni.showToast({ title: '获取验证码功能待接入', icon: 'none' })
}
const canSubmit = () => {
if (agreedFromEntry.value) return true
uni.showToast({ title: '请先返回登录引导确认协议', icon: 'none' })
return false
}
const submitLogin = () => {
if (!canSubmit()) return
if (activeTab.value === 'password') {
if (!account.value) {
uni.showToast({ title: '请输入账号或手机号', icon: 'none' })
return
}
if (!password.value) {
uni.showToast({ title: '请输入密码', icon: 'none' })
return
}
} else {
if (!/^1\d{10}$/.test(smsPhone.value)) {
uni.showToast({ title: '请输入正确手机号', icon: 'none' })
return
}
if (!verificationCode.value) {
uni.showToast({ title: '请输入验证码', icon: 'none' })
return
}
}
isSubmitting.value = true
errorMessage.value = ''
try {
await appApi.loginWithPassword({ phone: phone.value, passwordHash: calcMD5(password.value) })
uni.reLaunch({ url: '/pages/genealogy/index' })
} catch (error) {
errorMessage.value = error.message || '登录失败,请稍后重试'
} finally {
isSubmitting.value = false
}
uni.showToast({ title: '登录接口待接入', icon: 'none' })
}
</script>
<style scoped lang="scss">
.login-page { padding-top: 108rpx; }
.ceremony-top {
display: flex;
flex-direction: column;
align-items: center;
padding: 40rpx 40rpx 76rpx;
background: $brand-red;
color: #fff9ed;
.auth-page {
position: relative;
min-height: 100vh;
background: #f7f1e6;
}
.seal-word { display: flex; width: 66rpx; height: 66rpx; align-items: center; justify-content: center; box-sizing: border-box; border: 2rpx solid #f1d494; border-radius: 50%; color: #f5ddaa; font-family: serif; font-size: 37rpx; }
.eyebrow { margin-top: 24rpx; color: #f8dfad; font-size: 22rpx; letter-spacing: 5rpx; }
.brand-title { margin-top: 24rpx; font-family: serif; font-size: 68rpx; font-weight: 700; letter-spacing: 16rpx; }
.brand-subtitle { margin-top: 18rpx; color: #f5deae; font-size: 26rpx; letter-spacing: 3rpx; }
.paper-background,
.scenery-background {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
.paper-background { opacity: 0.96; }
.scenery-background { opacity: 0.76; }
.auth-content {
position: relative;
z-index: 1;
box-sizing: border-box;
min-height: 100vh;
padding-bottom: calc(44rpx + env(safe-area-inset-bottom));
}
.auth-header {
position: relative;
height: 196rpx;
overflow: hidden;
}
.header-background {
width: 100%;
height: 100%;
}
.header-seal {
position: absolute;
top: 34rpx;
left: 50%;
width: 124rpx;
height: 124rpx;
transform: translateX(-50%);
}
.login-panel {
margin: 68rpx 56rpx 0;
padding: 46rpx 38rpx 54rpx;
border: 2rpx solid #d6ad6c;
border-radius: 10rpx;
background: rgba(255, 252, 246, 0.78);
box-shadow: inset 0 0 0 5rpx rgba(255, 255, 255, 0.55);
}
.page-heading {
display: flex;
align-items: center;
}
.back-button {
display: flex;
align-items: center;
justify-content: center;
width: 48rpx;
height: 48rpx;
margin-right: 20rpx;
border: 1rpx solid #d7ae70;
border-radius: 50%;
color: #9d5b28;
font-size: 52rpx;
font-weight: 300;
line-height: 40rpx;
}
.back-hover { opacity: 0.62; }
.page-title,
.page-subtitle {
display: block;
}
.page-title {
color: #3f2c1d;
font-family: STKaiti, KaiTi, serif;
font-size: 46rpx;
font-weight: 700;
letter-spacing: 4rpx;
}
.page-subtitle {
margin-top: 8rpx;
color: #8c7864;
font-size: 22rpx;
letter-spacing: 2rpx;
}
.login-tabs {
display: flex;
margin-top: 54rpx;
border-bottom: 1rpx solid #dcc29a;
}
.login-tab {
position: relative;
flex: 1;
padding: 0 0 24rpx;
color: #89715a;
font-family: STKaiti, KaiTi, serif;
font-size: 29rpx;
text-align: center;
}
.login-tab.active {
color: #a7160c;
font-weight: 700;
}
.login-tab.active::after {
position: absolute;
right: 28rpx;
bottom: -1rpx;
left: 28rpx;
height: 4rpx;
border-radius: 4rpx;
background: #b7170d;
content: '';
}
.form-content { margin-top: 26rpx; }
.input-row {
display: flex;
align-items: center;
min-height: 96rpx;
border-bottom: 1rpx solid #e5d4b7;
}
.input-label {
width: 92rpx;
color: #674b35;
font-family: STKaiti, KaiTi, serif;
font-size: 30rpx;
}
.auth-input {
flex: 1;
height: 88rpx;
color: #3f2c1d;
font-size: 28rpx;
}
.login-paper { margin: -28rpx 28rpx 0; padding: 48rpx 42rpx; border: 1rpx solid $gold-soft; border-radius: 24rpx; background: $paper-white; }
.form-note { display: block; margin-top: 14rpx; color: $ink-muted; font-size: 23rpx; }
.form-label { display: block; margin-top: 40rpx; color: $ink-muted; font-size: 25rpx; }
.line-input { height: 78rpx; border-bottom: 1rpx solid $gold-soft; color: $ink; font-size: 30rpx; }
.placeholder { color: #b3a895; }
.error-message { display: block; margin-top: 22rpx; color: $brand-red; font-size: 23rpx; line-height: 1.5; }
.login-button { margin-top: 48rpx; }
.login-tip { display: block; margin-top: 24rpx; color: $ink-muted; font-size: 22rpx; text-align: center; }
.terms { display: block; margin-top: 16rpx; color: #a39785; font-size: 21rpx; text-align: center; }
.code-row .auth-input { min-width: 0; }
.get-code {
flex: 0 0 auto;
padding-left: 20rpx;
border-left: 1rpx solid #ddc7a3;
color: #a7160c;
font-size: 25rpx;
}
.secondary-action {
margin-top: 28rpx;
color: #a7160c;
font-size: 25rpx;
text-align: right;
}
.text-hover { opacity: 0.64; }
.login-submit {
display: flex;
align-items: center;
justify-content: center;
height: 100rpx;
margin-top: 60rpx;
border: 2rpx solid #9e170e;
border-radius: 8rpx;
background: #b7170d;
box-shadow: inset 0 0 0 4rpx #d69b5f;
color: #fffaf0;
font-family: STKaiti, KaiTi, serif;
font-size: 36rpx;
letter-spacing: 6rpx;
}
.button-hover { opacity: 0.84; }
.agreement-reminder {
display: block;
margin-top: 26rpx;
color: #9a8773;
font-size: 22rpx;
text-align: center;
}
</style>