购物车和订单中心以及优惠券相关功能初版
This commit is contained in:
@@ -30,10 +30,10 @@
|
||||
layout="vertical"
|
||||
class="auth-form"
|
||||
>
|
||||
<a-form-item name="account" label="账号">
|
||||
<a-form-item v-if="activeTab === 'register'" name="nickname" label="昵称">
|
||||
<a-input
|
||||
v-model:value="formData.account"
|
||||
placeholder="请输入账号"
|
||||
v-model:value="formData.nickname"
|
||||
placeholder="请输入昵称"
|
||||
size="large"
|
||||
>
|
||||
<template #prefix>
|
||||
@@ -42,6 +42,27 @@
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="account" label="账号">
|
||||
<a-input
|
||||
v-model:value="formData.account"
|
||||
placeholder="请输入账号"
|
||||
size="large"
|
||||
@blur="handleAccountBlur"
|
||||
>
|
||||
<template #prefix>
|
||||
<UserOutlined style="color: #999" />
|
||||
</template>
|
||||
</a-input>
|
||||
<div v-if="accountStatus" class="account-status">
|
||||
<span v-if="accountStatus.exists" class="status-success">
|
||||
账号存在,昵称:{{ accountStatus.nickname }}
|
||||
</span>
|
||||
<span v-else class="status-error">
|
||||
账号不存在
|
||||
</span>
|
||||
</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="password" label="密码">
|
||||
<a-input-password
|
||||
v-model:value="formData.password"
|
||||
@@ -90,18 +111,6 @@
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item v-if="activeTab === 'register'" name="nickname" label="昵称">
|
||||
<a-input
|
||||
v-model:value="formData.nickname"
|
||||
placeholder="请输入昵称"
|
||||
size="large"
|
||||
>
|
||||
<template #prefix>
|
||||
<UserOutlined style="color: #999" />
|
||||
</template>
|
||||
</a-input>
|
||||
</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>
|
||||
@@ -150,6 +159,7 @@ import { UserOutlined, LockOutlined, WechatOutlined, QqOutlined } from '@ant-des
|
||||
import { message } from 'ant-design-vue'
|
||||
import { authApi } from '@/api/auth'
|
||||
import { shopApi } from '@/api/shop'
|
||||
import { userApi } from '@/api/user'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -157,6 +167,7 @@ const activeTab = ref<'login' | 'register'>('login')
|
||||
const loading = ref(false)
|
||||
const loadingShops = ref(false)
|
||||
const shops = ref<any[]>([])
|
||||
const accountStatus = ref<any>(null)
|
||||
|
||||
const formData = reactive({
|
||||
account: '',
|
||||
@@ -187,7 +198,8 @@ const validateConfirmPassword = async (_rule: any, value: string) => {
|
||||
const rules = {
|
||||
account: [
|
||||
{ required: true, message: '请输入账号', trigger: 'blur' },
|
||||
{ min: 3, max: 50, message: '账号长度在3到50个字符', trigger: 'blur' }
|
||||
{ min: 3, max: 50, message: '账号长度在3到50个字符', trigger: 'blur' },
|
||||
{ pattern: /^[a-zA-Z0-9_\-@.]+$/, message: '账号只能包含数字、字母、下划线、连字符、@和点号', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
@@ -267,6 +279,28 @@ const handleQQLogin = () => {
|
||||
message.info('QQ登录功能开发中')
|
||||
}
|
||||
|
||||
const handleAccountBlur = async () => {
|
||||
if (activeTab.value === 'login' && formData.account) {
|
||||
try {
|
||||
const res = await userApi.getUserByAccount(formData.account)
|
||||
if (res) {
|
||||
accountStatus.value = {
|
||||
exists: true,
|
||||
nickname: res.nickname
|
||||
}
|
||||
} else {
|
||||
accountStatus.value = {
|
||||
exists: false
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
accountStatus.value = {
|
||||
exists: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const handleAdminLogin = () => {
|
||||
console.log('跳转到管理后台登录')
|
||||
localStorage.removeItem('accessToken')
|
||||
@@ -432,4 +466,17 @@ onMounted(() => {
|
||||
color: #764ba2;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.account-status {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.status-success {
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.status-error {
|
||||
color: #f5222d;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user