Initial commit: 商品售卖网站

This commit is contained in:
2026-04-13 07:20:09 +08:00
commit c6154273f2
865 changed files with 26573 additions and 0 deletions
+119
View File
@@ -0,0 +1,119 @@
<template>
<div class="auth-page">
<div class="auth-card">
<div class="auth-logo">
<div class="logo-icon">
<svg viewBox="0 0 24 24" fill="currentColor" width="24" height="24">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>
</svg>
</div>
<h2>{{ $t('auth.forgotPassword') }}</h2>
</div>
<el-form :model="form" :rules="rules" ref="formRef" @submit.prevent="handleSubmit">
<el-form-item :label="$t('auth.email')" prop="email">
<el-input v-model="form.email" type="email" />
</el-form-item>
<el-form-item>
<el-button type="primary" :loading="loading" native-type="submit" class="submit-btn">
{{ $t('auth.resetPassword') }}
</el-button>
</el-form-item>
</el-form>
<div class="auth-links">
<router-link to="/login">{{ $t('common.login') }}</router-link>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { authApi } from '../../api'
const formRef = ref()
const loading = ref(false)
const form = reactive({ email: '' })
const rules = {
email: [{ required: true, message: '请输入邮箱', trigger: 'blur' }],
}
async function handleSubmit() {
await formRef.value?.validate()
loading.value = true
try {
await authApi.forgotPassword(form)
ElMessage.success('如果邮箱存在,验证码已发送')
} finally {
loading.value = false
}
}
</script>
<style scoped lang="scss">
.auth-page {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.auth-card {
background: #2d2d44;
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 16px;
padding: 40px;
width: 100%;
max-width: 400px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.auth-logo {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 32px;
}
.logo-icon {
width: 48px;
height: 48px;
border-radius: 12px;
background: linear-gradient(135deg, #4e6ef2, #7c5cfc);
display: flex;
align-items: center;
justify-content: center;
color: #fff;
margin-bottom: 16px;
}
.auth-logo h2 {
font-size: 22px;
font-weight: 600;
color: #fff;
}
.submit-btn {
width: 100%;
height: 44px;
font-size: 15px;
font-weight: 600;
}
.auth-links {
display: flex;
justify-content: center;
margin-top: 20px;
font-size: 14px;
}
.auth-links a {
color: rgba(255, 255, 255, 0.5);
transition: color 0.15s;
}
.auth-links a:hover {
color: #4e6ef2;
}
</style>
+134
View File
@@ -0,0 +1,134 @@
<template>
<div class="auth-page">
<div class="auth-card">
<div class="auth-logo">
<div class="logo-icon">
<svg viewBox="0 0 24 24" fill="currentColor" width="24" height="24">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>
</svg>
</div>
<h2>{{ $t('common.login') }}</h2>
</div>
<el-form :model="form" :rules="rules" ref="formRef" @submit.prevent="handleLogin">
<el-form-item :label="$t('auth.email')" prop="email">
<el-input v-model="form.email" type="email" />
</el-form-item>
<el-form-item :label="$t('auth.password')" prop="password">
<el-input v-model="form.password" type="password" show-password />
</el-form-item>
<el-form-item>
<el-button type="primary" :loading="loading" native-type="submit" class="submit-btn">
{{ $t('common.login') }}
</el-button>
</el-form-item>
</el-form>
<div class="auth-links">
<router-link to="/forgot-password">{{ $t('auth.forgotPassword') }}</router-link>
<router-link to="/register">{{ $t('common.register') }}</router-link>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '../../store/user'
const router = useRouter()
const { t } = useI18n()
const userStore = useUserStore()
const formRef = ref()
const loading = ref(false)
const form = reactive({ email: '', password: '' })
const rules = {
email: [{ required: true, message: '请输入邮箱', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
}
async function handleLogin() {
await formRef.value?.validate()
loading.value = true
try {
await userStore.login(form)
ElMessage.success(t('auth.loginSuccess'))
const user = userStore.user
if (user?.role === 'admin') router.push('/admin')
else if (user?.role === 'supplier') router.push('/supplier')
else router.push('/')
} finally {
loading.value = false
}
}
</script>
<style scoped lang="scss">
.auth-page {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.auth-card {
background: #2d2d44;
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 16px;
padding: 40px;
width: 100%;
max-width: 400px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.auth-logo {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 32px;
}
.logo-icon {
width: 48px;
height: 48px;
border-radius: 12px;
background: linear-gradient(135deg, #4e6ef2, #7c5cfc);
display: flex;
align-items: center;
justify-content: center;
color: #fff;
margin-bottom: 16px;
}
.auth-logo h2 {
font-size: 22px;
font-weight: 600;
color: #fff;
}
.submit-btn {
width: 100%;
height: 44px;
font-size: 15px;
font-weight: 600;
}
.auth-links {
display: flex;
justify-content: space-between;
margin-top: 20px;
font-size: 14px;
}
.auth-links a {
color: rgba(255, 255, 255, 0.5);
transition: color 0.15s;
}
.auth-links a:hover {
color: #4e6ef2;
}
</style>
+137
View File
@@ -0,0 +1,137 @@
<template>
<div class="auth-page">
<div class="auth-card">
<div class="auth-logo">
<div class="logo-icon">
<svg viewBox="0 0 24 24" fill="currentColor" width="24" height="24">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>
</svg>
</div>
<h2>{{ $t('common.register') }}</h2>
</div>
<el-form :model="form" :rules="rules" ref="formRef" @submit.prevent="handleRegister">
<el-form-item :label="$t('auth.username')" prop="username">
<el-input v-model="form.username" />
</el-form-item>
<el-form-item :label="$t('auth.email')" prop="email">
<el-input v-model="form.email" type="email" />
</el-form-item>
<el-form-item :label="$t('auth.password')" prop="password">
<el-input v-model="form.password" type="password" show-password />
</el-form-item>
<el-form-item :label="$t('auth.inviteCode')">
<el-input v-model="form.invite_code" />
</el-form-item>
<el-form-item>
<el-button type="primary" :loading="loading" native-type="submit" class="submit-btn">
{{ $t('common.register') }}
</el-button>
</el-form-item>
</el-form>
<div class="auth-links">
<router-link to="/login">{{ $t('common.login') }}</router-link>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '../../store/user'
const router = useRouter()
const { t } = useI18n()
const userStore = useUserStore()
const formRef = ref()
const loading = ref(false)
const form = reactive({ username: '', email: '', password: '', invite_code: '' })
const rules = {
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
email: [{ required: true, message: '请输入邮箱', trigger: 'blur' }],
password: [{ required: true, min: 6, message: '密码至少6位', trigger: 'blur' }],
}
async function handleRegister() {
await formRef.value?.validate()
loading.value = true
try {
await userStore.register(form)
ElMessage.success(t('auth.registerSuccess'))
router.push('/')
} finally {
loading.value = false
}
}
</script>
<style scoped lang="scss">
.auth-page {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.auth-card {
background: #2d2d44;
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 16px;
padding: 40px;
width: 100%;
max-width: 400px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.auth-logo {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 32px;
}
.logo-icon {
width: 48px;
height: 48px;
border-radius: 12px;
background: linear-gradient(135deg, #4e6ef2, #7c5cfc);
display: flex;
align-items: center;
justify-content: center;
color: #fff;
margin-bottom: 16px;
}
.auth-logo h2 {
font-size: 22px;
font-weight: 600;
color: #fff;
}
.submit-btn {
width: 100%;
height: 44px;
font-size: 15px;
font-weight: 600;
}
.auth-links {
display: flex;
justify-content: center;
margin-top: 20px;
font-size: 14px;
}
.auth-links a {
color: rgba(255, 255, 255, 0.5);
transition: color 0.15s;
}
.auth-links a:hover {
color: #4e6ef2;
}
</style>