个人资料修改
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import axios, { AxiosError } from 'axios'
|
import axios, { AxiosError } from 'axios'
|
||||||
import { authApi } from './auth'
|
import { authApi } from './auth'
|
||||||
import router from '../router'
|
import router from '../router'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: 'http://localhost:8088/api',
|
baseURL: 'http://wcy111.top:8088/api',
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
@@ -27,6 +28,14 @@ const processQueue = (error: any, token: string | null = null) => {
|
|||||||
failedQueue = []
|
failedQueue = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleTokenExpired = () => {
|
||||||
|
localStorage.removeItem('accessToken')
|
||||||
|
localStorage.removeItem('refreshToken')
|
||||||
|
sessionStorage.removeItem('accessToken')
|
||||||
|
message.error('登录已过期,请重新登录')
|
||||||
|
router.push('/auth')
|
||||||
|
}
|
||||||
|
|
||||||
api.interceptors.request.use(
|
api.interceptors.request.use(
|
||||||
config => {
|
config => {
|
||||||
let token = localStorage.getItem('accessToken')
|
let token = localStorage.getItem('accessToken')
|
||||||
@@ -94,14 +103,14 @@ api.interceptors.response.use(
|
|||||||
return api(originalRequest)
|
return api(originalRequest)
|
||||||
} catch (refreshError) {
|
} catch (refreshError) {
|
||||||
processQueue(refreshError, null)
|
processQueue(refreshError, null)
|
||||||
localStorage.removeItem('accessToken')
|
handleTokenExpired()
|
||||||
localStorage.removeItem('refreshToken')
|
|
||||||
sessionStorage.removeItem('accessToken')
|
|
||||||
router.push('/auth')
|
|
||||||
return Promise.reject(refreshError)
|
return Promise.reject(refreshError)
|
||||||
} finally {
|
} finally {
|
||||||
isRefreshing = false
|
isRefreshing = false
|
||||||
}
|
}
|
||||||
|
} else if (error.response?.status === 401) {
|
||||||
|
handleTokenExpired()
|
||||||
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error('API Error:', error)
|
console.error('API Error:', error)
|
||||||
|
|||||||
+391
-101
@@ -1,56 +1,78 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mobile-container">
|
<div class="mobile-container">
|
||||||
|
<div class="header-bg"></div>
|
||||||
<!-- 头部区域 -->
|
|
||||||
<header class="header">
|
<header class="header">
|
||||||
<h1>个人中心</h1>
|
<h1>个人中心</h1>
|
||||||
<a-button class="settings-btn" type="text" @click="handleSettingsClick">
|
<a-button class="settings-btn" type="text" @click="handleSettingsClick">
|
||||||
<SettingOutlined :style="{ fontSize: '20px' }" />
|
<SettingOutlined :style="{ fontSize: '20px' }" />
|
||||||
</a-button>
|
</a-button>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<!-- 用户信息卡片 -->
|
|
||||||
<div class="profile-info">
|
<div class="profile-info">
|
||||||
<a-card :bordered="false" class="profile-card">
|
<a-card :bordered="false" class="profile-card">
|
||||||
<div class="avatar-section">
|
<div class="avatar-section">
|
||||||
<a-badge :dot="hasNotification" :offset="[-5, 5]">
|
<a-badge :dot="hasNotification" :offset="[-5, 5]">
|
||||||
<a-avatar :size="80" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" />
|
<a-avatar :size="90" :src="userInfo.avatar || DEFAULT_AVATAR" class="user-avatar" />
|
||||||
</a-badge>
|
</a-badge>
|
||||||
<div class="user-details">
|
<div class="user-details">
|
||||||
<h2 class="username">昵称</h2>
|
<h2 class="username">{{ userInfo.nickname || '用户' }}</h2>
|
||||||
<p class="email">user@example.com</p>
|
<p class="email">{{ userInfo.account }}</p>
|
||||||
|
<p class="signature" v-if="userInfo.signature">{{ userInfo.signature }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a-button type="primary" block @click="handleEditProfile">
|
<div class="shop-section" v-if="userInfo.shopName">
|
||||||
|
<div class="shop-card">
|
||||||
|
<div class="shop-icon-wrapper">
|
||||||
|
<ShopOutlined class="shop-icon" />
|
||||||
|
</div>
|
||||||
|
<div class="shop-content">
|
||||||
|
<p class="shop-label">所属店铺</p>
|
||||||
|
<h3 class="shop-name">{{ userInfo.shopName }}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="shop-arrow">
|
||||||
|
<RightOutlined />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a-button type="primary" block @click="handleEditProfile" class="edit-btn">
|
||||||
编辑资料
|
编辑资料
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-card>
|
</a-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 统计数据 -->
|
|
||||||
<div class="stats-section">
|
<div class="stats-section">
|
||||||
<a-row :gutter="16">
|
<a-card :bordered="false" class="stats-card">
|
||||||
<a-col :span="8">
|
<a-row :gutter="16">
|
||||||
<a-statistic title="订单" :value="12" />
|
<a-col :span="8">
|
||||||
</a-col>
|
<div class="stat-item">
|
||||||
<a-col :span="8">
|
<div class="stat-icon" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
|
||||||
<a-statistic title="收藏" :value="5" />
|
<ShoppingOutlined />
|
||||||
</a-col>
|
</div>
|
||||||
<a-col :span="8">
|
<a-statistic title="订单" :value="12" />
|
||||||
<a-statistic title="优惠券" :value="3" />
|
</div>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
<a-col :span="8">
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-icon" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
|
||||||
|
<HeartOutlined />
|
||||||
|
</div>
|
||||||
|
<a-statistic title="收藏" :value="5" />
|
||||||
|
</div>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="8">
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-icon" style="background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);">
|
||||||
|
<CreditCardOutlined />
|
||||||
|
</div>
|
||||||
|
<a-statistic title="优惠券" :value="3" />
|
||||||
|
</div>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 菜单列表 -->
|
|
||||||
<div class="menu-section">
|
<div class="menu-section">
|
||||||
<a-card :bordered="false" class="menu-card">
|
<a-card :bordered="false" class="menu-card">
|
||||||
<a-list :data-source="menuItems" :split="false">
|
<a-list :data-source="menuItems" :split="false">
|
||||||
<template #renderItem="{ item }">
|
<template #renderItem="{ item }">
|
||||||
<a-list-item
|
<a-list-item class="menu-item" @click="handleMenuClick(item.key)">
|
||||||
class="menu-item"
|
|
||||||
@click="handleMenuClick(item.key)"
|
|
||||||
>
|
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<RightOutlined />
|
<RightOutlined />
|
||||||
</template>
|
</template>
|
||||||
@@ -72,85 +94,212 @@
|
|||||||
</a-list>
|
</a-list>
|
||||||
</a-card>
|
</a-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 退出登录按钮 -->
|
|
||||||
<div class="logout-section">
|
<div class="logout-section">
|
||||||
<a-button danger block @click="handleLogout">
|
<a-button danger block @click="handleLogout">
|
||||||
退出登录
|
退出登录
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
<a-modal
|
||||||
|
v-model:visible="editModalVisible"
|
||||||
|
title="编辑资料"
|
||||||
|
@ok="handleSaveProfile"
|
||||||
|
@cancel="handleCancelEdit"
|
||||||
|
:confirmLoading="saving"
|
||||||
|
>
|
||||||
|
<a-form layout="vertical">
|
||||||
|
<a-form-item label="头像">
|
||||||
|
<div class="avatar-upload-section">
|
||||||
|
<a-upload
|
||||||
|
name="file"
|
||||||
|
:show-upload-list="false"
|
||||||
|
:before-upload="beforeUploadAvatar"
|
||||||
|
:custom-request="handleAvatarUpload"
|
||||||
|
accept="image/*"
|
||||||
|
>
|
||||||
|
<a-avatar :size="80" :src="editForm.avatar || DEFAULT_AVATAR" />
|
||||||
|
<div class="upload-hint">点击更换头像</div>
|
||||||
|
</a-upload>
|
||||||
|
<a-button v-if="editForm.avatar" type="text" danger size="small" @click="handleDeleteAvatar">
|
||||||
|
删除头像
|
||||||
|
</a-button>
|
||||||
|
</div>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="昵称">
|
||||||
|
<a-input v-model:value="editForm.nickname" placeholder="请输入昵称" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="个性签名">
|
||||||
|
<a-textarea v-model:value="editForm.signature" placeholder="请输入个性签名" :rows="3" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import {
|
import {
|
||||||
SettingOutlined,
|
SettingOutlined,
|
||||||
RightOutlined,
|
RightOutlined,
|
||||||
ShoppingOutlined,
|
ShoppingOutlined,
|
||||||
HeartOutlined,
|
HeartOutlined,
|
||||||
EnvironmentOutlined,
|
EnvironmentOutlined,
|
||||||
CreditCardOutlined,
|
CreditCardOutlined,
|
||||||
BellOutlined,
|
BellOutlined,
|
||||||
QuestionCircleOutlined
|
QuestionCircleOutlined,
|
||||||
|
ShopOutlined
|
||||||
} from '@ant-design/icons-vue'
|
} from '@ant-design/icons-vue'
|
||||||
import { message, Modal } from 'ant-design-vue'
|
import { message, Modal, UploadProps } from 'ant-design-vue'
|
||||||
import { authApi } from '@/api/auth'
|
import { authApi } from '@/api/auth'
|
||||||
|
import { userApi, type UserVO } from '@/api/user'
|
||||||
|
import { fileApi } from '@/api/file'
|
||||||
|
import { DEFAULT_AVATAR } from '@/constants'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
// 是否有未读通知
|
const userInfo = ref<UserVO>({
|
||||||
|
id: 0,
|
||||||
|
nickname: '',
|
||||||
|
account: '',
|
||||||
|
createTime: '',
|
||||||
|
updateTime: ''
|
||||||
|
})
|
||||||
|
|
||||||
const hasNotification = ref(true)
|
const hasNotification = ref(true)
|
||||||
|
const editModalVisible = ref(false)
|
||||||
|
const saving = ref(false)
|
||||||
|
const uploading = ref(false)
|
||||||
|
|
||||||
|
const editForm = ref({
|
||||||
|
nickname: '',
|
||||||
|
avatar: '',
|
||||||
|
signature: ''
|
||||||
|
})
|
||||||
|
|
||||||
// 菜单项数据
|
|
||||||
const menuItems = ref([
|
const menuItems = ref([
|
||||||
{
|
{
|
||||||
key: 'orders',
|
key: 'orders',
|
||||||
title: '我的订单',
|
title: '我的订单',
|
||||||
icon: ShoppingOutlined,
|
icon: ShoppingOutlined,
|
||||||
bgColor: '#e6f7ff'
|
bgColor: '#e6f7ff'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'wishlist',
|
key: 'wishlist',
|
||||||
title: '我的收藏',
|
title: '我的收藏',
|
||||||
icon: HeartOutlined,
|
icon: HeartOutlined,
|
||||||
bgColor: '#fff1f0'
|
bgColor: '#fff1f0'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'address',
|
key: 'address',
|
||||||
title: '收货地址',
|
title: '收货地址',
|
||||||
icon: EnvironmentOutlined,
|
icon: EnvironmentOutlined,
|
||||||
bgColor: '#f6ffed'
|
bgColor: '#f6ffed'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'payment',
|
key: 'payment',
|
||||||
title: '支付方式',
|
title: '支付方式',
|
||||||
icon: CreditCardOutlined,
|
icon: CreditCardOutlined,
|
||||||
bgColor: '#fff7e6'
|
bgColor: '#fff7e6'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'notifications',
|
key: 'notifications',
|
||||||
title: '消息通知',
|
title: '消息通知',
|
||||||
desc: '3条未读',
|
desc: '3条未读',
|
||||||
icon: BellOutlined,
|
icon: BellOutlined,
|
||||||
bgColor: '#f9f0ff'
|
bgColor: '#f9f0ff'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'help',
|
key: 'help',
|
||||||
title: '帮助与支持',
|
title: '帮助与支持',
|
||||||
icon: QuestionCircleOutlined,
|
icon: QuestionCircleOutlined,
|
||||||
bgColor: '#e6f7ff'
|
bgColor: '#e6f7ff'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
// 处理编辑资料点击
|
const fetchUserInfo = async () => {
|
||||||
|
try {
|
||||||
|
console.log('开始获取用户信息...')
|
||||||
|
const res = await userApi.getUserInfo()
|
||||||
|
console.log('获取到的用户信息:', res)
|
||||||
|
userInfo.value = res
|
||||||
|
console.log('设置后的 userInfo:', userInfo.value)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取用户信息失败:', error)
|
||||||
|
message.error('获取用户信息失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleEditProfile = () => {
|
const handleEditProfile = () => {
|
||||||
console.log('编辑个人资料被点击')
|
editForm.value = {
|
||||||
message.info('编辑功能开发中...')
|
nickname: userInfo.value.nickname || '',
|
||||||
|
avatar: userInfo.value.avatar || '',
|
||||||
|
signature: userInfo.value.signature || ''
|
||||||
|
}
|
||||||
|
editModalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const beforeUploadAvatar: UploadProps['beforeUpload'] = (file) => {
|
||||||
|
const isImage = file.type.startsWith('image/')
|
||||||
|
const isLt2M = file.size / 1024 / 1024 < 2
|
||||||
|
|
||||||
|
if (!isImage) {
|
||||||
|
message.error('只能上传图片文件!')
|
||||||
|
}
|
||||||
|
if (!isLt2M) {
|
||||||
|
message.error('图片大小不能超过 2MB!')
|
||||||
|
}
|
||||||
|
return isImage && isLt2M
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleAvatarUpload = async (options: any) => {
|
||||||
|
const { file } = options
|
||||||
|
uploading.value = true
|
||||||
|
try {
|
||||||
|
const res = await fileApi.uploadAvatar(file)
|
||||||
|
editForm.value.avatar = res
|
||||||
|
message.success('头像上传成功')
|
||||||
|
} catch (error) {
|
||||||
|
console.error('头像上传失败:', error)
|
||||||
|
message.error('头像上传失败')
|
||||||
|
} finally {
|
||||||
|
uploading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDeleteAvatar = () => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '确认删除',
|
||||||
|
content: '确定要删除头像吗?',
|
||||||
|
onOk: () => {
|
||||||
|
editForm.value.avatar = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSaveProfile = async () => {
|
||||||
|
if (!editForm.value.nickname) {
|
||||||
|
message.error('请输入昵称')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
saving.value = true
|
||||||
|
try {
|
||||||
|
await userApi.updateUserInfo(editForm.value)
|
||||||
|
message.success('资料更新成功')
|
||||||
|
editModalVisible.value = false
|
||||||
|
await fetchUserInfo()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('保存资料失败:', error)
|
||||||
|
message.error('保存资料失败')
|
||||||
|
} finally {
|
||||||
|
saving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCancelEdit = () => {
|
||||||
|
editModalVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理菜单项点击
|
|
||||||
const handleMenuClick = (key: string) => {
|
const handleMenuClick = (key: string) => {
|
||||||
console.log('菜单项被点击:', key)
|
console.log('菜单项被点击:', key)
|
||||||
if (key === 'wishlist') {
|
if (key === 'wishlist') {
|
||||||
@@ -168,7 +317,6 @@ const handleMenuClick = (key: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理退出登录
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认退出登录',
|
title: '确认退出登录',
|
||||||
@@ -181,24 +329,24 @@ const handleLogout = () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('登出接口调用失败:', error)
|
console.error('登出接口调用失败:', error)
|
||||||
} finally {
|
} finally {
|
||||||
// 清除本地存储的token
|
|
||||||
localStorage.removeItem('accessToken')
|
localStorage.removeItem('accessToken')
|
||||||
localStorage.removeItem('refreshToken')
|
localStorage.removeItem('refreshToken')
|
||||||
sessionStorage.removeItem('accessToken')
|
sessionStorage.removeItem('accessToken')
|
||||||
|
|
||||||
message.success('已退出登录')
|
message.success('已退出登录')
|
||||||
// 跳转到登录页面
|
|
||||||
router.push('/auth')
|
router.push('/auth')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理设置图标点击
|
|
||||||
const handleSettingsClick = () => {
|
const handleSettingsClick = () => {
|
||||||
console.log('设置图标被点击')
|
console.log('设置图标被点击')
|
||||||
router.push('/settings')
|
router.push('/settings')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
fetchUserInfo()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@@ -206,6 +354,17 @@ const handleSettingsClick = () => {
|
|||||||
padding-top: 60px;
|
padding-top: 60px;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-bg {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 180px;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
|
||||||
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
@@ -218,9 +377,8 @@ const handleSettingsClick = () => {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
border-bottom: 1px solid #f0f0f0;
|
background: transparent;
|
||||||
background: white;
|
color: white;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header h1 {
|
.header h1 {
|
||||||
@@ -235,26 +393,35 @@ const handleSettingsClick = () => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile-info {
|
.profile-info {
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile-card {
|
.profile-card {
|
||||||
border-radius: 16px;
|
border-radius: 20px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile-card :deep(.ant-card-body) {
|
.profile-card :deep(.ant-card-body) {
|
||||||
padding: 24px;
|
padding: 28px 24px 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar-section {
|
.avatar-section {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 16px;
|
gap: 18px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-avatar {
|
||||||
|
border: 4px solid white;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-details {
|
.user-details {
|
||||||
@@ -262,46 +429,162 @@ const handleSettingsClick = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.username {
|
.username {
|
||||||
font-size: 20px;
|
font-size: 24px;
|
||||||
font-weight: bold;
|
font-weight: 700;
|
||||||
margin: 0 0 4px 0;
|
margin: 0 0 6px 0;
|
||||||
|
color: #1a1a2e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.email {
|
.email {
|
||||||
color: #999;
|
color: #8b8b9a;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
margin: 0 0 6px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signature {
|
||||||
|
color: #6b6b7a;
|
||||||
|
font-size: 13px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-section {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-card {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
padding: 18px;
|
||||||
|
background: linear-gradient(135deg, #f5f7ff 0%, #e8ecff 100%);
|
||||||
|
border-radius: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-card:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-icon-wrapper {
|
||||||
|
width: 52px;
|
||||||
|
height: 52px;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 14px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-icon {
|
||||||
|
font-size: 24px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-content {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #8b8b9a;
|
||||||
|
margin: 0 0 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-name {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a2e;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-arrow {
|
||||||
|
color: #c4c4d0;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-btn {
|
||||||
|
height: 48px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border: none;
|
||||||
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-upload-section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-hint {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #667eea;
|
||||||
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-section {
|
.stats-section {
|
||||||
padding: 0 15px 15px;
|
padding: 0 15px 15px;
|
||||||
display: flex;
|
position: relative;
|
||||||
justify-content: center;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-section :deep(.ant-row) {
|
.stats-card {
|
||||||
width: 100%;
|
border-radius: 20px;
|
||||||
max-width: 400px;
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-card :deep(.ant-card-body) {
|
||||||
|
padding: 20px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon {
|
||||||
|
width: 52px;
|
||||||
|
height: 52px;
|
||||||
|
border-radius: 14px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 24px;
|
||||||
|
color: white;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-section :deep(.ant-statistic-title) {
|
.stats-section :deep(.ant-statistic-title) {
|
||||||
font-size: 12px;
|
font-size: 13px;
|
||||||
color: #999;
|
color: #8b8b9a;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-section :deep(.ant-statistic-content) {
|
.stats-section :deep(.ant-statistic-content) {
|
||||||
font-size: 20px;
|
font-size: 22px;
|
||||||
font-weight: bold;
|
font-weight: 700;
|
||||||
color: #1890ff;
|
color: #1a1a2e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-section {
|
.menu-section {
|
||||||
padding: 0 15px 15px;
|
padding: 0 15px 15px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-card {
|
.menu-card {
|
||||||
border-radius: 16px;
|
border-radius: 20px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-card :deep(.ant-card-body) {
|
.menu-card :deep(.ant-card-body) {
|
||||||
@@ -309,14 +592,14 @@ const handleSettingsClick = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.menu-item {
|
.menu-item {
|
||||||
padding: 16px;
|
padding: 18px 16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background 0.3s;
|
transition: all 0.3s ease;
|
||||||
border-bottom: 1px solid #f0f0f0;
|
border-bottom: 1px solid #f5f5f7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-item:hover {
|
.menu-item:hover {
|
||||||
background: #fafafa;
|
background: #f8f9ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-item:last-child {
|
.menu-item:last-child {
|
||||||
@@ -325,38 +608,45 @@ const handleSettingsClick = () => {
|
|||||||
|
|
||||||
.menu-item :deep(.ant-list-item-action) {
|
.menu-item :deep(.ant-list-item-action) {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
color: #ccc;
|
color: #c4c4d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-icon {
|
.menu-icon {
|
||||||
width: 40px;
|
width: 44px;
|
||||||
height: 40px;
|
height: 44px;
|
||||||
border-radius: 10px;
|
border-radius: 12px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: 18px;
|
font-size: 20px;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-item :deep(.ant-list-item-meta-title) {
|
.menu-item :deep(.ant-list-item-meta-title) {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
color: #333;
|
color: #1a1a2e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-item :deep(.ant-list-item-meta-description) {
|
.menu-item :deep(.ant-list-item-meta-description) {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #999;
|
color: #8b8b9a;
|
||||||
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logout-section {
|
.logout-section {
|
||||||
padding: 0 15px 20px;
|
padding: 0 15px 25px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logout-section :deep(.ant-btn-dangerous) {
|
.logout-section :deep(.ant-btn-dangerous) {
|
||||||
height: 48px;
|
height: 50px;
|
||||||
border-radius: 24px;
|
border-radius: 25px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
|
||||||
|
border: none;
|
||||||
|
box-shadow: 0 4px 15px rgba(238, 90, 111, 0.3);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export default defineConfig({
|
|||||||
'localhost',
|
'localhost',
|
||||||
'127.0.0.1',
|
'127.0.0.1',
|
||||||
'2666.online', // 允许通过 2666.online 访问
|
'2666.online', // 允许通过 2666.online 访问
|
||||||
|
'wcy111.top', // 允许通过 wcy111.top 访问
|
||||||
// 可以添加更多允许的域名
|
// 可以添加更多允许的域名
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -164,6 +164,13 @@
|
|||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MinIO -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.minio</groupId>
|
||||||
|
<artifactId>minio</artifactId>
|
||||||
|
<version>8.5.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Lombok -->
|
<!-- Lombok -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Long userId = jwtUtil.getUserIdFromToken(token);
|
Long userId = jwtUtil.getUserIdFromToken(token);
|
||||||
|
String account = jwtUtil.getAccountFromToken(token);
|
||||||
request.setAttribute("userId", userId);
|
request.setAttribute("userId", userId);
|
||||||
|
request.setAttribute("account", account);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-2
@@ -179,11 +179,25 @@ public class UserController {
|
|||||||
* @return 用户VO
|
* @return 用户VO
|
||||||
*/
|
*/
|
||||||
@GetMapping("/info")
|
@GetMapping("/info")
|
||||||
public Result<UserVO> getCurrentUserInfo() {
|
public Result<UserVO> getCurrentUserInfo(HttpServletRequest request) {
|
||||||
UserVO userVO = userService.getCurrentUserInfo();
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
UserVO userVO = userService.getUserById(userId);
|
||||||
return Result.success(userVO);
|
return Result.success(userVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新当前用户信息
|
||||||
|
*
|
||||||
|
* @param userDTO 用户DTO
|
||||||
|
* @return 是否更新成功
|
||||||
|
*/
|
||||||
|
@PutMapping("/update")
|
||||||
|
public Result<Boolean> updateCurrentUserInfo(HttpServletRequest request, @RequestBody UserDTO userDTO) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
boolean success = userService.updateUser(userId, userDTO);
|
||||||
|
return Result.success(success);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 绑定手机号
|
* 绑定手机号
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ public class UserDTO {
|
|||||||
*/
|
*/
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户头像URL
|
||||||
|
*/
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户签名
|
* 用户签名
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -66,6 +66,12 @@ public class UserDO extends BaseEntity {
|
|||||||
@TableField("password")
|
@TableField("password")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户头像URL
|
||||||
|
*/
|
||||||
|
@TableField("avatar")
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户签名
|
* 用户签名
|
||||||
*/
|
*/
|
||||||
|
|||||||
+39
-8
@@ -9,10 +9,12 @@ import com.xiaowang.yuminailcore.dto.RegisterRequestDTO;
|
|||||||
import com.xiaowang.yuminailcore.dto.UserDTO;
|
import com.xiaowang.yuminailcore.dto.UserDTO;
|
||||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
||||||
|
import com.xiaowang.yuminailcore.service.ShopService;
|
||||||
import com.xiaowang.yuminailcore.service.UserService;
|
import com.xiaowang.yuminailcore.service.UserService;
|
||||||
import com.xiaowang.yuminailcore.utils.JwtUtil;
|
import com.xiaowang.yuminailcore.utils.JwtUtil;
|
||||||
import com.xiaowang.yuminailcore.vo.LoginResponseVO;
|
import com.xiaowang.yuminailcore.vo.LoginResponseVO;
|
||||||
import com.xiaowang.yuminailcore.vo.UserVO;
|
import com.xiaowang.yuminailcore.vo.UserVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.ShopVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -33,6 +35,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
|
|
||||||
private final UserMapper userMapper;
|
private final UserMapper userMapper;
|
||||||
private final JwtUtil jwtUtil;
|
private final JwtUtil jwtUtil;
|
||||||
|
private final ShopService shopService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createUser(UserDTO userDTO) {
|
public Long createUser(UserDTO userDTO) {
|
||||||
@@ -56,14 +59,34 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
if (userDO == null) {
|
if (userDO == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
userDO.setShopId(userDTO.getShopId());
|
if (userDTO.getShopId() != null) {
|
||||||
userDO.setNickname(userDTO.getNickname());
|
userDO.setShopId(userDTO.getShopId());
|
||||||
userDO.setAccount(userDTO.getAccount());
|
}
|
||||||
userDO.setPassword(userDTO.getPassword());
|
if (userDTO.getNickname() != null) {
|
||||||
userDO.setSignature(userDTO.getSignature());
|
userDO.setNickname(userDTO.getNickname());
|
||||||
userDO.setLevel(userDTO.getLevel());
|
}
|
||||||
userDO.setType(userDTO.getType());
|
if (userDTO.getAccount() != null) {
|
||||||
userDO.setVipId(userDTO.getVipId());
|
userDO.setAccount(userDTO.getAccount());
|
||||||
|
}
|
||||||
|
if (userDTO.getPassword() != null) {
|
||||||
|
userDO.setPassword(userDTO.getPassword());
|
||||||
|
}
|
||||||
|
if (userDTO.getAvatar() != null) {
|
||||||
|
userDO.setAvatar(userDTO.getAvatar());
|
||||||
|
}
|
||||||
|
if (userDTO.getSignature() != null) {
|
||||||
|
userDO.setSignature(userDTO.getSignature());
|
||||||
|
}
|
||||||
|
if (userDTO.getLevel() != null) {
|
||||||
|
userDO.setLevel(userDTO.getLevel());
|
||||||
|
}
|
||||||
|
if (userDTO.getType() != null) {
|
||||||
|
userDO.setType(userDTO.getType());
|
||||||
|
}
|
||||||
|
if (userDTO.getVipId() != null) {
|
||||||
|
userDO.setVipId(userDTO.getVipId());
|
||||||
|
}
|
||||||
|
userDO.setUpdateTime(LocalDateTime.now());
|
||||||
return userMapper.updateById(userDO) > 0;
|
return userMapper.updateById(userDO) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,8 +161,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
UserVO userVO = new UserVO();
|
UserVO userVO = new UserVO();
|
||||||
userVO.setId(userDO.getId());
|
userVO.setId(userDO.getId());
|
||||||
userVO.setShopId(userDO.getShopId());
|
userVO.setShopId(userDO.getShopId());
|
||||||
|
if (userDO.getShopId() != null && userDO.getShopId() > 0) {
|
||||||
|
ShopVO shopVO = shopService.getShopById(userDO.getShopId());
|
||||||
|
if (shopVO != null) {
|
||||||
|
userVO.setShopName(shopVO.getShopName());
|
||||||
|
}
|
||||||
|
}
|
||||||
userVO.setNickname(userDO.getNickname());
|
userVO.setNickname(userDO.getNickname());
|
||||||
userVO.setAccount(userDO.getAccount());
|
userVO.setAccount(userDO.getAccount());
|
||||||
|
String defaultAvatar = "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png";
|
||||||
|
userVO.setAvatar(userDO.getAvatar() != null && !userDO.getAvatar().isEmpty() ? userDO.getAvatar() : defaultAvatar);
|
||||||
userVO.setSignature(userDO.getSignature());
|
userVO.setSignature(userDO.getSignature());
|
||||||
userVO.setLevel(userDO.getLevel());
|
userVO.setLevel(userDO.getLevel());
|
||||||
userVO.setType(userDO.getType());
|
userVO.setType(userDO.getType());
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ public class UserVO {
|
|||||||
*/
|
*/
|
||||||
private String account;
|
private String account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户头像URL
|
||||||
|
*/
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户签名
|
* 用户签名
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,3 +10,8 @@ server.servlet.encoding.enabled=true
|
|||||||
|
|
||||||
# MyBatis编码配置
|
# MyBatis编码配置
|
||||||
mybatis.configuration.map-underscore-to-camel-case=true
|
mybatis.configuration.map-underscore-to-camel-case=true
|
||||||
|
|
||||||
|
# 时区配置
|
||||||
|
spring.jackson.time-zone=Asia/Shanghai
|
||||||
|
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
||||||
|
server.timezone=Asia/Shanghai
|
||||||
|
|||||||
@@ -26,3 +26,7 @@ spring:
|
|||||||
uri: lb://yumi-nail-core
|
uri: lb://yumi-nail-core
|
||||||
predicates:
|
predicates:
|
||||||
- Path=/api/tag/**
|
- Path=/api/tag/**
|
||||||
|
- id: file-route
|
||||||
|
uri: lb://yumi-nail-core
|
||||||
|
predicates:
|
||||||
|
- Path=/api/file/**
|
||||||
|
|||||||
Reference in New Issue
Block a user