合并代码

This commit is contained in:
szz
2025-07-31 13:54:37 +08:00
parent 97a53c200e
commit 7d94b0ddae
21 changed files with 479 additions and 688 deletions

View File

@@ -1,3 +1,3 @@
# 生产环境配置
VITE_API_BASE_URL=https://www.zrbjr.com/api
VITE_UPLOAD_BASE_URL=https://www.zrbjr.com/api/upload
VITE_API_BASE_URL=http://114.55.111.44:3001/api
VITE_UPLOAD_BASE_URL=http://114.55.111.44:3001/api/upload

8
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

10
.idea/UniappTool.xml generated Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="cn.fjdmy.uniapp.UniappProjectDataService">
<option name="generalBasePath" value="$PROJECT_DIR$" />
<option name="manifestPath" value="$PROJECT_DIR$/manifest.json" />
<option name="pagesPath" value="$PROJECT_DIR$/pages.json" />
<option name="scanNum" value="1" />
<option name="type" value="store" />
</component>
</project>

12
.idea/frontend.iml generated Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/frontend.iml" filepath="$PROJECT_DIR$/.idea/frontend.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
<title>易融宝</title>
<title>炬融圈</title>
<style>
* {
margin: 0;

51
package-lock.json generated
View File

@@ -13,7 +13,9 @@
"element-plus": "^2.4.4",
"nprogress": "^0.2.0",
"pinia": "^2.1.7",
"swiper": "^8.4.7",
"vue": "^3.3.11",
"vue-awesome-swiper": "^5.0.1",
"vue-router": "^4.2.5"
},
"devDependencies": {
@@ -1428,6 +1430,15 @@
"node": ">=0.10"
}
},
"node_modules/dom7": {
"version": "4.0.6",
"resolved": "https://registry.npmmirror.com/dom7/-/dom7-4.0.6.tgz",
"integrity": "sha512-emjdpPLhpNubapLFdjNL9tP06Sr+GZkrIHEXLWvOGsytACUrkbeIdjO5g77m00BrHTznnlcNqgmn7pCN192TBA==",
"license": "MIT",
"dependencies": {
"ssr-window": "^4.0.0"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
@@ -2395,6 +2406,12 @@
"node": ">=0.10.0"
}
},
"node_modules/ssr-window": {
"version": "4.0.2",
"resolved": "https://registry.npmmirror.com/ssr-window/-/ssr-window-4.0.2.tgz",
"integrity": "sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ==",
"license": "MIT"
},
"node_modules/supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
@@ -2411,6 +2428,30 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/swiper": {
"version": "8.4.7",
"resolved": "https://registry.npmmirror.com/swiper/-/swiper-8.4.7.tgz",
"integrity": "sha512-VwO/KU3i9IV2Sf+W2NqyzwWob4yX9Qdedq6vBtS0rFqJ6Fa5iLUJwxQkuD4I38w0WDJwmFl8ojkdcRFPHWD+2g==",
"funding": [
{
"type": "patreon",
"url": "https://www.patreon.com/swiperjs"
},
{
"type": "open_collective",
"url": "http://opencollective.com/swiper"
}
],
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
"dom7": "^4.0.4",
"ssr-window": "^4.0.2"
},
"engines": {
"node": ">= 4.7.0"
}
},
"node_modules/sync-child-process": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/sync-child-process/-/sync-child-process-1.0.2.tgz",
@@ -2543,6 +2584,16 @@
}
}
},
"node_modules/vue-awesome-swiper": {
"version": "5.0.1",
"resolved": "https://registry.npmmirror.com/vue-awesome-swiper/-/vue-awesome-swiper-5.0.1.tgz",
"integrity": "sha512-mWjFJzUqA4lG+DmsmibvMpoiBnl+IH2SSeiiQ3i5M0t1y9FknTxnGT0DsMb2YdJLgjYMEK3sYOWzqgLnZMH8Lg==",
"license": "MIT",
"peerDependencies": {
"swiper": "^7.0.0 || ^8.0.0",
"vue": "3.x"
}
},
"node_modules/vue-demi": {
"version": "0.14.10",
"resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",

View File

@@ -14,7 +14,9 @@
"element-plus": "^2.4.4",
"nprogress": "^0.2.0",
"pinia": "^2.1.7",
"swiper": "^8.4.7",
"vue": "^3.3.11",
"vue-awesome-swiper": "^5.0.1",
"vue-router": "^4.2.5"
},
"devDependencies": {

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -22,7 +22,11 @@ const routesWithBottomNav = [
'/points-history',
'/profile',
'/shop',
'/orders'
'/orders',
'/mainpage',
'/myprofile',
'/mymatching',
'/myshop'
]
// 计算是否显示底部导航

View File

@@ -1,5 +1,37 @@
<template>
<div class="bottom-nav">
<div
class="nav-item"
:class="{ active: isActive('/mainpage') }"
@click="handleNavClick('/mainpage')"
>
<HomeFilled class="nav-icon" />
<span class="nav-label">主页</span>
</div>
<div
class="nav-item"
:class="{ active: isActive('/mymatching') }"
@click="handleNavClick('/mymatching')"
>
<User class="nav-icon" />
<span class="nav-label">资金匹配</span>
</div>
<div
class="nav-item"
:class="{ active: isActive('/myshop') }"
@click="handleNavClick('/myshop')"
>
<User class="nav-icon" />
<span class="nav-label">积分商城</span>
</div>
<div
class="nav-item"
:class="{ active: isActive('/myprofile') }"
@click="handleNavClick('/myprofile')"
>
<User class="nav-icon" />
<span class="nav-label">个人中心</span>
</div>
<div
class="nav-item"
:class="{ active: isActive('/transfers') }"
@@ -8,7 +40,7 @@
<Money class="nav-icon" />
<span class="nav-label">转账管理</span>
</div>
<div
<!-- <div
class="nav-item"
:class="{ active: isActive('/matching') }"
@click="handleNavClick('/matching')"
@@ -31,14 +63,14 @@
>
<User class="nav-icon" />
<span class="nav-label">个人中心</span>
</div>
</div> -->
</div>
</template>
<script setup>
import { useRouter, useRoute } from 'vue-router'
import { useUserStore } from '@/stores/user'
import { Money, Coin, User, Connection } from '@element-plus/icons-vue'
import { Money, Coin, User, Connection, HomeFilled } from '@element-plus/icons-vue'
const router = useRouter()
const route = useRoute()
@@ -50,7 +82,7 @@ const isActive = (path) => {
const handleNavClick = (path) => {
if (!userStore.isAuthenticated) {
router.push('/login')
router.push('/mylogin')
return
}
router.push(path)

View File

@@ -11,6 +11,75 @@ const routes = [
title: '首页'
}
},
{
path: '/mylogin',
name: 'MyLogin',
component: () => import('@/views/MyLogin.vue'),
meta: {
title: '登录',
hideForAuth: true
}
},
{
path: '/mainpage',
name: 'MainPage',
component: () => import('@/views/MainPage.vue'),
meta: {
title: '主页'
}
},
{
path: '/mymatching',
name: 'MyMatching',
component: () => import('@/views/MyMatching.vue'),
meta: {
title: '资金匹配',
requiresAuth: true
}
},
{
path: '/myshop',
name: 'MyShop',
component: () => import('@/views/MyShop.vue'),
meta: {
title: '积分商城'
}
},
{
path: '/myprofile',
name: 'MyProfile',
component: () => import('@/views/MyProfile.vue'),
meta: {
title: '个人中心'
}
},
{
path: '/mypoints-history',
name: 'MyPointsHistory',
component: () => import('@/views/MyPointsHistory.vue'),
meta: {
title: '积分记录',
requiresAuth: true
}
},
{
path: '/editdetailspage',
name: 'EditDetailsPage',
component: () => import('@/views/EditDetailsPage.vue'),
meta: {
title: '编辑信息',
requiresAuth: true
}
},
{
path: '/editpasswordpage',
name: 'EditPasswordPage',
component: () => import('@/views/EditPasswordPage.vue'),
meta: {
title: '编辑密码',
requiresAuth: true
}
},
{
path: '/home',
name: 'HomePage',
@@ -108,6 +177,22 @@ const routes = [
requiresAuth: true
}
},
{
path: '/agent/login',
name: 'AgentLogin',
component: () => import('@/views/AgentLogin.vue'),
meta: {
title: '代理登录'
}
},
{
path: '/agent/dashboard',
name: 'AgentDashboard',
component: () => import('@/views/AgentDashboard.vue'),
meta: {
title: '代理后台'
}
},
{
path: '/about',
name: 'About',
@@ -146,7 +231,7 @@ router.beforeEach(async (to, from, next) => {
// 设置页面标题
if (to.meta.title) {
document.title = `${to.meta.title} - 易融宝`
document.title = `${to.meta.title} - 炬融圈`
}
// 检查是否需要认证
@@ -157,7 +242,7 @@ router.beforeEach(async (to, from, next) => {
if (!userStore.isAuthenticated) {
next({
name: 'Login',
name: 'MyLogin',
query: { redirect: to.fullPath }
})
return
@@ -165,9 +250,9 @@ router.beforeEach(async (to, from, next) => {
}
}
// 如果已登录用户访问登录/注册页面,重定向到转账管理
// 如果已登录用户访问登录/注册页面,重定向到转账管理(改成了主页)
if (to.meta.hideForAuth && userStore.isAuthenticated) {
next({ name: 'Transfers' })
next({ name: 'MainPage' })
return
}

View File

@@ -4,7 +4,7 @@
<div class="login-card">
<div class="login-header">
<h2>用户登录</h2>
<p>欢迎回到前端H5系统</p>
<p>欢迎回到炬融圈</p>
</div>
<el-form
@@ -76,6 +76,21 @@
</el-link>
</p>
</div>
<!-- 备案信息 -->
<div class="icp-info">
<div class="icp-item">
<svg class="icp-icon" viewBox="0 0 1024 1024" width="16" height="16">
<path d="M512 85.333333c-23.466667 0-42.666667 19.2-42.666667 42.666667v85.333333c0 23.466667 19.2 42.666667 42.666667 42.666667s42.666667-19.2 42.666667-42.666667V128c0-23.466667-19.2-42.666667-42.666667-42.666667z" fill="#909399"/>
<path d="M512 256c-141.226667 0-256 114.773333-256 256 0 70.613333 28.586667 134.4 74.666667 180.48L512 874.666667l181.333333-182.186667C739.413333 646.4 768 582.613333 768 512c0-141.226667-114.773333-256-256-256z m0 341.333333c-47.146667 0-85.333333-38.186667-85.333333-85.333333s38.186667-85.333333 85.333333-85.333333 85.333333 38.186667 85.333333 85.333333-38.186667 85.333333-85.333333 85.333333z" fill="#909399"/>
<path d="M170.666667 298.666667c-11.733333-20.48-37.546667-27.306667-58.026667-15.573334-20.48 11.733333-27.306667 37.546667-15.573333 58.026667l42.666666 74.24c11.733333 20.48 37.546667 27.306667 58.026667 15.573333 20.48-11.733333 27.306667-37.546667 15.573333-58.026666l-42.666666-74.24z" fill="#909399"/>
<path d="M853.333333 298.666667l-42.666666 74.24c-11.733333 20.48-4.906667 46.293333 15.573333 58.026666 20.48 11.733333 46.293333 4.906667 58.026667-15.573333l42.666666-74.24c11.733333-20.48 4.906667-46.293333-15.573333-58.026667-20.48-11.733333-46.293333-4.906667-58.026667 15.573334z" fill="#909399"/>
</svg>
<a href="https://beian.miit.gov.cn/" target="_blank" class="icp-link">
浙ICP备2025186895号
</a>
</div>
</div>
</div>
</div>
@@ -286,6 +301,36 @@ const handleRememberMe = () => {
font-size: 14px;
}
.icp-info {
text-align: center;
margin-top: 20px;
padding-top: 15px;
border-top: 1px solid rgba(224, 224, 230, 0.3);
}
.icp-item {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
}
.icp-icon {
flex-shrink: 0;
}
.icp-link {
color: #909399;
font-size: 12px;
text-decoration: none;
transition: color 0.3s ease;
}
.icp-link:hover {
color: #409eff;
text-decoration: underline;
}
.quick-login {
margin-top: 20px;
}
@@ -365,6 +410,15 @@ const handleRememberMe = () => {
gap: 10px;
align-items: flex-start;
}
.icp-info {
margin-top: 15px;
padding-top: 10px;
}
.icp-link {
font-size: 11px;
}
}
/* Element Plus 组件样式覆盖 */

View File

@@ -133,7 +133,7 @@
<span class="cycle">{{ allocation.cycle_number }}</span>
</div>
<div class="allocation-details">
<p>转账给: <strong>{{ allocation.to_user_name }}</strong></p>
<p>转账给: <strong>{{ allocation.to_user_real_name }}</strong></p>
<p>金额: <strong class="amount">¥{{ allocation.amount }}</strong></p>
<p>总金额: ¥{{ allocation.total_amount }}</p>
<p class="deadline-info">
@@ -158,13 +158,6 @@
>
{{ allocation.can_transfer ? '确认转账' : '无法转账' }}
</button>
<button
@click="rejectAllocation(allocation.id)"
class="reject-btn"
:disabled="processing"
>
拒绝
</button>
</div>
</div>
</div>
@@ -443,8 +436,32 @@ export default {
* 创建匹配订单
*/
async createOrder() {
this.creating = true
try {
// 构建确认信息
let confirmMessage = ''
if (this.matchingType === 'small') {
confirmMessage = '确定要开始小额匹配吗?\n\n匹配成功后将生成3笔转账分配。'
} else {
if (!this.isValidCustomAmount) {
this.$message.error('请输入有效的匹配金额5000-50000元')
return
}
const amount = parseFloat(this.customAmount)
const count = this.getLargeMatchingCount()
confirmMessage = `确定要开始大额匹配吗?\n\n匹配金额${amount}\n将生成${count}笔转账分配`
}
// 二次确认对话框
await this.$confirm(confirmMessage, '确认匹配', {
confirmButtonText: '确认匹配',
cancelButtonText: '取消',
type: 'warning',
dangerouslyUseHTMLString: false
})
this.creating = true
// 构建请求参数
const requestData = {
matchingType: this.matchingType
@@ -452,10 +469,6 @@ export default {
// 如果是大额匹配,添加自定义金额
if (this.matchingType === 'large') {
if (!this.isValidCustomAmount) {
this.$message.error('请输入有效的匹配金额5000-50000元')
return
}
requestData.customAmount = parseFloat(this.customAmount)
}
@@ -468,6 +481,11 @@ export default {
this.$message.success(successMessage)
await this.loadData()
} catch (error) {
// 如果用户取消确认,不显示错误信息
if (error === 'cancel') {
return
}
console.error('创建匹配订单失败:', error)
const errorMessage = error.response?.data?.message || '匹配失败,请稍后重试'
@@ -527,32 +545,7 @@ export default {
}
},
/**
* 拒绝分配
* @param {string} allocationId - 分配ID
*/
async rejectAllocation(allocationId) {
const reason = prompt('请输入拒绝原因(可选):')
// 用户点击取消时prompt返回null此时不执行后续操作
if (reason === null) {
return
}
this.processing = true
try {
await api.post(`/matching/reject-allocation/${allocationId}`, {
reason
})
this.$message.success('已拒绝分配')
await this.loadData()
} catch (error) {
console.error('拒绝分配失败:', error)
this.$message.error('拒绝分配失败')
} finally {
this.processing = false
}
},
async viewOrderDetail(orderId) {
try {
@@ -577,7 +570,6 @@ export default {
completed: '已完成',
cancelled: '已取消',
confirmed: '已确认',
rejected: '已拒绝',
failed: '匹配失败'
}
return statusMap[status] || status
@@ -587,7 +579,6 @@ export default {
const actionMap = {
join: '加入',
confirm: '确认',
reject: '拒绝',
complete: '完成'
}
return actionMap[action] || action
@@ -1062,8 +1053,7 @@ export default {
gap: 10px;
}
.confirm-btn,
.reject-btn {
.confirm-btn {
padding: 8px 16px;
border: none;
border-radius: 5px;
@@ -1080,14 +1070,7 @@ export default {
background: #229954;
}
.reject-btn {
background: #e74c3c;
color: white;
}
.reject-btn:hover {
background: #c0392b;
}
.order-card {
padding: 15px;

View File

@@ -43,6 +43,7 @@
</div>
<div class="user-info">
<h2 class="username">{{ userInfo?.username }}</h2>
<p class="user-email">{{ userInfo?.email }}</p>
<!-- 审核状态显示 -->
<div class="audit-status">
@@ -91,7 +92,9 @@
<el-input v-model="form.nickname" placeholder="请输入昵称" />
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model="form.email" placeholder="请输入邮箱" />
</el-form-item>
<el-form-item label="真实姓名" prop="realName">
<el-input v-model="form.realName" placeholder="请输入真实姓名" />
@@ -358,7 +361,7 @@ const userInfo = ref({
id: '',
username: '',
nickname: '',
email: '',
phone: '',
realName: '',
idCard: '',
@@ -378,7 +381,7 @@ const userStats = ref({
const form = reactive({
username: '',
nickname: '',
email: '',
phone: '',
realName: '',
idCard: '',
@@ -414,7 +417,10 @@ const rules = {
{ required: true, message: '请输入用户名', trigger: 'blur' },
{ min: 3, max: 20, message: '用户名长度在 3 到 20 个字符', trigger: 'blur' }
],
email: [
{ required: true, message: '请输入邮箱', trigger: 'blur' },
{ type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' }
],
realName: [
{ required: true, message: '请输入真实姓名', trigger: 'blur' },
{ min: 2, max: 10, message: '真实姓名长度在 2 到 10 个字符', trigger: 'blur' }
@@ -937,7 +943,11 @@ onMounted(() => {
font-weight: 600;
}
.user-email {
margin: 0 0 10px 0;
color: rgba(255, 255, 255, 0.8);
font-size: 14px;
}
.audit-status {
margin-bottom: 20px;

View File

@@ -34,8 +34,7 @@
/>
</el-form-item>
<!-- 短信验证码组件 - 已注释 -->
<!-- <el-form-item prop="smsCode">
<el-form-item prop="smsCode">
<div class="sms-code-group">
<el-input
v-model="registerForm.smsCode"
@@ -56,7 +55,7 @@
{{ smsCountdown > 0 ? `${smsCountdown}s后重发` : '发送验证码' }}
</el-button>
</div>
</el-form-item> -->
</el-form-item>
<el-form-item prop="registrationCode">
<el-input
@@ -132,7 +131,7 @@
<div class="register-footer">
<p>
已有账号
<el-link type="primary" @click="$router.push('/login')">
<el-link type="primary" @click="$router.push('/mylogin')">
立即登录
</el-link>
</p>
@@ -192,17 +191,17 @@ const registerForm = reactive({
password: '',
confirmPassword: '',
captcha: '',
// smsCode: '', // 短信验证码字段 - 已注释
smsCode: '',
agreement: false
})
// 短信验证码相关状态 - 已注释
// const sendingSMS = ref(false)
// const smsCountdown = ref(0)
// const canSendSMS = computed(() => {
// const phoneRegex = /^1[3-9]\d{9}$/
// return phoneRegex.test(registerForm.phone)
// })
// 短信验证码相关状态
const sendingSMS = ref(false)
const smsCountdown = ref(0)
const canSendSMS = computed(() => {
const phoneRegex = /^1[3-9]\d{9}$/
return phoneRegex.test(registerForm.phone)
})
// 自定义验证函数
const validateUsername = (rule, value, callback) => {
@@ -264,14 +263,12 @@ const registerRules = {
],
registrationCode: [
{ required: true, message: '请输入激活码', trigger: 'blur' },
{ len: 6, message: '激活码长度6位', trigger: 'blur' },
{ pattern: /^[A-Z0-9]{6}$/, message: '激活码只能包含大写字母和数字', trigger: 'blur' }
{ min: 6, message: '激活码长度不能少于6位', trigger: 'blur' }
],
smsCode: [
{ required: true, message: '请输入短信验证码', trigger: 'blur' },
{ pattern: /^\d{6}$/, message: '短信验证码为6位数字', trigger: 'blur' }
],
// 短信验证码验证规则 - 已注释
// smsCode: [
// { required: true, message: '请输入短信验证码', trigger: 'blur' },
// { pattern: /^\d{6}$/, message: '短信验证码为6位数字', trigger: 'blur' }
// ],
password: [{ validator: validatePassword, trigger: 'blur' }],
confirmPassword: [{ validator: validateConfirmPassword, trigger: 'blur' }],
@@ -282,52 +279,52 @@ const registerRules = {
agreement: [{ validator: validateAgreement, trigger: 'change' }]
}
// 发送短信验证码 - 已注释
// const sendSMSCode = async () => {
// if (!canSendSMS.value || sendingSMS.value || smsCountdown.value > 0) {
// return
// }
//
// try {
// sendingSMS.value = true
//
// const response = await fetch('/api/sms/send', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// },
// body: JSON.stringify({
// phone: registerForm.phone
// })
// })
//
// const result = await response.json()
//
// if (result.success) {
// ElMessage.success('验证码发送成功,请查收短信')
// // 开始倒计时
// startCountdown()
// } else {
// ElMessage.error(result.message || '发送失败,请重试')
// }
// } catch (error) {
// console.error('发送短信验证码失败:', error)
// ElMessage.error('发送失败,请检查网络连接')
// } finally {
// sendingSMS.value = false
// }
// }
// 发送短信验证码
const sendSMSCode = async () => {
if (!canSendSMS.value || sendingSMS.value || smsCountdown.value > 0) {
return
}
try {
sendingSMS.value = true
const response = await fetch('/api/sms/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
phone: registerForm.phone
})
})
const result = await response.json()
if (result.success) {
ElMessage.success('验证码发送成功,请查收短信')
// 开始倒计时
startCountdown()
} else {
ElMessage.error(result.message || '发送失败,请重试')
}
} catch (error) {
console.error('发送短信验证码失败:', error)
ElMessage.error('发送失败,请检查网络连接')
} finally {
sendingSMS.value = false
}
}
// 开始倒计时 - 已注释
// const startCountdown = () => {
// smsCountdown.value = 60
// const timer = setInterval(() => {
// smsCountdown.value--
// if (smsCountdown.value <= 0) {
// clearInterval(timer)
// }
// }, 1000)
// }
// 开始倒计时
const startCountdown = () => {
smsCountdown.value = 60
const timer = setInterval(() => {
smsCountdown.value--
if (smsCountdown.value <= 0) {
clearInterval(timer)
}
}, 1000)
}
// 处理注册
const handleRegister = async () => {
@@ -354,7 +351,7 @@ const handleRegister = async () => {
phone: registerForm.phone,
registrationCode: registerForm.registrationCode,
password: registerForm.password,
// smsCode: registerForm.smsCode, // 短信验证码 - 已注释
smsCode: registerForm.smsCode,
captchaId: captchaInfo.captchaId,
captchaText: captchaInfo.captchaText
}
@@ -432,6 +429,13 @@ onMounted(() => {
const redirectPath = route.query.redirect || '/'
router.push(redirectPath)
}
// 从URL参数中获取邀请码并自动填入
const inviteCode = route.query.code
if (inviteCode) {
registerForm.registrationCode = inviteCode
ElMessage.success('已自动填入邀请码')
}
})
</script>

View File

@@ -76,7 +76,7 @@
@click="goToProduct(product.id)"
>
<div class="product-image">
<img :src="getImageUrl(product.image)" :alt="product.name" />
<img :src="product.image" :alt="product.name" />
<div v-if="product.discount" class="discount-badge">
{{ product.discount }}
</div>
@@ -138,9 +138,6 @@
title="购物车"
direction="rtl"
size="80%"
:z-index="10000"
:modal="true"
:append-to-body="true"
>
<div class="cart-content">
<div v-if="cartItems.length === 0" class="empty-cart">
@@ -149,7 +146,7 @@
</div>
<div v-else>
<div v-for="item in cartItems" :key="item.id" class="cart-item">
<img :src="getImageUrl(item.image)" :alt="item.name" class="item-image" />
<img :src="item.image" :alt="item.name" class="item-image" />
<div class="item-info">
<h4>{{ item.name }}</h4>
<p class="item-price">
@@ -208,7 +205,6 @@ import {
} from '@element-plus/icons-vue'
import api from '@/utils/api'
import { debounce } from 'lodash-es'
import { getImageUrl } from '@/config'
const router = useRouter()
const userStore = useUserStore()
@@ -241,11 +237,6 @@ const categories = ref([
// 计算属性
const filteredProducts = computed(() => {
// 安全检查确保products.value是数组
if (!products.value || !Array.isArray(products.value)) {
return []
}
let result = products.value
// 分类筛选
@@ -256,21 +247,21 @@ const filteredProducts = computed(() => {
// 搜索筛选
if (searchKeyword.value) {
result = result.filter(p =>
p.name && p.name.toLowerCase().includes(searchKeyword.value.toLowerCase()) ||
p.description && p.description.toLowerCase().includes(searchKeyword.value.toLowerCase())
p.name.toLowerCase().includes(searchKeyword.value.toLowerCase()) ||
p.description.toLowerCase().includes(searchKeyword.value.toLowerCase())
)
}
// 排序
switch (sortBy.value) {
case 'price_asc':
result.sort((a, b) => (a.points || 0) - (b.points || 0))
result.sort((a, b) => a.points - b.points)
break
case 'price_desc':
result.sort((a, b) => (b.points || 0) - (a.points || 0))
result.sort((a, b) => b.points - a.points)
break
case 'sales':
result.sort((a, b) => (b.sales || 0) - (a.sales || 0))
result.sort((a, b) => b.sales - a.sales)
break
}
@@ -288,19 +279,11 @@ const sortText = computed(() => {
})
const cartCount = computed(() => {
// 安全检查确保cartItems.value是数组
if (!cartItems.value || !Array.isArray(cartItems.value)) {
return 0
}
return cartItems.value.reduce((sum, item) => sum + (item.quantity || 0), 0)
return cartItems.value.reduce((sum, item) => sum + item.quantity, 0)
})
const totalPoints = computed(() => {
// 安全检查确保cartItems.value是数组
if (!cartItems.value || !Array.isArray(cartItems.value)) {
return 0
}
return cartItems.value.reduce((sum, item) => sum + ((item.points || 0) * (item.quantity || 0)), 0)
return cartItems.value.reduce((sum, item) => sum + (item.points * item.quantity), 0)
})
// 方法
@@ -399,7 +382,7 @@ const getProducts = async (isLoadMore = false) => {
loadingMore.value = true
}
const {data} = await api.get('/products', {
const response = await api.get('/products', {
params: {
page: page.value,
limit: 20,
@@ -409,28 +392,16 @@ const getProducts = async (isLoadMore = false) => {
}
})
// 确保响应数据是有效的数组
const responseProducts = data.data?.products || []
if (isLoadMore) {
// 确保products.value是数组
if (!Array.isArray(products.value)) {
products.value = []
}
products.value.push(...responseProducts)
products.value.push(...response.data.products)
} else {
products.value = responseProducts
products.value = response.data.products
}
hasMore.value = data.data?.hasMore || false
hasMore.value = response.data.hasMore
page.value++
} catch (error) {
console.error('获取商品列表失败:', error)
ElMessage.error('获取商品列表失败')
// 确保products.value始终是数组
if (!isLoadMore && (!products.value || !Array.isArray(products.value))) {
products.value = []
}
} finally {
loading.value = false
loadingMore.value = false
@@ -444,18 +415,13 @@ const loadMore = () => {
const getUserPoints = async () => {
try {
const response = await api.get('/user/points')
userPoints.value = response.data.points || 0
userPoints.value = response.data.points
} catch (error) {
console.error('获取用户积分失败:', error)
userPoints.value = 0
}
}
const truncateText = (text, maxLength) => {
// 安全检查确保text是字符串
if (!text || typeof text !== 'string') {
return ''
}
if (text.length <= maxLength) return text
return text.substring(0, maxLength) + '...'
}
@@ -470,33 +436,7 @@ onMounted(() => {
<style scoped>
.shop-page {
min-height: 100vh;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
background-attachment: fixed;
padding-bottom: 80px;
position: relative;
/* 移动端优化 */
-webkit-overflow-scrolling: touch;
overflow-x: hidden;
}
.shop-page::before {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
radial-gradient(circle at 40% 40%, rgba(120, 119, 198, 0.2) 0%, transparent 50%);
pointer-events: none;
z-index: 0;
}
.shop-page > * {
position: relative;
z-index: 1;
background-color: #f5f5f5;
}
.navbar {
@@ -505,13 +445,11 @@ onMounted(() => {
justify-content: space-between;
padding: 0 16px;
height: 56px;
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(20px);
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
background: white;
border-bottom: 1px solid #eee;
position: sticky;
top: 0;
z-index: 100;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}
.nav-left,
@@ -533,21 +471,14 @@ onMounted(() => {
.nav-title {
margin: 0;
font-size: 18px;
font-weight: 800;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
font-weight: 500;
color: #333;
}
.search-section {
padding: 20px;
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
margin: 20px 16px 0 16px;
border-radius: 16px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
padding: 16px;
background: white;
border-bottom: 1px solid #eee;
}
.search-input {
@@ -555,14 +486,9 @@ onMounted(() => {
}
.category-section {
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
padding: 20px 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
margin: 0 16px;
border-radius: 16px;
margin-top: 16px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
background: white;
padding: 16px 0;
border-bottom: 1px solid #eee;
}
.category-list {
@@ -576,33 +502,21 @@ onMounted(() => {
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
padding: 12px 16px;
border-radius: 16px;
gap: 4px;
padding: 8px 12px;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
min-width: 70px;
background: rgba(248, 250, 252, 0.8);
border: 2px solid transparent;
/* 移动端触摸优化 */
-webkit-tap-highlight-color: transparent;
touch-action: manipulation;
user-select: none;
transition: all 0.3s;
min-width: 60px;
}
.category-item:hover {
background: rgba(139, 92, 246, 0.1);
border-color: rgba(139, 92, 246, 0.3);
transform: translateY(-2px);
box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
background: #f0f9ff;
}
.category-item.active {
background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
background: #409eff;
color: white;
border-color: rgba(255, 255, 255, 0.3);
box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
transform: translateY(-3px);
}
.category-item span {
@@ -610,12 +524,7 @@ onMounted(() => {
}
.products-section {
padding: 20px;
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
margin: 20px;
border-radius: 20px;
border: 1px solid rgba(255, 255, 255, 0.1);
padding: 16px;
}
.section-header {
@@ -648,183 +557,98 @@ onMounted(() => {
}
.product-card {
background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
backdrop-filter: blur(20px);
border-radius: 16px;
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 8px 32px rgba(139, 92, 246, 0.15);
border: 1px solid rgba(139, 92, 246, 0.2);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
cursor: pointer;
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
/* 移动端触摸优化 */
-webkit-tap-highlight-color: transparent;
touch-action: manipulation;
}
.product-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(124, 58, 237, 0.06) 100%);
opacity: 0;
transition: opacity 0.3s ease;
pointer-events: none;
transition: all 0.3s;
}
.product-card:hover {
transform: translateY(-8px) scale(1.02);
box-shadow: 0 16px 48px rgba(139, 92, 246, 0.25);
border-color: rgba(139, 92, 246, 0.4);
}
.product-card:hover::before {
opacity: 1;
}
.product-card:active {
transform: translateY(-4px) scale(1.01);
transition: all 0.1s;
transform: translateY(-4px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}
.product-image {
position: relative;
width: 100%;
height: 140px;
height: 120px;
overflow: hidden;
background: linear-gradient(45deg, #f1f5f9 0%, #e2e8f0 100%);
}
.product-image img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.product-card:hover .product-image img {
transform: scale(1.1);
}
.discount-badge {
position: absolute;
top: 12px;
right: 12px;
background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
top: 8px;
right: 8px;
background: #ff4757;
color: white;
padding: 4px 8px;
border-radius: 12px;
font-size: 11px;
font-weight: 600;
box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
backdrop-filter: blur(10px);
padding: 2px 6px;
border-radius: 4px;
font-size: 12px;
}
.product-info {
padding: 16px;
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(15px);
padding: 12px;
}
.product-name {
margin: 0 0 6px 0;
font-size: 15px;
font-weight: 600;
color: #1e293b;
margin: 0 0 4px 0;
font-size: 14px;
font-weight: 500;
color: #333;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.product-desc {
margin: 0 0 12px 0;
margin: 0 0 8px 0;
font-size: 12px;
color: #64748b;
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
color: #666;
line-height: 1.4;
}
.product-price {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
margin-bottom: 8px;
}
.current-price {
display: flex;
align-items: center;
gap: 4px;
color: #f59e0b;
font-weight: 700;
font-size: 17px;
background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
gap: 2px;
color: #ff6b35;
font-weight: 600;
font-size: 16px;
}
.original-price {
color: #94a3b8;
color: #999;
font-size: 12px;
text-decoration: line-through;
font-weight: 500;
}
.product-stats {
display: flex;
justify-content: space-between;
font-size: 11px;
color: #64748b;
font-size: 12px;
color: #999;
margin-bottom: 8px;
background: rgba(139, 92, 246, 0.08);
padding: 6px 10px;
border-radius: 8px;
backdrop-filter: blur(5px);
border: 1px solid rgba(139, 92, 246, 0.1);
}
.product-actions {
padding: 0 16px 16px;
padding: 0 12px 12px;
}
.product-actions .el-button {
width: 100%;
height: 40px;
border-radius: 12px;
font-weight: 600;
font-size: 14px;
background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
border: none;
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.product-actions .el-button:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}
.product-actions .el-button:active {
transform: translateY(0);
}
.product-actions .el-button:disabled {
background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
color: #64748b;
box-shadow: none;
transform: none;
}
.empty-state {
@@ -841,67 +665,18 @@ onMounted(() => {
.cart-fab {
position: fixed;
bottom: 80px;
right: 40px;
width: 64px;
height: 64px;
background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
right: 20px;
width: 56px;
height: 56px;
background: #409eff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: white;
cursor: pointer;
box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
z-index: 9999;
/* 移动端触摸优化 */
-webkit-tap-highlight-color: transparent;
touch-action: manipulation;
user-select: none;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
backdrop-filter: blur(10px);
border: 2px solid rgba(255, 255, 255, 0.2);
}
.cart-badge {
position: absolute;
top: -6px;
right: -6px;
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
color: white;
border-radius: 50%;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
font-size: 11px;
font-weight: 700;
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
border: 2px solid white;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% {
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4), 0 0 0 0 rgba(239, 68, 68, 0.7);
}
70% {
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4), 0 0 0 10px rgba(239, 68, 68, 0);
}
100% {
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4), 0 0 0 0 rgba(239, 68, 68, 0);
}
}
.cart-fab:hover {
transform: scale(1.1);
box-shadow: 0 12px 35px rgba(139, 92, 246, 0.5);
background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}
.cart-fab:active {
transform: scale(1.05);
box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
box-shadow: 0 4px 12px rgba(64, 158, 255, 0.4);
z-index: 1000;
}
.cart-content {
@@ -977,276 +752,23 @@ onMounted(() => {
}
/* 响应式设计 */
@media (max-width: 768px) {
.navbar {
padding: 0 12px;
height: 50px;
}
.nav-title {
font-size: 16px;
}
.back-btn,
.points-btn {
font-size: 13px;
}
.search-section {
padding: 16px;
margin: 16px 12px 0 12px;
}
.category-section {
padding: 12px 0;
margin: 12px;
}
.category-list {
padding: 0 12px;
gap: 12px;
overflow-x: auto;
scrollbar-width: none;
-ms-overflow-style: none;
}
.category-list::-webkit-scrollbar {
display: none;
}
.category-item {
min-width: 60px;
padding: 8px 14px;
}
.category-item span {
font-size: 12px;
}
.products-section {
padding: 16px;
margin: 16px 12px;
}
.section-header {
margin-bottom: 12px;
}
.section-header h3 {
font-size: 15px;
}
.sort-btn {
font-size: 13px;
}
.products-grid {
grid-template-columns: repeat(2, 1fr);
gap: 12px;
}
.product-card {
border-radius: 12px;
}
.product-card:hover {
transform: none;
}
.product-image {
height: 120px;
}
.product-info {
padding: 12px;
}
.product-name {
font-size: 13px;
}
.product-desc {
font-size: 11px;
}
.current-price {
font-size: 15px;
}
.cart-fab {
bottom: 70px;
right: 16px;
width: 56px;
height: 56px;
}
}
@media (max-width: 480px) {
.navbar {
padding: 0 10px;
height: 48px;
}
.nav-title {
font-size: 15px;
}
.search-section {
margin: 12px 8px 0 8px;
padding: 12px;
}
.category-section {
margin: 8px;
padding: 8px 12px;
}
.products-section {
margin: 12px 8px;
padding: 12px;
}
.products-grid {
grid-template-columns: repeat(2, 1fr);
gap: 8px;
grid-template-columns: 1fr;
}
.product-card {
border-radius: 10px;
display: flex;
}
.product-image {
height: 100px;
width: 120px;
height: 120px;
flex-shrink: 0;
}
.product-info {
padding: 10px;
}
.product-name {
font-size: 12px;
}
.product-desc {
font-size: 10px;
margin-bottom: 4px;
}
.current-price {
font-size: 14px;
}
.product-stats {
font-size: 10px;
margin-bottom: 4px;
}
.product-actions {
padding: 0 10px 10px;
}
.product-actions .el-button {
font-size: 12px;
height: 36px;
}
.cart-fab {
bottom: 60px;
right: 12px;
width: 52px;
height: 52px;
}
.cart-item {
padding: 12px 0;
}
.item-image {
width: 50px;
height: 50px;
}
.item-info h4 {
font-size: 13px;
}
.item-price {
font-size: 12px;
}
.total-points {
font-size: 16px;
}
}
@media (max-width: 360px) {
.navbar {
padding: 0 8px;
}
.search-section {
margin: 8px 6px 0 6px;
padding: 10px;
}
.category-section {
margin: 6px;
padding: 6px 10px;
}
.products-section {
margin: 8px 6px;
padding: 10px;
}
.category-list {
padding: 0 8px;
gap: 8px;
}
.category-item {
min-width: 50px;
padding: 6px 10px;
}
.products-grid {
grid-template-columns: repeat(2, 1fr);
gap: 6px;
}
.product-card {
border-radius: 8px;
}
.product-image {
height: 85px;
}
.product-info {
padding: 8px;
}
.product-name {
font-size: 11px;
}
.current-price {
font-size: 13px;
}
.product-actions {
padding: 0 8px 8px;
}
.product-actions .el-button {
height: 32px;
font-size: 11px;
}
.cart-fab {
right: 8px;
width: 48px;
height: 48px;
flex: 1;
}
}
</style>

View File

@@ -14,11 +14,11 @@ export default defineConfig({
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:3000',
target: 'http://114.55.111.44:3001',
changeOrigin: true
},
'/uploads': {
target: 'http://localhost:3000',
target: 'http://114.55.111.44:3001',
changeOrigin: true
}
}