diff --git a/power_leasing/src/api/user.js b/power_leasing/src/api/user.js new file mode 100644 index 0000000..0b832bc --- /dev/null +++ b/power_leasing/src/api/user.js @@ -0,0 +1,76 @@ +import request from '../utils/request' + +//注册 +export function register(data) { + return request({ + url: `/lease/auth/register`, + method: 'post', + data + }) +} + + +//登录 +export function getLogin(data) { + return request({ + url: `/lease/auth/login`, + method: 'post', + data + }) + } + + + +//退出登录 +export function getLogout(data) { + return request({ + url: `/lease/auth/logout`, + method: 'post', + data + }) + } + + +//发送登录验证码 +export function sendLoginCode(data) { + return request({ + url: `/lease/auth/sendLoginCode`, + method: 'post', + data + }) + } + + + //发送注册验证码 +export function sendEmailCode(data) { + return request({ + url: `/lease/auth/sendRegisterCode`, + method: 'post', + data + }) + } + + + //发送修改密码验证码 +export function sendUpdatePwdCode(data) { + return request({ + url: `/lease/auth/sendUpdatePwdCode`, + method: 'post', + data + }) + } + + + //修改密码 +export function updatePassword(data) { + return request({ + url: `/lease/auth/updatePassword`, + method: 'post', + data + }) + } + + + + + diff --git a/power_leasing/src/components/header.vue b/power_leasing/src/components/header.vue index d38ee10..f5e7bdd 100644 --- a/power_leasing/src/components/header.vue +++ b/power_leasing/src/components/header.vue @@ -2,18 +2,47 @@
@@ -44,16 +73,25 @@ export default { cart: [], // 服务端购物车数量(统计 productMachineDtoList 的总条数) cartServerCount: 0, - navigation: mainNavigation + navigation: mainNavigation, + // 用户邮箱 + userEmail: '' } }, computed: { + // 计算购物车数量 cartItemCount() { // 只使用服务端数量,避免与本地缓存数量不一致 return Number.isFinite(this.cartServerCount) ? this.cartServerCount : 0 }, + // 计算面包屑导航 breadcrumbs() { return getBreadcrumb(this.$route.path) + }, + // 判断是否已登录(检查localStorage中是否有token) + isLoggedIn() { + const token = localStorage.getItem('token') + return !!token // 有token就是已登录,没有就是未登录 } }, watch: {}, @@ -65,6 +103,8 @@ export default { this.loadServerCartCount() // 监听应用内购物车更新事件 window.addEventListener('cart-updated', this.handleCartUpdated) + // 加载用户信息(邮箱) + this.loadUserEmail() }, beforeDestroy() { window.removeEventListener('storage', this.handleStorageChange) @@ -125,9 +165,58 @@ export default { // 无显式数量则主动刷新 this.loadServerCartCount() }, + /** + * 跳转到登录页 + */ + goToLogin() { + this.$router.push('/login') + }, + /** + * 跳转到注册页 + */ + goToRegister() { + this.$router.push('/register') + }, + /** + * 加载用户邮箱 + * 从localStorage读取用户信息,获取邮箱 + */ + loadUserEmail() { + try { + // 从localStorage读取用户信息 + const userInfoStr = localStorage.getItem('userInfo') + if (userInfoStr) { + const userInfo = JSON.parse(userInfoStr) + // 获取邮箱,如果没有邮箱就显示用户名 + this.userEmail = userInfo.email || userInfo.username || '用户' + } + } catch (e) { + console.error('读取用户信息失败:', e) + this.userEmail = '' + } + }, + /** + * 退出登录 + * 清除所有登录信息,跳转到登录页 + */ handleLogout() { + // 清除localStorage中的所有登录信息 + localStorage.removeItem('token') + localStorage.removeItem('userInfo') + localStorage.removeItem('leasEmail') + localStorage.removeItem('userId') + localStorage.removeItem('username') + + // 清空购物车 this.user = null this.cart = [] + this.userEmail = '' + + // 提示用户 + this.$message.success('退出登录成功') + + // 跳转到登录页 + this.$router.push('/login') }, getBreadcrumbPath(index) { const paths = ['/productList', '/cart', '/checkout'] @@ -144,14 +233,30 @@ export default { width: 100%; } +/* 导航栏布局:导航按钮在中间,登录状态在右边 */ .navbar { display: flex; - justify-content: center; - gap: 24px; + justify-content: center; /* 主内容居中 */ + align-items: center; background: #fff; border-bottom: 1px solid #eee; - padding: 16px 0; + padding: 16px 32px; margin-bottom: 16px; + position: relative; /* 让右侧元素可以绝对定位 */ +} + +/* 左侧导航按钮区域(实际在中间显示) */ +.nav-left { + display: flex; + gap: 24px; +} + +/* 右侧用户登录区域(绝对定位到右边) */ +.nav-right { + display: flex; + align-items: center; + position: absolute; + right: 32px; /* 距离右边32px */ } .nav-btn { @@ -171,14 +276,19 @@ export default { position: relative; } +/* 导航按钮悬停效果 */ .nav-btn:hover { - background: #f8f9fa; + background: #f5f7ff; + color: #667eea; transform: translateY(-2px); } +/* 导航按钮激活状态 - 紫色渐变,跟登录按钮一样 */ .nav-btn.active { - background: #42b983; + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; + box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3); + transform: translateY(-2px); } .nav-icon { @@ -233,12 +343,87 @@ export default { color: #ccc; } -/* 响应式设计 */ +/* 未登录:注册/登录按钮样式 */ +.auth-buttons { + display: flex; + gap: 12px; +} + +.auth-btn { + padding: 8px 20px; + border-radius: 6px; + font-size: 14px; + font-weight: 600; + text-decoration: none; + transition: all 0.3s ease; + cursor: pointer; +} + +/* 注册按钮 - 白色背景 */ +.register-btn { + color: #667eea; + border: 1px solid #667eea; + background: white; + cursor: pointer; +} + +.register-btn:hover { + background: #f5f7ff; +} + +/* 登录按钮 - 紫色背景 */ +.login-btn { + color: white; + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + border: none; + cursor: pointer; +} + +.login-btn:hover { + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4); +} + +/* 已登录:用户信息样式 */ +.user-info { + display: flex; + align-items: center; + gap: 16px; + padding: 8px 16px; + /* 去掉灰色背景,更简洁 */ +} + +/* 用户邮箱显示 */ +.user-email { + color: #2c3e50; + font-size: 14px; + font-weight: 600; +} + +/* 退出按钮样式 */ +.logout-btn { + color: #e74c3c; + font-size: 14px; + padding: 4px 12px; +} + +.logout-btn:hover { + color: #c0392b; + background: #fee; +} + +/* 响应式设计 - 手机端适配 */ @media (max-width: 768px) { .navbar { flex-direction: column; - gap: 12px; - padding: 12px 0; + gap: 16px; + padding: 12px 16px; + } + + .nav-left { + flex-direction: column; + width: 100%; + gap: 8px; } .nav-btn { @@ -247,6 +432,25 @@ export default { padding: 16px 20px; } + .nav-right { + width: 100%; + justify-content: center; + } + + .auth-buttons { + width: 100%; + } + + .auth-btn { + flex: 1; + text-align: center; + } + + .user-info { + width: 100%; + justify-content: center; + } + .breadcrumb { margin: 0 12px 16px 12px; padding: 8px 16px; diff --git a/power_leasing/src/router/routes.js b/power_leasing/src/router/routes.js index b46d974..d72a229 100644 --- a/power_leasing/src/router/routes.js +++ b/power_leasing/src/router/routes.js @@ -3,6 +3,40 @@ * @description 定义所有电商页面的路由配置 */ +// 认证相关路由(独立布局,无Header) +export const authRoutes = [ + { + path: '/login', + name: 'Login', + component: () => import('../views/auth/login.vue'), + meta: { + title: '用户登录', + description: '登录到您的账户', + requiresAuth: false // 不需要登录即可访问 + } + }, + { + path: '/register', + name: 'Register', + component: () => import('../views/auth/register.vue'), + meta: { + title: '用户注册', + description: '创建新账户', + requiresAuth: false + } + }, + { + path: '/reset-password', + name: 'ResetPassword', + component: () => import('../views/auth/reset-password.vue'), + meta: { + title: '重置密码', + description: '重置您的账户密码', + requiresAuth: false + } + } +] + // 商品相关路由 export const productRoutes = [ { @@ -100,13 +134,9 @@ export const accountRoutes = [ } }, { - // 兼容旧入口:收款记录 -> 卖家资金流水(收款tab) path: 'receipt-record', name: 'accountReceiptRecord', - redirect: (to) => ({ - path: '/account/seller-funds-flow', - query: { ...(to && to.query ? to.query : {}), tab: 'receipt' } - }), + component: () => import('../views/account/receiptRecord.vue'), meta: { title: '收款记录', description: '卖家收款流水记录', @@ -114,29 +144,15 @@ export const accountRoutes = [ } }, { - // 兼容旧入口:提现记录 -> 卖家资金流水(提现tab) path: 'withdraw-record', name: 'accountWithdrawRecord', - redirect: (to) => ({ - path: '/account/seller-funds-flow', - query: { ...(to && to.query ? to.query : {}), tab: 'withdraw' } - }), + component: () => import('../views/account/withdrawRecord.vue'), meta: { title: '提现记录', description: '卖家提现流水记录', allAuthority: ['all'] } }, - { - path: 'seller-funds-flow', - name: 'accountSellerFundsFlow', - component: () => import('../views/account/sellerFundsFlow.vue'), - meta: { - title: '资金流水', - description: '卖家收款/提现记录切换查看', - allAuthority: ['all'] - } - }, { path: 'shop-new', name: 'accountShopNew', @@ -197,16 +213,6 @@ export const accountRoutes = [ allAuthority: ['all'] } }, - { - path: 'purchased-machine-detail/:id', - name: 'purchasedMachineDetail', - component: () => import('../views/account/purchasedMachineDetail.vue'), - meta: { - title: '已购商品详情', - description: '查看已购买商品的详细信息', - allAuthority: ['all'] - } - }, { path: 'funds-flow', name: 'accountFundsFlow', @@ -281,6 +287,10 @@ export const childrenRoutes = [ // 主路由配置 export const mainRoutes = [ + // 认证路由(独立布局,无Header) + ...authRoutes, + + // 主应用路由(带Layout) { path: '/', name: 'Home', @@ -288,6 +298,7 @@ export const mainRoutes = [ redirect: '/productList', children: childrenRoutes }, + // 404页面重定向到商品列表 { path: '*', diff --git a/power_leasing/src/views/account/index.vue b/power_leasing/src/views/account/index.vue index 3f8eb8b..c4aa46b 100644 --- a/power_leasing/src/views/account/index.vue +++ b/power_leasing/src/views/account/index.vue @@ -295,14 +295,22 @@ export default { padding: 6px 10px; color: #2c3e50; cursor: pointer; + transition: all 0.3s ease; } +/* 激活状态 - 紫色渐变 */ .role-button.active { - background: #42b983; - border-color: #42b983; + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + border-color: #667eea; color: #fff; + box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3); +} +.role-button:hover { + background: #f5f7ff; + color: #667eea; + border-color: #667eea; } .role-button:focus { - outline: 2px solid #42b98333; + outline: 2px solid rgba(102, 126, 234, 0.2); outline-offset: 2px; } /* 用户信息卡片:置于导航最前,展示邮箱与首字母头像 */ @@ -318,17 +326,19 @@ export default { border-radius: 8px; margin-bottom: 4px; } +/* 头像也改成紫色渐变 */ .avatar { width: 36px; height: 36px; border-radius: 50%; - background: linear-gradient(135deg, #42b983, #67c23a); + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; + box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3); } .user-email { font-size: 14px; @@ -342,14 +352,18 @@ export default { color: #2c3e50; text-decoration: none; border-radius: 6px; - transition: background 0.2s; + transition: all 0.3s ease; } +/* 悬停效果 - 淡紫色 */ .side-link:hover { - background: #f6f8fa; + background: #f5f7ff; + color: #667eea; } +/* 激活状态 - 紫色渐变 */ .side-link.active { - background: #42b983; + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; + box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3); } .content { diff --git a/power_leasing/src/views/account/wallet.vue b/power_leasing/src/views/account/wallet.vue index 65e43c8..332da88 100644 --- a/power_leasing/src/views/account/wallet.vue +++ b/power_leasing/src/views/account/wallet.vue @@ -1160,7 +1160,7 @@ export default { + + \ No newline at end of file diff --git a/power_leasing/src/views/auth/register.vue b/power_leasing/src/views/auth/register.vue new file mode 100644 index 0000000..56d6f61 --- /dev/null +++ b/power_leasing/src/views/auth/register.vue @@ -0,0 +1,734 @@ + + + + + + diff --git a/power_leasing/src/views/auth/reset-password.vue b/power_leasing/src/views/auth/reset-password.vue new file mode 100644 index 0000000..db62537 --- /dev/null +++ b/power_leasing/src/views/auth/reset-password.vue @@ -0,0 +1,669 @@ + + + + + +