Files
JayuCloud/JY-Artist-Frontend/src/views/AuthView.vue
T

1881 lines
57 KiB
Vue
Raw Normal View History

2026-02-24 09:59:22 +08:00
<template>
<div class="mobile-container">
2026-05-31 18:36:52 +08:00
<header class="auth-topbar">
<button class="auth-back-button" type="button" aria-label="返回" @click="handleBackClick">
<LeftOutlined />
</button>
2026-06-24 22:13:00 +08:00
<strong>{{ BRAND_CONFIG.appName }}</strong>
2026-05-31 18:36:52 +08:00
<span class="auth-topbar-spacer" aria-hidden="true"></span>
</header>
2026-05-29 13:30:56 +08:00
<main class="auth-page">
2026-06-24 22:13:00 +08:00
<section class="brand-stage" :aria-label="BRAND_CONFIG.appName">
<p class="brand-name">{{ BRAND_CONFIG.appName }}</p>
<p class="brand-copy">{{ activeTab === 'login' ? '登录后继续预约与收藏' : '填写信息完成账号注册' }}</p>
2026-05-29 13:30:56 +08:00
</section>
<section class="auth-container" aria-label="账号登录注册">
<button
v-if="activeTab === 'register'"
class="auth-mode-link auth-mode-link--top"
type="button"
2026-02-24 09:59:22 +08:00
@click="activeTab = 'login'"
>
返回登录
</button>
2026-02-24 09:59:22 +08:00
<div v-if="activeTab === 'login'" class="login-type-toggle">
<a-radio-group v-model:value="loginType" button-style="solid">
<a-radio-button value="phone">手机号验证码登录</a-radio-button>
2026-07-06 17:35:12 +08:00
<a-radio-button value="password">账号密码登录</a-radio-button>
</a-radio-group>
</div>
2026-02-24 09:59:22 +08:00
<a-form
:model="formData"
:rules="currentRules"
2026-02-24 09:59:22 +08:00
@finish="handleSubmit"
layout="vertical"
class="auth-form"
>
<a-form-item v-if="activeTab === 'register'" name="nickname" label="昵称">
2026-02-24 09:59:22 +08:00
<a-input
v-model:value="formData.nickname"
placeholder="请输入昵称"
2026-02-24 09:59:22 +08:00
size="large"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<UserOutlined style="color: var(--text-secondary)" />
2026-02-24 09:59:22 +08:00
</template>
</a-input>
</a-form-item>
<a-form-item v-if="activeTab === 'register'" name="account" label="账号">
<a-input
v-model:value="formData.account"
placeholder="请输入账号"
size="large"
@input="handleAccountInput"
2026-03-19 20:51:07 +08:00
@blur="handleRegisterAccountBlur"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<UserOutlined style="color: var(--text-secondary)" />
</template>
</a-input>
2026-03-19 20:51:07 +08:00
<div
v-if="registerAccountStatus"
class="field-status"
:class="registerAccountStatus.available ? 'success' : 'error'"
>
{{ registerAccountStatus.message }}
</div>
</a-form-item>
<a-form-item v-if="activeTab === 'register'" name="phone" label="手机号">
<a-input
v-model:value="formData.phone"
placeholder="请输入手机号"
size="large"
2026-03-19 20:51:07 +08:00
@blur="handleRegisterPhoneBlur"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<UserOutlined style="color: var(--text-secondary)" />
</template>
</a-input>
2026-03-19 20:51:07 +08:00
<div
v-if="registerPhoneStatus"
class="field-status"
:class="registerPhoneStatus.available ? 'success' : 'error'"
>
{{ registerPhoneStatus.message }}
</div>
</a-form-item>
<a-form-item v-if="activeTab === 'register'" name="verificationCode" label="验证码">
<a-input
v-model:value="formData.verificationCode"
placeholder="请输入验证码"
size="large"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<LockOutlined style="color: var(--text-secondary)" />
</template>
<template #suffix>
<a-button
type="link"
:disabled="countdown > 0 || !formData.phone"
@click="handleSendVerificationCode"
>
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
</a-button>
</template>
</a-input>
</a-form-item>
<a-form-item
v-if="activeTab === 'login' && loginType === 'password'"
name="account"
label="账号"
>
<a-input
v-model:value="formData.account"
placeholder="请输入账号"
size="large"
@input="handleAccountInput"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<UserOutlined style="color: var(--text-secondary)" />
</template>
</a-input>
<div
v-if="loginAccountStatus"
class="field-status"
:class="loginAccountStatus.exists ? 'success' : 'error'"
>
{{ loginAccountStatus.message }}
</div>
</a-form-item>
<a-form-item
v-if="activeTab === 'login' && loginType === 'phone'"
name="phone"
label="手机号"
>
<a-input
v-model:value="formData.phone"
placeholder="请输入手机号"
size="large"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<UserOutlined style="color: var(--text-secondary)" />
</template>
</a-input>
<div class="phone-login-tip">
2026-05-29 13:30:56 +08:00
<InfoCircleOutlined style="color: var(--theme-primary); margin-right: 4px;" />
<span>新用户将自动注册</span>
</div>
</a-form-item>
<a-form-item
v-if="activeTab === 'login' && loginType === 'phone'"
name="verificationCode"
label="验证码"
>
<a-input
v-model:value="formData.verificationCode"
placeholder="请输入验证码"
size="large"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<LockOutlined style="color: var(--text-secondary)" />
</template>
<template #suffix>
<a-button
type="link"
:disabled="countdown > 0 || !formData.phone"
@click="handleSendVerificationCode"
>
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
</a-button>
</template>
</a-input>
</a-form-item>
2026-03-19 20:51:07 +08:00
<a-form-item
v-if="activeTab === 'login'"
name="shopId"
label="选择登录店铺"
2026-05-29 13:30:56 +08:00
class="shop-select-item"
>
<a-select
v-model:value="formData.shopId"
:placeholder="loginShopPlaceholder"
size="large"
:loading="loadingShops"
:disabled="!allowLoginShopless && !loginShops.length"
2026-03-19 20:51:07 +08:00
allow-clear
>
2026-03-19 20:51:07 +08:00
<a-select-option
v-if="loginShops.length === 0"
disabled
value=""
>
{{ allowLoginShopless ? '当前无需选择店铺' : '暂无可用店铺' }}
</a-select-option>
2026-03-19 20:51:07 +08:00
<a-select-option
v-for="shop in loginShops"
2026-03-19 20:51:07 +08:00
:key="shop.id"
:value="normalizeShopOptionValue(shop.id)"
>
{{ shop.shopName }}
</a-select-option>
</a-select>
<div
v-if="loginShopMessage"
class="field-status"
:class="loginShops.length || allowLoginShopless ? 'success' : 'error'"
>
{{ loginShopMessage }}
</div>
</a-form-item>
<a-form-item
v-if="(activeTab === 'login' && loginType === 'password') || activeTab === 'register'"
name="password"
label="密码"
>
2026-02-24 09:59:22 +08:00
<a-input-password
v-model:value="formData.password"
placeholder="请输入密码"
size="large"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<LockOutlined style="color: var(--text-secondary)" />
2026-02-24 09:59:22 +08:00
</template>
</a-input-password>
</a-form-item>
<a-form-item v-if="activeTab === 'register'" name="confirmPassword" label="确认密码">
<a-input-password
v-model:value="formData.confirmPassword"
placeholder="请再次输入密码"
size="large"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<LockOutlined style="color: var(--text-secondary)" />
2026-02-24 09:59:22 +08:00
</template>
</a-input-password>
</a-form-item>
<a-form-item v-if="activeTab === 'register'" name="inviteCode" label="邀请码">
<a-input
v-model:value="formData.inviteCode"
placeholder="可不填,不填默认归属所选店铺店长"
size="large"
/>
</a-form-item>
2026-05-29 13:30:56 +08:00
<a-form-item v-if="activeTab === 'register'" name="shopId" label="选择店铺" class="shop-select-item">
2026-02-24 09:59:22 +08:00
<a-select
v-model:value="formData.shopId"
placeholder="请选择店铺"
size="large"
:loading="loadingShops"
>
<a-select-option
2026-02-24 09:59:22 +08:00
v-if="shops.length === 0"
disabled
value=""
>
暂无店铺数据
</a-select-option>
<a-select-option
v-for="shop in shops"
:key="shop.id"
:value="normalizeShopOptionValue(shop.id)"
2026-02-24 09:59:22 +08:00
>
{{ shop.shopName }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item v-if="activeTab === 'login'" style="margin-bottom: 8px">
<div class="form-actions">
<a-checkbox v-model:checked="formData.rememberMe">记住我</a-checkbox>
<a class="forgot-password" @click="handleForgotPassword">忘记密码?</a>
</div>
</a-form-item>
<a-form-item style="margin-bottom: 12px">
<a-checkbox v-model:checked="agreementAccepted">
我已阅读并同意
<a @click.stop.prevent="openAgreement('USER_TERMS')">《用户协议》</a>
和
<a @click.stop.prevent="openAgreement('PRIVACY_POLICY')">《隐私政策》</a>
</a-checkbox>
</a-form-item>
2026-02-24 09:59:22 +08:00
<a-form-item>
<a-button
type="primary"
html-type="submit"
size="large"
2026-02-24 09:59:22 +08:00
block
2026-05-29 13:30:56 +08:00
class="primary-action"
2026-02-24 09:59:22 +08:00
:loading="loading"
:disabled="!agreementAccepted"
2026-02-24 09:59:22 +08:00
>
{{ activeTab === 'login' ? '登录' : '注册' }}
</a-button>
</a-form-item>
<div class="social-login">
<div class="divider">
<span>微信手机号登录</span>
2026-02-24 09:59:22 +08:00
</div>
<div class="social-hint">
微信手机号授权登录请在小程序中使用;网页端可使用账号密码或验证码登录。
</div>
2026-05-29 13:30:56 +08:00
<button type="button" class="guest-entry" @click="router.push('/home')">
游客浏览
</button>
2026-02-24 09:59:22 +08:00
</div>
<div class="admin-login">
<span class="admin-login-link" @click="handleAdminLogin">管理后台登录</span>
</div>
<div v-if="activeTab === 'login'" class="auth-mode-footer">
<span>还没有账号?</span>
<button class="auth-mode-link" type="button" @click="activeTab = 'register'">
注册账号
</button>
</div>
2026-02-24 09:59:22 +08:00
</a-form>
2026-05-29 13:30:56 +08:00
</section>
</main>
2026-03-19 14:10:59 +08:00
<a-modal
v-model:open="forgotPasswordVisible"
2026-03-19 14:10:59 +08:00
title="忘记密码"
:footer="null"
width="90%"
:destroyOnClose="true"
>
<a-form
:model="forgotPasswordForm"
:rules="forgotPasswordRules"
@finish="handleResetPassword"
layout="vertical"
>
<a-form-item name="phone" label="手机号">
<a-input
v-model:value="forgotPasswordForm.phone"
placeholder="请输入绑定的手机号"
size="large"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<UserOutlined style="color: var(--text-secondary)" />
2026-03-19 14:10:59 +08:00
</template>
</a-input>
</a-form-item>
<a-form-item name="verificationCode" label="验证码">
<a-input
v-model:value="forgotPasswordForm.verificationCode"
placeholder="请输入验证码"
size="large"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<LockOutlined style="color: var(--text-secondary)" />
2026-03-19 14:10:59 +08:00
</template>
<template #suffix>
<a-button
type="link"
2026-03-19 14:10:59 +08:00
:disabled="forgotCountdown > 0 || !forgotPasswordForm.phone"
@click="handleSendForgotCode"
>
{{ forgotCountdown > 0 ? `${forgotCountdown}秒后重发` : '发送验证码' }}
</a-button>
</template>
</a-input>
</a-form-item>
<a-form-item name="newPassword" label="新密码">
<a-input-password
v-model:value="forgotPasswordForm.newPassword"
placeholder="请输入新密码"
size="large"
>
<template #prefix>
2026-05-29 13:30:56 +08:00
<LockOutlined style="color: var(--text-secondary)" />
2026-03-19 14:10:59 +08:00
</template>
</a-input-password>
</a-form-item>
<a-form-item>
<a-button
type="primary"
html-type="submit"
size="large"
2026-03-19 14:10:59 +08:00
block
:loading="resettingPassword"
>
重置密码
</a-button>
</a-form-item>
<a-form-item>
<a-button size="large" block @click="forgotPasswordVisible = false">
取消
</a-button>
</a-form-item>
</a-form>
</a-modal>
<a-modal
v-model:open="agreementModalOpen"
:title="selectedAgreement?.title || '协议内容'"
:footer="null"
width="90%"
>
<div class="agreement-content">
<div class="agreement-version">版本:{{ selectedAgreement?.version || '--' }}</div>
2026-05-29 13:30:56 +08:00
<div class="agreement-rich-content" v-html="agreementContentHtml"></div>
</div>
</a-modal>
2026-02-24 09:59:22 +08:00
</div>
</template>
<script setup lang="ts">
/**
* AuthView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
2026-02-24 09:59:22 +08:00
import { useRouter } from 'vue-router'
2026-05-31 18:36:52 +08:00
import { InfoCircleOutlined, LeftOutlined, LockOutlined, UserOutlined } from '@ant-design/icons-vue'
2026-02-24 09:59:22 +08:00
import { message } from 'ant-design-vue'
2026-03-10 23:23:15 +08:00
import type { Rule } from 'ant-design-vue/es/form'
2026-05-23 18:44:57 +08:00
/**
* Purpose: LegalAgreement supports AuthView.vue by holding or executing the legal agreement page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
import { authApi, legalAgreementApi, type LegalAgreement } from '@/api/auth'
2026-02-24 09:59:22 +08:00
import { shopApi } from '@/api/shop'
import { ACCOUNT_REGEX, ACCOUNT_RULE_MESSAGE, sanitizeAccountInput } from '@/utils/account'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { notifyShopThemeChanged } from '@/utils/shop-theme'
2026-05-29 13:30:56 +08:00
import { renderRichContent } from '@/utils/rich-content'
2026-06-24 22:13:00 +08:00
import { BRAND_CONFIG } from '@/config/brand'
import {
userApi,
type AvailabilityCheckResponse,
type LoginAccountCheckResponse,
type LoginShopSelectionResponse
} from '@/api/user'
2026-03-27 14:55:41 +08:00
import type { IdType } from '@/utils/id'
2026-02-24 09:59:22 +08:00
2026-05-23 18:44:57 +08:00
/**
* Purpose: router supports AuthView.vue by holding or executing the router page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-24 09:59:22 +08:00
const router = useRouter()
2026-05-31 18:36:52 +08:00
const handleBackClick = () => {
if (window.history.length > 1) {
router.back()
return
}
router.push('/home')
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: activeTab supports AuthView.vue by holding or executing the active tab page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-24 09:59:22 +08:00
const activeTab = ref<'login' | 'register'>('login')
2026-05-23 18:44:57 +08:00
/**
* Purpose: loginType supports AuthView.vue by holding or executing the login type page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-07-06 17:35:12 +08:00
const loginType = ref<'password' | 'phone'>('phone')
/** loading is a reactive state variable used by the template and event handlers. */
2026-02-24 09:59:22 +08:00
const loading = ref(false)
/** loadingShops is a reactive state variable used by the template and event handlers. */
2026-02-24 09:59:22 +08:00
const loadingShops = ref(false)
2026-05-23 18:44:57 +08:00
/**
* Purpose: shops supports AuthView.vue by holding or executing the shops page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-24 09:59:22 +08:00
const shops = ref<any[]>([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: loginShops supports AuthView.vue by holding or executing the login shops page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-27 14:55:41 +08:00
const loginShops = ref<Array<{ id: IdType; shopName: string }>>([])
/** countdown is a reactive state variable used by the template and event handlers. */
const countdown = ref(0)
2026-05-23 18:44:57 +08:00
/**
* Purpose: loginAccountStatus supports AuthView.vue by holding or executing the login account status page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const loginAccountStatus = ref<LoginAccountCheckResponse | null>(null)
2026-05-23 18:44:57 +08:00
/**
* Purpose: registerAccountStatus supports AuthView.vue by holding or executing the register account status page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-19 20:51:07 +08:00
const registerAccountStatus = ref<AvailabilityCheckResponse | null>(null)
2026-05-23 18:44:57 +08:00
/**
* Purpose: registerPhoneStatus supports AuthView.vue by holding or executing the register phone status page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-19 20:51:07 +08:00
const registerPhoneStatus = ref<AvailabilityCheckResponse | null>(null)
/** loginShopMessage is a reactive state variable used by the template and event handlers. */
const loginShopMessage = ref('')
/** allowLoginShopless is a reactive state variable used by the template and event handlers. */
const allowLoginShopless = ref(false)
2026-02-24 09:59:22 +08:00
/** forgotPasswordVisible is a reactive state variable used by the template and event handlers. */
2026-03-19 14:10:59 +08:00
const forgotPasswordVisible = ref(false)
/** forgotCountdown is a reactive state variable used by the template and event handlers. */
2026-03-19 14:10:59 +08:00
const forgotCountdown = ref(0)
/** resettingPassword is a reactive state variable used by the template and event handlers. */
2026-03-19 14:10:59 +08:00
const resettingPassword = ref(false)
2026-05-23 18:44:57 +08:00
/**
* Purpose: agreementAccepted supports AuthView.vue by holding or executing the agreement accepted page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const agreementAccepted = ref(false)
2026-05-23 18:44:57 +08:00
/**
* Purpose: agreements supports AuthView.vue by holding or executing the agreements page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const agreements = ref<LegalAgreement[]>([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: agreementModalOpen supports AuthView.vue by holding or executing the agreement modal open page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const agreementModalOpen = ref(false)
2026-05-23 18:44:57 +08:00
/**
* Purpose: selectedAgreement supports AuthView.vue by holding or executing the selected agreement page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const selectedAgreement = ref<LegalAgreement | null>(null)
2026-05-29 13:30:56 +08:00
const agreementContentHtml = computed(() => renderRichContent(selectedAgreement.value?.content || '暂无协议内容'))
2026-03-19 14:10:59 +08:00
2026-05-23 18:44:57 +08:00
/**
* Purpose: forgotPasswordForm supports AuthView.vue by holding or executing the forgot password form page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-19 14:10:59 +08:00
const forgotPasswordForm = reactive({
phone: '',
verificationCode: '',
newPassword: ''
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: formData supports AuthView.vue by holding or executing the form data page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-24 09:59:22 +08:00
const formData = reactive({
account: '',
password: '',
confirmPassword: '',
nickname: '',
shopId: undefined as string | undefined,
inviteCode: '',
phone: '',
verificationCode: '',
2026-02-24 09:59:22 +08:00
rememberMe: false
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: agreementVersions supports AuthView.vue by holding or executing the agreement versions page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const agreementVersions = computed<Record<string, string>>(() => {
return agreements.value.reduce((result, agreement) => {
result[agreement.agreementType] = agreement.version
return result
}, {} as Record<string, string>)
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: agreementPayload supports AuthView.vue by holding or executing the agreement payload page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const agreementPayload = () => ({
agreementAccepted: agreementAccepted.value,
agreementVersions: agreementVersions.value,
clientType: 'WEB'
})
let loginAccountCheckTimer: number | undefined
let loginPhoneShopCheckTimer: number | undefined
2026-05-23 18:44:57 +08:00
/**
* Purpose: phoneRegex supports AuthView.vue by holding or executing the phone regex page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const phoneRegex = /^1[3-9]\d{9}$/
2026-05-23 18:44:57 +08:00
/**
* Purpose: verificationCodeRegex supports AuthView.vue by holding or executing the verification code regex page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const verificationCodeRegex = /^\d{6}$/
2026-05-23 18:44:57 +08:00
/**
* Purpose: loginShopUnsupportedMessage supports AuthView.vue by holding or executing the login shop unsupported message page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const loginShopUnsupportedMessage = '可直接登录;如账号绑定多家门店,登录后可在个人中心切换当前门店。'
/** loginShopPlaceholder is a reactive state variable used by the template and event handlers. */
const loginShopPlaceholder = computed(() => {
if (loadingShops.value) {
return '正在加载可登录店铺'
}
if (loginShops.value.length) {
return allowLoginShopless.value ? '可选择本次登录店铺,留空直接登录' : '请选择登录店铺'
}
if (allowLoginShopless.value) {
return '当前无需选择店铺'
}
return '请先输入账号或手机号'
})
/** validateLoginShopRequired is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const validateLoginShopRequired = async () => {
if (allowLoginShopless.value || !loginShops.value.length || formData.shopId) {
return Promise.resolve()
}
return Promise.reject('请选择登录店铺')
}
/** validatePassword is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const validatePassword = async (_rule: Rule, value: string) => {
if (!value || value.length < 6) {
return Promise.reject('密码长度不能少于 6 位')
2026-02-24 09:59:22 +08:00
}
2026-03-19 14:10:59 +08:00
let count = 0
if (/\d/.test(value)) count++
if (/[a-z]/.test(value)) count++
if (/[A-Z]/.test(value)) count++
if (/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>/?]/.test(value)) count++
2026-03-19 14:10:59 +08:00
if (count < 3) {
return Promise.reject('密码需至少包含数字、小写字母、大写字母、符号中的 3 种')
2026-03-19 14:10:59 +08:00
}
2026-02-24 09:59:22 +08:00
return Promise.resolve()
}
/** validateConfirmPassword is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const validateConfirmPassword = async (_rule: Rule, value: string) => {
2026-02-24 09:59:22 +08:00
if (!value) {
return Promise.reject('请确认密码')
}
if (value !== formData.password) {
return Promise.reject('两次输入的密码不一致')
}
return Promise.resolve()
}
/** handleAccountInput is a local helper used by this page script. */
const handleAccountInput = () => {
const normalized = sanitizeAccountInput(formData.account)
if (normalized !== formData.account) {
formData.account = normalized
}
}
const registerRules: Record<string, Rule[]> = {
2026-02-24 09:59:22 +08:00
account: [
{ required: true, message: '请输入账号', trigger: 'blur' },
{ pattern: ACCOUNT_REGEX, message: ACCOUNT_RULE_MESSAGE, trigger: 'blur' }
2026-02-24 09:59:22 +08:00
],
phone: [
{ required: true, message: '请输入手机号', trigger: 'blur' },
{ pattern: phoneRegex, message: '手机号格式不正确', trigger: 'blur' }
],
verificationCode: [
{ required: true, message: '请输入验证码', trigger: 'blur' },
{ pattern: verificationCodeRegex, message: '验证码必须为 6 位数字', trigger: 'blur' }
],
2026-02-24 09:59:22 +08:00
password: [
{ required: true, message: '请输入密码', trigger: 'blur' },
{ validator: validatePassword, trigger: 'blur' }
],
confirmPassword: [
{ required: true, message: '请确认密码', trigger: 'blur' },
{ validator: validateConfirmPassword, trigger: 'blur' }
],
nickname: [
{ required: true, message: '请输入昵称', trigger: 'blur' },
{ min: 2, max: 20, message: '昵称长度需为 2 到 20 个字符', trigger: 'blur' },
2026-03-19 14:10:59 +08:00
{ pattern: /^[\u4e00-\u9fa5a-zA-Z0-9_]+$/, message: '昵称不能包含特殊符号', trigger: 'blur' }
2026-02-24 09:59:22 +08:00
],
shopId: [
{ required: true, message: '请选择店铺', trigger: 'change' }
]
}
const loginPasswordRules: Record<string, Rule[]> = {
account: [
{ required: true, message: '请输入账号', trigger: 'blur' },
{ pattern: ACCOUNT_REGEX, message: ACCOUNT_RULE_MESSAGE, trigger: 'blur' }
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' }
],
shopId: [
{ validator: validateLoginShopRequired, trigger: 'change' }
]
}
const loginPhoneRules: Record<string, Rule[]> = {
2026-03-19 14:10:59 +08:00
phone: [
{ required: true, message: '请输入手机号', trigger: 'blur' },
{ pattern: phoneRegex, message: '手机号格式不正确', trigger: 'blur' }
2026-03-19 14:10:59 +08:00
],
verificationCode: [
{ required: true, message: '请输入验证码', trigger: 'blur' },
{ pattern: verificationCodeRegex, message: '验证码必须为 6 位数字', trigger: 'blur' }
],
shopId: [
{ validator: validateLoginShopRequired, trigger: 'change' }
]
}
const forgotPasswordRules: Record<string, Rule[]> = {
phone: [
{ required: true, message: '请输入手机号', trigger: 'blur' },
{ pattern: phoneRegex, message: '手机号格式不正确', trigger: 'blur' }
],
verificationCode: [
{ required: true, message: '请输入验证码', trigger: 'blur' },
{ pattern: verificationCodeRegex, message: '验证码必须为 6 位数字', trigger: 'blur' }
2026-03-19 14:10:59 +08:00
],
newPassword: [
{ required: true, message: '请输入新密码', trigger: 'blur' }
]
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: currentRules supports AuthView.vue by holding or executing the current rules page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const currentRules = computed<Record<string, Rule[]>>(() => {
if (activeTab.value === 'register') {
return registerRules
}
return loginType.value === 'phone' ? loginPhoneRules : loginPasswordRules
})
/** fetchShops is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-02-24 09:59:22 +08:00
const fetchShops = async () => {
loadingShops.value = true
try {
const response = await shopApi.getShopsSimple()
2026-02-24 11:17:15 +08:00
shops.value = (response as unknown as any[]) || []
2026-02-24 09:59:22 +08:00
} catch (error) {
console.error('获取店铺列表失败:', error)
2026-03-19 20:51:07 +08:00
message.warning('店铺列表加载失败,普通登录不受影响')
2026-02-24 09:59:22 +08:00
} finally {
loadingShops.value = false
}
}
/** resetLoginAccountStatus is a local helper used by this page script. */
const resetLoginAccountStatus = () => {
if (loginAccountCheckTimer !== undefined) {
window.clearTimeout(loginAccountCheckTimer)
loginAccountCheckTimer = undefined
}
loginAccountStatus.value = null
}
/** resetPhoneLoginShopCheck is a local helper used by this page script. */
const resetPhoneLoginShopCheck = () => {
if (loginPhoneShopCheckTimer !== undefined) {
window.clearTimeout(loginPhoneShopCheckTimer)
loginPhoneShopCheckTimer = undefined
}
}
/** resetLoginShopState is a local helper used by this page script. */
const resetLoginShopState = (clearSelectedShop = activeTab.value === 'login') => {
resetPhoneLoginShopCheck()
loginShops.value = []
loginShopMessage.value = ''
allowLoginShopless.value = false
if (clearSelectedShop) {
formData.shopId = undefined
}
}
/** normalizeShopOptionValue is a local helper used by this page script. */
const normalizeShopOptionValue = (shopId?: string | number | null) => {
if (shopId === undefined || shopId === null || shopId === '') {
return undefined
}
return String(shopId)
}
/** isLoginShopPrefetchUnsupported is a local helper used by this page script. */
const isLoginShopPrefetchUnsupported = (error: unknown) => {
const status = (error as any)?.response?.status
return status === 404
}
/** applyLoginShopSelection is a local helper used by this page script. */
const applyLoginShopSelection = (selection?: LoginShopSelectionResponse | null) => {
loginShops.value = selection?.shops || []
allowLoginShopless.value = Boolean(selection?.allowShoplessLogin)
loginShopMessage.value = selection?.message || ''
if (!loginShops.value.length) {
formData.shopId = undefined
return
}
const currentShopId = normalizeShopOptionValue(formData.shopId)
const matchedShop = loginShops.value.find(shop => normalizeShopOptionValue(shop.id) === currentShopId)
if (matchedShop) {
formData.shopId = normalizeShopOptionValue(matchedShop.id)
return
}
if (!allowLoginShopless.value && loginShops.value.length === 1) {
const [onlyShop] = loginShops.value
if (onlyShop) {
formData.shopId = normalizeShopOptionValue(onlyShop.id)
return
}
}
formData.shopId = undefined
}
/** loadLoginShopsByAccount is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadLoginShopsByAccount = async (account = formData.account) => {
const trimmedAccount = account.trim()
if (activeTab.value !== 'login' || loginType.value !== 'password' || !trimmedAccount) {
resetLoginShopState()
return null
}
try {
const selection = await userApi.getLoginShopsByAccount(trimmedAccount) as unknown as LoginShopSelectionResponse
if (
activeTab.value === 'login'
&& loginType.value === 'password'
&& formData.account.trim() === trimmedAccount
) {
applyLoginShopSelection(selection)
}
return selection
} catch (error) {
if (formData.account.trim() === trimmedAccount) {
if (isLoginShopPrefetchUnsupported(error)) {
applyLoginShopSelection({
allowShoplessLogin: true,
...{ message: loginShopUnsupportedMessage },
shops: []
})
} else {
resetLoginShopState()
}
}
if (!isLoginShopPrefetchUnsupported(error)) {
console.error('登录店铺查询失败:', error)
}
return null
}
}
/** loadLoginShopsByPhone is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadLoginShopsByPhone = async (phone = formData.phone) => {
const trimmedPhone = phone.trim()
if (activeTab.value !== 'login' || loginType.value !== 'phone' || !phoneRegex.test(trimmedPhone)) {
resetLoginShopState()
return null
}
try {
const selection = await userApi.getLoginShopsByPhone(trimmedPhone) as unknown as LoginShopSelectionResponse
if (
activeTab.value === 'login'
&& loginType.value === 'phone'
&& formData.phone.trim() === trimmedPhone
) {
applyLoginShopSelection(selection)
}
return selection
} catch (error) {
if (formData.phone.trim() === trimmedPhone) {
if (isLoginShopPrefetchUnsupported(error)) {
applyLoginShopSelection({
allowShoplessLogin: true,
...{ message: loginShopUnsupportedMessage },
shops: []
})
} else {
resetLoginShopState()
}
}
if (!isLoginShopPrefetchUnsupported(error)) {
console.error('手机号登录店铺查询失败:', error)
}
return null
}
}
/** checkLoginAccountAvailability is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const checkLoginAccountAvailability = async (account = formData.account) => {
const trimmedAccount = account.trim()
if (activeTab.value !== 'login' || loginType.value !== 'password' || !trimmedAccount) {
loginAccountStatus.value = null
return null
}
try {
const response = await userApi.checkLoginAccountAvailability(trimmedAccount) as unknown as LoginAccountCheckResponse
if (
activeTab.value === 'login'
&& loginType.value === 'password'
&& formData.account.trim() === trimmedAccount
) {
loginAccountStatus.value = response
}
return response
} catch (error) {
if (formData.account.trim() === trimmedAccount) {
loginAccountStatus.value = null
}
console.error('登录账号检测失败:', error)
return null
}
}
/** checkRegisterAccountAvailability is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const checkRegisterAccountAvailability = async (showWarning = true) => {
const trimmedAccount = formData.account.trim()
if (activeTab.value !== 'register' || !trimmedAccount) {
registerAccountStatus.value = null
return false
}
const response = await userApi.checkAccountAvailability(trimmedAccount) as unknown as AvailabilityCheckResponse
registerAccountStatus.value = response
if (showWarning && !response.available) {
message.warning(response.message)
}
return response.available
}
/** checkRegisterPhoneAvailability is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const checkRegisterPhoneAvailability = async (showWarning = true) => {
const trimmedPhone = formData.phone.trim()
if (activeTab.value !== 'register' || !trimmedPhone) {
registerPhoneStatus.value = null
return false
}
const response = await userApi.checkPhoneAvailability(trimmedPhone) as unknown as AvailabilityCheckResponse
registerPhoneStatus.value = response
if (showWarning && !response.available) {
message.warning(response.message)
}
return response.available
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: loadAgreements supports AuthView.vue by holding or executing the load agreements page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const loadAgreements = async () => {
try {
agreements.value = await legalAgreementApi.listCurrent() as unknown as LegalAgreement[]
} catch (error) {
console.error('加载协议失败:', error)
message.warning('协议内容加载失败,请稍后重试')
}
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: openAgreement supports AuthView.vue by holding or executing the open agreement page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const openAgreement = async (type: 'USER_TERMS' | 'PRIVACY_POLICY') => {
const cached = agreements.value.find(item => item.agreementType === type)
if (cached) {
selectedAgreement.value = cached
agreementModalOpen.value = true
return
}
selectedAgreement.value = await legalAgreementApi.getCurrent(type) as unknown as LegalAgreement
agreementModalOpen.value = true
}
/** handleSubmit is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-02-24 09:59:22 +08:00
const handleSubmit = async () => {
if (!agreementAccepted.value) {
message.warning('请先阅读并同意用户协议和隐私政策')
return
}
if (!agreementVersions.value.USER_TERMS || !agreementVersions.value.PRIVACY_POLICY) {
message.warning('协议内容未加载完成,请稍后再试')
return
}
2026-02-24 09:59:22 +08:00
loading.value = true
try {
await runWithGlobalLoading(async () => {
if (activeTab.value === 'login') {
let response
if (loginType.value === 'phone') {
response = await authApi.phoneLogin({
phone: formData.phone,
verificationCode: formData.verificationCode,
shopId: formData.shopId,
...agreementPayload()
})
} else {
response = await authApi.login({
account: formData.account,
password: formData.password,
rememberMe: formData.rememberMe,
shopId: formData.shopId,
...agreementPayload()
})
}
const loginData = response as any
if (!loginData.accessToken || !loginData.refreshToken) {
console.error('登录响应缺少 token:', loginData)
message.error('登录失败:响应数据异常')
return
}
localStorage.setItem('accessToken', loginData.accessToken)
localStorage.setItem('refreshToken', loginData.refreshToken)
localStorage.setItem('userInfo', JSON.stringify(loginData.userInfo))
sessionStorage.setItem('accessToken', loginData.accessToken)
2026-05-23 15:16:40 +08:00
sessionStorage.setItem('refreshToken', loginData.refreshToken)
notifyShopThemeChanged()
if (loginData.needSetPassword) {
localStorage.setItem('needSetPassword', 'true')
} else {
localStorage.removeItem('needSetPassword')
}
message.success('登录成功')
router.push('/home').catch(err => {
console.error('跳转首页失败:', err)
window.location.href = '/home'
})
2026-03-19 20:51:07 +08:00
return
}
const accountAvailable = await checkRegisterAccountAvailability(false)
const phoneAvailable = await checkRegisterPhoneAvailability(false)
if (!accountAvailable || !phoneAvailable) {
message.error('请先处理注册信息中的占用问题')
return
}
await authApi.register({
account: formData.account,
password: formData.password,
nickname: formData.nickname,
phone: formData.phone,
verificationCode: formData.verificationCode,
shopId: formData.shopId!,
inviteCode: formData.inviteCode,
...agreementPayload()
2026-02-24 09:59:22 +08:00
})
message.success('注册成功,请登录')
activeTab.value = 'login'
loginType.value = 'password'
formData.password = ''
formData.confirmPassword = ''
formData.verificationCode = ''
resetLoginAccountStatus()
})
2026-02-24 09:59:22 +08:00
} catch (error: any) {
console.error(activeTab.value === 'login' ? '登录失败:' : '注册失败:', error)
2026-02-24 09:59:22 +08:00
message.error(error.message || (activeTab.value === 'login' ? '登录失败' : '注册失败'))
} finally {
loading.value = false
}
}
/** handleForgotPassword is a local helper used by this page script. */
2026-02-24 09:59:22 +08:00
const handleForgotPassword = () => {
2026-03-19 14:10:59 +08:00
forgotPasswordVisible.value = true
}
/** handleSendForgotCode is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-19 14:10:59 +08:00
const handleSendForgotCode = async () => {
if (!forgotPasswordForm.phone) {
message.error('请输入手机号')
return
}
if (!phoneRegex.test(forgotPasswordForm.phone)) {
message.error('手机号格式不正确')
return
}
try {
await runWithGlobalLoading(() => authApi.sendVerificationCode({
phone: forgotPasswordForm.phone,
sceneCode: 'USER_RESET_PASSWORD_SMS_CODE'
}))
2026-03-19 14:10:59 +08:00
message.success('验证码已发送')
forgotCountdown.value = 60
const timer = window.setInterval(() => {
2026-03-19 14:10:59 +08:00
forgotCountdown.value--
if (forgotCountdown.value <= 0) {
window.clearInterval(timer)
2026-03-19 14:10:59 +08:00
}
}, 1000)
} catch (error: any) {
message.error(error.response?.data?.message || '发送验证码失败')
}
}
/** handleResetPassword is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-19 14:10:59 +08:00
const handleResetPassword = async () => {
resettingPassword.value = true
try {
await runWithGlobalLoading(() => authApi.resetPasswordByPhone({
2026-03-19 14:10:59 +08:00
phone: forgotPasswordForm.phone,
verificationCode: forgotPasswordForm.verificationCode,
newPassword: forgotPasswordForm.newPassword
}))
2026-03-19 14:10:59 +08:00
message.success('密码重置成功,请使用新密码登录')
forgotPasswordVisible.value = false
forgotPasswordForm.phone = ''
forgotPasswordForm.verificationCode = ''
forgotPasswordForm.newPassword = ''
} catch (error: any) {
message.error(error.response?.data?.message || '重置密码失败')
} finally {
resettingPassword.value = false
}
2026-02-24 09:59:22 +08:00
}
/** handleRegisterAccountBlur is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-19 20:51:07 +08:00
const handleRegisterAccountBlur = async () => {
if (activeTab.value !== 'register' || !formData.account.trim()) {
registerAccountStatus.value = null
return
}
try {
await checkRegisterAccountAvailability(false)
} catch (error: any) {
registerAccountStatus.value = null
message.error(error.message || '账号校验失败')
}
}
/** handleRegisterPhoneBlur is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-19 20:51:07 +08:00
const handleRegisterPhoneBlur = async () => {
if (activeTab.value !== 'register' || !formData.phone.trim()) {
registerPhoneStatus.value = null
return
}
if (!phoneRegex.test(formData.phone)) {
registerPhoneStatus.value = null
return
}
try {
await checkRegisterPhoneAvailability(false)
} catch (error: any) {
registerPhoneStatus.value = null
message.error(error.message || '手机号校验失败')
}
}
/** handleSendVerificationCode is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleSendVerificationCode = async () => {
if (!formData.phone) {
message.error('请输入手机号')
return
}
2026-03-19 14:10:59 +08:00
if (!phoneRegex.test(formData.phone)) {
message.error('手机号格式不正确')
return
}
2026-03-19 20:51:07 +08:00
try {
2026-03-19 20:51:07 +08:00
if (activeTab.value === 'register') {
const phoneAvailable = await checkRegisterPhoneAvailability(false)
if (!phoneAvailable) {
message.warning(registerPhoneStatus.value?.message || '该手机号已被注册')
return
}
}
await runWithGlobalLoading(() => userApi.sendVerificationCode({
phone: formData.phone,
sceneCode: activeTab.value === 'register' ? 'USER_REGISTER_SMS_CODE' : 'USER_LOGIN_SMS_CODE'
}))
message.success('验证码已发送')
countdown.value = 60
const timer = window.setInterval(() => {
countdown.value--
if (countdown.value <= 0) {
window.clearInterval(timer)
}
}, 1000)
} catch (error: any) {
message.error(error.message || '发送验证码失败')
}
}
/** handleAdminLogin is a local helper used by this page script. */
const handleAdminLogin = () => {
localStorage.removeItem('accessToken')
localStorage.removeItem('refreshToken')
localStorage.removeItem('userInfo')
localStorage.removeItem('adminAccessToken')
localStorage.removeItem('adminRefreshToken')
localStorage.removeItem('adminUserInfo')
sessionStorage.removeItem('accessToken')
2026-05-23 15:16:40 +08:00
sessionStorage.removeItem('refreshToken')
sessionStorage.removeItem('adminAccessToken')
window.setTimeout(() => {
window.location.href = '/admin/login'
}, 100)
}
watch([activeTab, loginType], () => {
resetLoginAccountStatus()
resetLoginShopState(activeTab.value === 'login')
if (activeTab.value !== 'login') {
return
}
if (loginType.value === 'password' && formData.account.trim()) {
void Promise.all([
checkLoginAccountAvailability(formData.account.trim()),
loadLoginShopsByAccount(formData.account.trim())
])
return
}
if (loginType.value === 'phone' && phoneRegex.test(formData.phone.trim())) {
void loadLoginShopsByPhone(formData.phone.trim())
}
})
watch(
() => formData.account,
value => {
if (activeTab.value !== 'login' || loginType.value !== 'password') {
return
}
resetLoginAccountStatus()
const trimmedAccount = value.trim()
if (!trimmedAccount) {
return
}
loginAccountCheckTimer = window.setTimeout(() => {
loginAccountCheckTimer = undefined
void Promise.all([
checkLoginAccountAvailability(trimmedAccount),
loadLoginShopsByAccount(trimmedAccount)
])
}, 400)
}
)
watch(
() => formData.phone,
value => {
if (activeTab.value !== 'login' || loginType.value !== 'phone') {
return
}
resetPhoneLoginShopCheck()
const trimmedPhone = value.trim()
if (!phoneRegex.test(trimmedPhone)) {
resetLoginShopState()
return
}
loginPhoneShopCheckTimer = window.setTimeout(() => {
loginPhoneShopCheckTimer = undefined
void loadLoginShopsByPhone(trimmedPhone)
}, 400)
}
)
2026-02-24 09:59:22 +08:00
onMounted(() => {
fetchShops()
loadAgreements()
2026-02-24 09:59:22 +08:00
})
onBeforeUnmount(() => {
resetLoginAccountStatus()
resetPhoneLoginShopCheck()
})
2026-02-24 09:59:22 +08:00
</script>
<style scoped>
.mobile-container {
min-height: 100vh;
2026-05-29 13:30:56 +08:00
min-height: 100svh;
background:
linear-gradient(
180deg,
color-mix(in srgb, var(--theme-page-bg) 86%, transparent) 0%,
color-mix(in srgb, var(--theme-primary-soft) 72%, var(--theme-page-bg)) 48%,
var(--theme-page-bg) 100%
),
var(--theme-background-image),
var(--theme-gradient),
2026-05-29 13:30:56 +08:00
var(--theme-gradient-soft);
background-size: cover, cover, auto, auto;
2026-05-29 13:30:56 +08:00
background-position: center top;
color: var(--text-primary);
overflow-x: hidden;
padding: 24px 20px 28px;
}
2026-05-31 18:36:52 +08:00
.auth-topbar {
position: sticky;
top: 0;
z-index: 20;
display: grid;
grid-template-columns: 40px minmax(0, 1fr) 40px;
align-items: center;
2026-07-07 09:29:01 +08:00
width: min(100%, var(--frontend-page-max-width));
2026-05-31 18:36:52 +08:00
height: 44px;
margin: -10px auto 8px;
}
.auth-back-button {
display: inline-grid;
width: 36px;
height: 36px;
place-items: center;
border: 1px solid color-mix(in srgb, var(--theme-border) 78%, transparent);
border-radius: 999px;
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-card-bg) 86%, transparent);
box-shadow: 0 10px 24px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
cursor: pointer;
}
.auth-topbar strong {
overflow: hidden;
color: var(--text-primary);
font-size: 16px;
font-weight: 800;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
}
.auth-topbar-spacer {
width: 36px;
height: 36px;
}
2026-05-29 13:30:56 +08:00
.auth-page {
width: 100%;
2026-07-07 09:29:01 +08:00
max-width: var(--frontend-page-max-width);
2026-05-31 18:36:52 +08:00
min-height: calc(100svh - 104px);
2026-02-24 09:59:22 +08:00
display: flex;
2026-05-29 13:30:56 +08:00
flex-direction: column;
2026-02-24 09:59:22 +08:00
justify-content: center;
gap: 14px;
2026-05-29 13:30:56 +08:00
margin: 0 auto;
}
.brand-stage {
width: 100%;
text-align: center;
padding: 6px 10px 0;
2026-05-29 13:30:56 +08:00
}
.brand-name {
margin: 0;
color: var(--text-primary);
font-size: 24px;
font-weight: 800;
2026-05-29 13:30:56 +08:00
line-height: 1.2;
letter-spacing: 0;
}
.brand-copy {
max-width: 310px;
margin: 8px auto 0;
2026-05-29 13:30:56 +08:00
color: var(--text-secondary);
font-size: 13px;
line-height: 1.5;
2026-05-29 13:30:56 +08:00
letter-spacing: 0;
2026-02-24 09:59:22 +08:00
}
.auth-container {
width: 100%;
background: var(--theme-card-bg);
border: 1px solid var(--theme-border);
border-radius: 18px;
padding: 20px 18px 18px;
box-shadow: 0 12px 28px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
2026-02-24 09:59:22 +08:00
}
.logo-section {
text-align: center;
margin-bottom: 30px;
}
.logo {
font-size: 48px;
font-weight: bold;
2026-05-29 13:30:56 +08:00
color: var(--theme-primary);
2026-02-24 09:59:22 +08:00
margin-bottom: 10px;
}
.subtitle {
font-size: 16px;
2026-05-29 13:30:56 +08:00
color: var(--text-secondary);
2026-02-24 09:59:22 +08:00
}
.login-type-toggle {
2026-05-29 13:30:56 +08:00
margin-bottom: 18px;
}
.login-type-toggle :deep(.ant-radio-group) {
width: 100%;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
}
.login-type-toggle :deep(.ant-radio-button-wrapper) {
height: 40px;
display: inline-flex;
align-items: center;
justify-content: center;
border: 1px solid var(--theme-border);
border-radius: 999px;
background: color-mix(in srgb, var(--theme-card-bg) 82%, transparent);
color: var(--text-secondary);
font-size: 13px;
font-weight: 700;
line-height: 1.2;
letter-spacing: 0;
white-space: normal;
}
.login-type-toggle :deep(.ant-radio-button-wrapper::before) {
display: none;
}
.login-type-toggle :deep(.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled)) {
color: var(--theme-card-bg);
background: var(--theme-primary-action);
border-color: var(--theme-primary-action);
box-shadow: none;
}
2026-02-24 09:59:22 +08:00
.auth-form {
2026-05-29 13:30:56 +08:00
margin-top: 0;
}
.auth-form :deep(.ant-form-item) {
margin-bottom: 16px;
}
.auth-form :deep(.ant-form-item-label) {
padding-bottom: 7px;
}
.auth-form :deep(.ant-form-item-label > label) {
color: var(--text-secondary);
font-size: 13px;
font-weight: 700;
letter-spacing: 0;
}
.auth-form :deep(.ant-input),
.auth-form :deep(.ant-input-affix-wrapper),
.auth-form :deep(.ant-select-selector) {
min-height: 52px;
border-radius: 18px;
border-color: var(--theme-border);
background: color-mix(in srgb, var(--theme-card-bg) 88%, var(--theme-primary-soft));
color: var(--text-primary);
box-shadow: none;
transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.auth-form :deep(.ant-input),
.auth-form :deep(.ant-input-affix-wrapper) {
padding-inline: 15px;
}
.auth-form :deep(.ant-input-affix-wrapper > input.ant-input) {
min-height: auto;
background: transparent;
}
.auth-form :deep(.ant-input::placeholder),
.auth-form :deep(.ant-select-selection-placeholder) {
color: color-mix(in srgb, var(--text-secondary) 70%, transparent);
}
.auth-form :deep(.ant-input-affix-wrapper-focused),
.auth-form :deep(.ant-input:focus),
.auth-form :deep(.ant-select-focused .ant-select-selector) {
border-color: var(--theme-primary);
box-shadow: var(--theme-focus-shadow);
background: color-mix(in srgb, var(--theme-card-bg) 94%, var(--theme-primary-soft));
}
.auth-form :deep(.ant-select-selector) {
align-items: center;
padding: 0 15px;
}
.auth-form :deep(.ant-select-selection-item) {
color: var(--text-primary);
font-weight: 600;
}
.auth-form :deep(.ant-input-prefix) {
margin-right: 8px;
}
.auth-form :deep(.ant-input-suffix .ant-btn-link) {
height: 32px;
padding: 0 2px;
color: var(--theme-primary-action);
font-size: 12px;
font-weight: 700;
letter-spacing: 0;
}
.shop-select-item {
margin: 0 0 14px;
padding: 10px 12px;
border-radius: 16px;
2026-05-29 13:30:56 +08:00
border: 1px solid var(--theme-border);
background: color-mix(in srgb, var(--theme-card-bg) 92%, var(--theme-primary-soft));
2026-05-29 13:30:56 +08:00
}
.shop-select-item :deep(.ant-form-item-label > label) {
color: var(--theme-primary-action);
}
.shop-select-item :deep(.ant-form-item-control-input) {
min-height: auto;
2026-02-24 09:59:22 +08:00
}
.form-actions {
display: flex;
justify-content: space-between;
align-items: center;
2026-05-29 13:30:56 +08:00
gap: 12px;
font-size: 13px;
}
.form-actions :deep(.ant-checkbox-wrapper) {
color: var(--text-secondary);
2026-02-24 09:59:22 +08:00
}
2026-03-19 20:51:07 +08:00
.field-status {
2026-05-29 13:30:56 +08:00
margin-top: 9px;
2026-03-19 20:51:07 +08:00
font-size: 12px;
2026-05-29 13:30:56 +08:00
line-height: 1.5;
letter-spacing: 0;
2026-03-19 20:51:07 +08:00
}
.field-status.success {
2026-05-29 13:30:56 +08:00
color: var(--theme-secondary);
2026-03-19 20:51:07 +08:00
}
.field-status.error {
2026-05-29 13:30:56 +08:00
color: var(--theme-primary-action);
2026-03-19 20:51:07 +08:00
}
2026-02-24 09:59:22 +08:00
.forgot-password {
2026-05-29 13:30:56 +08:00
color: var(--theme-primary-action);
2026-02-24 09:59:22 +08:00
cursor: pointer;
2026-05-29 13:30:56 +08:00
font-weight: 700;
2026-02-24 09:59:22 +08:00
}
.social-login {
2026-05-29 13:30:56 +08:00
margin-top: 22px;
2026-02-24 09:59:22 +08:00
}
.divider {
text-align: center;
position: relative;
2026-05-29 13:30:56 +08:00
margin-bottom: 14px;
2026-02-24 09:59:22 +08:00
}
.divider::before {
content: '';
position: absolute;
left: 0;
top: 50%;
width: 100%;
height: 1px;
2026-05-29 13:30:56 +08:00
background: color-mix(in srgb, var(--theme-border) 78%, transparent);
2026-02-24 09:59:22 +08:00
}
.divider span {
2026-05-29 13:30:56 +08:00
background: color-mix(in srgb, var(--theme-card-bg) 94%, var(--theme-primary-soft));
padding: 0 12px;
color: var(--text-secondary);
font-size: 12px;
font-weight: 700;
line-height: 1.2;
letter-spacing: 0;
2026-02-24 09:59:22 +08:00
position: relative;
}
.social-buttons {
display: flex;
justify-content: center;
gap: 20px;
}
.social-hint {
2026-05-29 13:30:56 +08:00
margin-bottom: 12px;
font-size: 12px;
line-height: 1.6;
2026-05-29 13:30:56 +08:00
color: var(--text-secondary);
text-align: center;
}
2026-05-29 13:30:56 +08:00
.guest-entry {
width: 100%;
min-height: 44px;
border: 1px solid var(--theme-border);
border-radius: 999px;
background: color-mix(in srgb, var(--theme-card-bg) 76%, transparent);
color: var(--theme-primary-action);
font-size: 13px;
font-weight: 700;
letter-spacing: 0;
cursor: pointer;
transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.guest-entry:active {
transform: scale(0.98);
}
.social-circle-btn {
opacity: 0.72;
border-style: dashed;
}
.social-button-captions {
margin-top: 12px;
display: flex;
justify-content: center;
gap: 18px;
font-size: 12px;
2026-05-29 13:30:56 +08:00
color: var(--text-secondary);
}
2026-02-24 09:59:22 +08:00
.social-buttons .ant-btn {
2026-05-29 13:30:56 +08:00
border-color: var(--theme-border);
2026-02-24 09:59:22 +08:00
}
.social-buttons .ant-btn:hover {
2026-05-29 13:30:56 +08:00
border-color: var(--theme-primary);
color: var(--theme-primary);
2026-02-24 09:59:22 +08:00
}
.admin-login {
text-align: center;
2026-05-29 13:30:56 +08:00
margin-top: 18px;
padding-top: 17px;
border-top: 1px solid color-mix(in srgb, var(--theme-border) 80%, transparent);
}
.admin-login-link {
2026-05-29 13:30:56 +08:00
color: var(--text-secondary);
font-size: 12px;
font-weight: 700;
letter-spacing: 0;
cursor: pointer;
2026-05-29 13:30:56 +08:00
transition: color 0.2s ease;
}
.admin-login-link:hover {
2026-05-29 13:30:56 +08:00
color: var(--theme-primary-action);
text-decoration: underline;
}
.auth-mode-footer {
display: flex;
justify-content: center;
align-items: center;
gap: 6px;
margin-top: 14px;
color: var(--text-secondary);
font-size: 13px;
line-height: 1.5;
}
.auth-mode-link {
padding: 0;
border: 0;
background: transparent;
color: var(--theme-primary-action);
font-size: 13px;
font-weight: 700;
line-height: 1.5;
letter-spacing: 0;
cursor: pointer;
}
.auth-mode-link:hover {
text-decoration: underline;
}
.auth-mode-link--top {
display: inline-flex;
margin: 0 0 16px;
}
.phone-login-tip {
margin-top: 8px;
font-size: 12px;
2026-05-29 13:30:56 +08:00
color: var(--theme-primary-action);
display: flex;
align-items: center;
}
2026-05-29 13:30:56 +08:00
.primary-action {
min-height: 52px;
border: none;
border-radius: 999px;
background: var(--theme-primary-action);
2026-05-29 13:30:56 +08:00
color: var(--theme-card-bg);
font-size: 15px;
font-weight: 800;
letter-spacing: 0;
box-shadow: 0 10px 22px color-mix(in srgb, var(--theme-primary) 16%, transparent);
2026-05-29 13:30:56 +08:00
}
.primary-action:not(:disabled):hover,
.primary-action:not(:disabled):focus {
background: var(--theme-primary-action);
2026-05-29 13:30:56 +08:00
color: var(--theme-card-bg);
box-shadow: 0 10px 22px color-mix(in srgb, var(--theme-primary) 16%, transparent);
2026-05-29 13:30:56 +08:00
}
.primary-action:disabled {
color: color-mix(in srgb, var(--text-secondary) 56%, transparent);
background: color-mix(in srgb, var(--theme-border) 62%, var(--theme-card-bg));
box-shadow: none;
}
.auth-form :deep(.ant-checkbox-wrapper),
.auth-form :deep(a) {
font-size: 12px;
line-height: 1.6;
letter-spacing: 0;
}
.auth-form :deep(.ant-checkbox-wrapper) {
color: var(--text-secondary);
}
.auth-form :deep(a) {
color: var(--theme-primary-action);
font-weight: 700;
}
.auth-form :deep(.ant-checkbox-checked .ant-checkbox-inner) {
background-color: var(--theme-primary-action);
border-color: var(--theme-primary-action);
}
.auth-form :deep(.ant-checkbox-wrapper:hover .ant-checkbox-inner),
.auth-form :deep(.ant-checkbox:hover .ant-checkbox-inner) {
border-color: var(--theme-primary);
}
.agreement-content {
max-height: 60vh;
overflow: auto;
}
.agreement-version {
margin-bottom: 12px;
2026-05-29 13:30:56 +08:00
color: var(--text-secondary);
font-size: 13px;
}
2026-05-29 13:30:56 +08:00
.agreement-rich-content {
color: var(--text-primary);
line-height: 1.8;
overflow-wrap: break-word;
}
.agreement-rich-content :deep(*) {
max-width: 100%;
}
.agreement-rich-content :deep(p),
.agreement-rich-content :deep(ul),
.agreement-rich-content :deep(ol),
.agreement-rich-content :deep(blockquote),
.agreement-rich-content :deep(pre),
.agreement-rich-content :deep(table) {
margin: 0 0 12px;
}
.agreement-rich-content :deep(p:last-child),
.agreement-rich-content :deep(ul:last-child),
.agreement-rich-content :deep(ol:last-child),
.agreement-rich-content :deep(blockquote:last-child),
.agreement-rich-content :deep(pre:last-child),
.agreement-rich-content :deep(table:last-child) {
margin-bottom: 0;
}
.agreement-rich-content :deep(ul),
.agreement-rich-content :deep(ol) {
padding-left: 1.25em;
}
.agreement-rich-content :deep(a) {
color: var(--theme-primary);
}
.agreement-rich-content :deep(img) {
display: block;
max-width: 100%;
border-radius: 8px;
}
.agreement-rich-content :deep(pre) {
overflow-x: auto;
padding: 10px 12px;
border-radius: 8px;
background: var(--theme-primary-soft);
}
@media (max-width: 420px) {
.mobile-container {
padding: 18px 14px 24px;
}
.auth-page {
2026-05-31 18:36:52 +08:00
min-height: calc(100svh - 92px);
gap: 12px;
2026-05-29 13:30:56 +08:00
}
.brand-name {
font-size: 23px;
2026-05-29 13:30:56 +08:00
}
.brand-copy {
font-size: 13px;
}
.auth-container {
border-radius: 18px;
2026-05-29 13:30:56 +08:00
padding: 20px 16px 18px;
}
}
2026-03-19 20:51:07 +08:00
</style>