- Mock adapter implementing @vmall/shared ApiClient (localStorage-persisted cart/orders/invoices), runtime switch via mockApi flag (default on) - Fixed bilingual mock catalog: 3-level categories, 24 products w/ SKUs, stores, brands, banners, floors, seckill/collective/integral, comments, coupons, addresses, seeded orders/shipments/invoices - B2B2C mall shell: top bar, logo/search/cart header, dark nav + category mega-menu, value-prop footer, back-to-top; 1200px grid, #ca151e theme - UI primitives replacing element-plus: carousel, pagination, breadcrumb, qty stepper, rating stars, modal, tabs, step bar, product card - Pages: home floors, search (filters/sort/paging), goods detail (SKU picker, store rail, review tabs), cart -> checkout -> pay -> success, auth pages, user center (dashboard/orders/addresses/favorites/coupons/ invoices), stores, seckill, collective, integral - i18n split into per-domain locale modules (en+zh) - OpenSpec change mall-pc-storefront-replica archived; all specs green
239 lines
5.8 KiB
Vue
239 lines
5.8 KiB
Vue
<script setup lang="ts">
|
|
const { t } = useI18n();
|
|
const email = ref("");
|
|
const password = ref("");
|
|
const confirmPassword = ref("");
|
|
const code = ref("");
|
|
const errorKey = ref("");
|
|
const success = ref(false);
|
|
const submitting = ref(false);
|
|
const countdown = ref(0);
|
|
let timer: ReturnType<typeof setInterval> | undefined;
|
|
|
|
function startCountdown(): void {
|
|
if (countdown.value > 0) return;
|
|
countdown.value = 60;
|
|
timer = setInterval(() => {
|
|
countdown.value -= 1;
|
|
if (countdown.value <= 0 && timer) {
|
|
clearInterval(timer);
|
|
timer = undefined;
|
|
}
|
|
}, 1000);
|
|
}
|
|
|
|
onUnmounted(() => {
|
|
if (timer) clearInterval(timer);
|
|
});
|
|
|
|
function validate(): boolean {
|
|
if (!email.value || !password.value || !confirmPassword.value || !code.value) {
|
|
errorKey.value = "auth.validationRequired";
|
|
return false;
|
|
}
|
|
if (!/^\S+@\S+\.\S+$/.test(email.value)) {
|
|
errorKey.value = "auth.validationEmail";
|
|
return false;
|
|
}
|
|
if (password.value.length < 6) {
|
|
errorKey.value = "auth.validationPassword";
|
|
return false;
|
|
}
|
|
if (password.value !== confirmPassword.value) {
|
|
errorKey.value = "auth.validationMismatch";
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
async function submit(): Promise<void> {
|
|
errorKey.value = "";
|
|
if (!validate()) return;
|
|
submitting.value = true;
|
|
await new Promise<void>((resolve) => setTimeout(resolve, 180));
|
|
success.value = true;
|
|
submitting.value = false;
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<section class="auth-page">
|
|
<div class="auth-inner">
|
|
<div class="auth-panel">
|
|
<template v-if="success">
|
|
<div class="success-state">
|
|
<div class="success-mark">✓</div>
|
|
<h1>{{ t("auth.resetSuccess") }}</h1>
|
|
<p>{{ t("auth.resetSuccessHint") }}</p>
|
|
<NuxtLink class="mbtn red block" to="/login">{{ t("auth.loginNow") }}</NuxtLink>
|
|
</div>
|
|
</template>
|
|
<template v-else>
|
|
<div class="auth-tabs">
|
|
<h1>{{ t("auth.forgotTab") }}</h1>
|
|
<NuxtLink to="/login">{{ t("auth.loginTab") }}</NuxtLink>
|
|
</div>
|
|
<form @submit.prevent="submit">
|
|
<label class="field">
|
|
<span>{{ t("common.email") }}</span>
|
|
<input v-model.trim="email" class="minput" type="email" autocomplete="email" :placeholder="t('auth.emailPlaceholder')" />
|
|
</label>
|
|
<label class="field">
|
|
<span>{{ t("auth.newPassword") }}</span>
|
|
<input v-model="password" class="minput" type="password" autocomplete="new-password" :placeholder="t('auth.passwordPlaceholder')" />
|
|
</label>
|
|
<label class="field">
|
|
<span>{{ t("auth.confirmPassword") }}</span>
|
|
<input v-model="confirmPassword" class="minput" type="password" autocomplete="new-password" :placeholder="t('auth.confirmPasswordPlaceholder')" />
|
|
</label>
|
|
<label class="field">
|
|
<span>{{ t("auth.smsCode") }}</span>
|
|
<span class="code-row">
|
|
<input v-model.trim="code" class="minput" type="text" :placeholder="t('auth.smsCodePlaceholder')" />
|
|
<button class="mbtn code-button" type="button" :disabled="countdown > 0" @click="startCountdown">
|
|
{{ countdown > 0 ? t("auth.codeCountdown", { n: countdown }) : t("auth.getCode") }}
|
|
</button>
|
|
</span>
|
|
</label>
|
|
<p v-if="errorKey" class="error">{{ t(errorKey) }}</p>
|
|
<button class="mbtn red block submit" type="submit" :disabled="submitting">
|
|
{{ t("auth.resetAction") }}
|
|
</button>
|
|
</form>
|
|
<div class="auth-links">
|
|
<NuxtLink to="/login">{{ t("auth.loginNow") }}</NuxtLink>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.auth-page {
|
|
min-height: 720px;
|
|
background: #f6f6f6 url("/mock/login-bg.svg") center top / cover no-repeat;
|
|
padding: 50px 0;
|
|
box-sizing: border-box;
|
|
}
|
|
.auth-inner {
|
|
width: 1200px;
|
|
min-height: 540px;
|
|
margin: 0 auto;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
align-items: flex-start;
|
|
}
|
|
.auth-panel {
|
|
width: 400px;
|
|
min-height: 540px;
|
|
box-sizing: border-box;
|
|
padding: 40px;
|
|
background: #fff;
|
|
box-shadow: 0 4px 22px rgba(0, 0, 0, 0.08);
|
|
}
|
|
.auth-tabs {
|
|
display: flex;
|
|
align-items: baseline;
|
|
gap: 18px;
|
|
margin-bottom: 24px;
|
|
border-bottom: 1px solid var(--mall-line);
|
|
padding-bottom: 14px;
|
|
}
|
|
h1 {
|
|
margin: 0;
|
|
color: var(--mall-ink);
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
}
|
|
.auth-tabs a,
|
|
.auth-links a {
|
|
color: var(--mall-red);
|
|
font-size: 13px;
|
|
text-decoration: none;
|
|
}
|
|
.auth-tabs a:hover,
|
|
.auth-links a:hover {
|
|
color: var(--mall-red-dark);
|
|
}
|
|
.field {
|
|
display: block;
|
|
margin-bottom: 13px;
|
|
}
|
|
.field > span:first-child {
|
|
display: block;
|
|
margin-bottom: 6px;
|
|
color: var(--mall-muted);
|
|
font-size: 13px;
|
|
}
|
|
.code-row {
|
|
display: flex;
|
|
gap: 8px;
|
|
}
|
|
.code-row .minput {
|
|
min-width: 0;
|
|
flex: 1;
|
|
}
|
|
.code-button {
|
|
flex: 0 0 100px;
|
|
padding: 5px 8px;
|
|
white-space: nowrap;
|
|
}
|
|
.submit {
|
|
margin-top: 4px;
|
|
}
|
|
.error {
|
|
margin: -2px 0 10px;
|
|
color: var(--mall-red);
|
|
font-size: 12px;
|
|
}
|
|
.auth-links {
|
|
margin-top: 17px;
|
|
font-size: 12px;
|
|
text-align: center;
|
|
}
|
|
.success-state {
|
|
padding-top: 60px;
|
|
text-align: center;
|
|
}
|
|
.success-mark {
|
|
width: 54px;
|
|
height: 54px;
|
|
margin: 0 auto 18px;
|
|
border-radius: 50%;
|
|
background: var(--mall-green);
|
|
color: #fff;
|
|
font-size: 34px;
|
|
line-height: 54px;
|
|
}
|
|
.success-state h1 {
|
|
font-size: 20px;
|
|
}
|
|
.success-state p {
|
|
margin: 14px 0 28px;
|
|
color: var(--mall-muted);
|
|
font-size: 13px;
|
|
line-height: 1.6;
|
|
}
|
|
.success-state a {
|
|
text-decoration: none;
|
|
}
|
|
@media (max-width: 1240px) {
|
|
.auth-inner {
|
|
width: calc(100% - 40px);
|
|
}
|
|
}
|
|
@media (max-width: 640px) {
|
|
.auth-page {
|
|
padding: 20px;
|
|
}
|
|
.auth-inner {
|
|
width: 100%;
|
|
}
|
|
.auth-panel {
|
|
width: 100%;
|
|
padding: 30px 24px;
|
|
}
|
|
}
|
|
</style>
|