修复一些问题,优化前后端交互接口格式,优化首页轮播图图的维护
This commit is contained in:
+182
-181
@@ -100,95 +100,151 @@ export interface AdminLoginResponse {
|
||||
userInfo: any
|
||||
}
|
||||
|
||||
export interface HotProduct {
|
||||
id: number
|
||||
title: string
|
||||
price: number
|
||||
likeCount: number
|
||||
collectCount: number
|
||||
}
|
||||
|
||||
export interface RecentActivity {
|
||||
id: number
|
||||
type: string
|
||||
title: string
|
||||
description: string
|
||||
time: string
|
||||
color: string
|
||||
}
|
||||
|
||||
export interface DashboardStats {
|
||||
totalUsers: number
|
||||
totalProducts: number
|
||||
totalShops: number
|
||||
todayOrders: number
|
||||
hotProducts: HotProduct[]
|
||||
recentActivities: RecentActivity[]
|
||||
}
|
||||
|
||||
export const adminAuthApi = {
|
||||
login: (data: AdminLoginRequest) => {
|
||||
return adminApi.post<AdminLoginResponse>('/auth/login', data)
|
||||
},
|
||||
refreshToken: (refreshToken: string) => {
|
||||
return adminApi.post<{ accessToken: string; refreshToken: string }>('/auth/refresh', { refreshToken })
|
||||
}
|
||||
}
|
||||
|
||||
logout: () => {
|
||||
return adminApi.post('/auth/logout')
|
||||
export interface ObjectStorageFileVO {
|
||||
id: number
|
||||
fileName: string
|
||||
fileSize: number
|
||||
contentType: string
|
||||
createTime: string
|
||||
}
|
||||
|
||||
export const adminFileApi = {
|
||||
uploadFile: (file: File) => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return adminApi.post<ObjectStorageFileVO>('/object-storage-file/upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
},
|
||||
getSignedUrl: (id: number) => {
|
||||
return adminApi.get<string>(`/object-storage-file/get-signed-url/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
id: number
|
||||
tagName: string
|
||||
textColor?: string
|
||||
bgColor?: string
|
||||
borderColor?: string
|
||||
shopId?: number
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
|
||||
export const adminTagApi = {
|
||||
listAllTags: () => {
|
||||
return adminApi.get<Tag[]>('/tag/list/all')
|
||||
},
|
||||
listTagsByShopId: (shopId: number) => {
|
||||
return adminApi.get<Tag[]>(`/tag/list/by-shop/${shopId}`)
|
||||
},
|
||||
createTag: (data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: number }) => {
|
||||
return adminApi.post<number>('/tag/create', data)
|
||||
},
|
||||
updateTag: (id: number, data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: number }) => {
|
||||
return adminApi.put<boolean>(`/tag/update/${id}`, data)
|
||||
},
|
||||
deleteTag: (id: number) => {
|
||||
return adminApi.delete<boolean>(`/tag/delete/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export interface Artist {
|
||||
id: number
|
||||
nickname: string
|
||||
account: string
|
||||
avatar?: string
|
||||
shopId?: number
|
||||
shopName?: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
|
||||
export const adminArtistApi = {
|
||||
listArtists: (shopId?: number) => {
|
||||
const params: any = {}
|
||||
if (shopId) {
|
||||
params.shopId = shopId
|
||||
}
|
||||
return adminApi.get<Artist[]>('/user/list/artists', { params })
|
||||
}
|
||||
}
|
||||
|
||||
export interface Coupon {
|
||||
id: number
|
||||
couponName: string
|
||||
couponType: number
|
||||
discountValue?: string
|
||||
minAmount?: number
|
||||
reduceAmount?: string
|
||||
startTime: string
|
||||
endTime: string
|
||||
shopId?: number
|
||||
shopName?: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
|
||||
export const adminCouponApi = {
|
||||
listAllCoupons: (shopId?: number) => {
|
||||
const params = shopId ? { shopId } : {}
|
||||
return adminApi.get<Coupon[]>('/coupon/list/all', { params })
|
||||
},
|
||||
createCoupon: (data: any) => {
|
||||
return adminApi.post<number>('/coupon/create', data)
|
||||
},
|
||||
updateCoupon: (id: number, data: any) => {
|
||||
return adminApi.put<boolean>(`/coupon/update/${id}`, data)
|
||||
},
|
||||
deleteCoupon: (id: number) => {
|
||||
return adminApi.delete<boolean>(`/coupon/delete/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export interface Product {
|
||||
id: number
|
||||
shopId: number
|
||||
shopName?: string
|
||||
title: string
|
||||
description: string
|
||||
imageFileIds: string
|
||||
imageUrls?: string[]
|
||||
price: number
|
||||
tags: string
|
||||
approximateDuration?: string
|
||||
tags?: string
|
||||
tagList?: string[]
|
||||
tagInfos?: any[]
|
||||
likeCount: number
|
||||
collectCount: number
|
||||
approximateDuration: string
|
||||
bookableArtists: string
|
||||
availableCoupons: string
|
||||
imageFileIds?: string
|
||||
imageUrls?: string[]
|
||||
bookableArtists?: string
|
||||
availableCoupons?: string
|
||||
likeCount?: number
|
||||
collectCount?: number
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
|
||||
export interface ProductListResponse {
|
||||
list: Product[]
|
||||
total: number
|
||||
page: number
|
||||
size: number
|
||||
}
|
||||
|
||||
export interface CreateProductRequest {
|
||||
shopId: number
|
||||
title: string
|
||||
description: string
|
||||
imageFileIds: string
|
||||
price: number
|
||||
tags: string
|
||||
approximateDuration: string
|
||||
bookableArtists: string
|
||||
availableCoupons: string
|
||||
}
|
||||
|
||||
export const adminDashboardApi = {
|
||||
getStats: () => {
|
||||
return adminApi.get<DashboardStats>('/dashboard/stats')
|
||||
}
|
||||
}
|
||||
|
||||
export const adminProductApi = {
|
||||
listProducts: (params: { page: number; size: number; keyword?: string; shopId?: number }) => {
|
||||
return adminApi.get<ProductListResponse>('/product/list', { params })
|
||||
return adminApi.get<{ list: Product[]; total: number; page: number; size: number }>('/product/list', { params })
|
||||
},
|
||||
createProduct: (data: CreateProductRequest) => {
|
||||
listAllProducts: () => {
|
||||
return adminApi.get<Product[]>('/product/list/all')
|
||||
},
|
||||
createProduct: (data: any) => {
|
||||
return adminApi.post<number>('/product/create', data)
|
||||
},
|
||||
updateProduct: (id: number, data: CreateProductRequest) => {
|
||||
updateProduct: (id: number, data: any) => {
|
||||
return adminApi.put<boolean>(`/product/update/${id}`, data)
|
||||
},
|
||||
deleteProduct: (id: number) => {
|
||||
@@ -202,7 +258,9 @@ export interface Shop {
|
||||
description: string
|
||||
address: string
|
||||
businessHours: string
|
||||
imageFileIds: string
|
||||
coverImageFileId?: string
|
||||
coverImageUrls?: string[]
|
||||
imageFileIds?: string
|
||||
imageUrls?: string[]
|
||||
createTime: string
|
||||
updateTime: string
|
||||
@@ -220,7 +278,8 @@ export interface CreateShopRequest {
|
||||
description: string
|
||||
address: string
|
||||
businessHours: string
|
||||
imageFileIds: string
|
||||
coverImageFileId?: string
|
||||
imageFileIds?: string
|
||||
}
|
||||
|
||||
export const adminShopApi = {
|
||||
@@ -254,159 +313,101 @@ export interface UserVO {
|
||||
vipId?: number
|
||||
createTime: string
|
||||
updateTime: string
|
||||
status: number
|
||||
phone?: string
|
||||
}
|
||||
|
||||
export interface UserListResponse {
|
||||
list: UserVO[]
|
||||
export interface PageResult<T> {
|
||||
list: T[]
|
||||
total: number
|
||||
page: number
|
||||
size: number
|
||||
}
|
||||
|
||||
export interface CreateUserRequest {
|
||||
shopId: number
|
||||
nickname: string
|
||||
account: string
|
||||
phone: string
|
||||
password: string
|
||||
type: number
|
||||
}
|
||||
|
||||
export const userApi = {
|
||||
getUserInfo: () => {
|
||||
return adminApi.get<UserVO>('/user/info')
|
||||
export const adminUserApi = {
|
||||
listUsers: (params: { page: number; size: number; keyword?: string; type?: number; shopId?: number }) => {
|
||||
return adminApi.get<PageResult<UserVO>>('/user/list', { params })
|
||||
},
|
||||
listUsers: (params: { page: number; size: number; keyword?: string; shopId?: number; status?: number }) => {
|
||||
return adminApi.get<UserListResponse>('/user/list', { params })
|
||||
listAllUsers: () => {
|
||||
return adminApi.get<UserVO[]>('/user/list/all')
|
||||
},
|
||||
createUser: (data: CreateUserRequest) => {
|
||||
createUser: (data: any) => {
|
||||
return adminApi.post<number>('/user/create', data)
|
||||
},
|
||||
updateUser: (id: number, data: Partial<CreateUserRequest>) => {
|
||||
updateUser: (id: number, data: any) => {
|
||||
return adminApi.put<boolean>(`/user/update/${id}`, data)
|
||||
},
|
||||
updateUserStatus: (id: number, status: number) => {
|
||||
return adminApi.put(`/user/status/${id}`, { status })
|
||||
},
|
||||
deleteUser: (id: number) => {
|
||||
return adminApi.delete<boolean>(`/user/delete/${id}`)
|
||||
},
|
||||
updateUserStatus: (id: number, status: number) => {
|
||||
return adminApi.put<boolean>(`/user/status/${id}`, { status })
|
||||
},
|
||||
resetPassword: (id: number) => {
|
||||
return adminApi.post(`/user/reset-password/${id}`)
|
||||
return adminApi.post<string>(`/user/reset-password/${id}`)
|
||||
},
|
||||
getUserInfo: () => {
|
||||
return adminApi.get<UserVO>('/user/info')
|
||||
}
|
||||
}
|
||||
|
||||
export interface PermissionVO {
|
||||
id: number
|
||||
permissionName: string
|
||||
permissionCode: string
|
||||
description: string
|
||||
module: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
// 别名导出,兼容旧代码
|
||||
export const userApi = adminUserApi
|
||||
|
||||
export interface ObjectStorageFileVO {
|
||||
export interface OrderVO {
|
||||
id: number
|
||||
fileName: string
|
||||
fileUrl: string
|
||||
orderNo: string
|
||||
userId: number
|
||||
userNickname?: string
|
||||
shopId: number
|
||||
shopName?: string
|
||||
artistId?: number
|
||||
artistName?: string
|
||||
totalAmount: number
|
||||
discountAmount: number
|
||||
payAmount: number
|
||||
status: number
|
||||
statusText?: string
|
||||
remark?: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
|
||||
export const adminFileApi = {
|
||||
uploadFile: (file: File) => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return adminApi.post<ObjectStorageFileVO>('/object-storage-file/upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
export const adminOrderApi = {
|
||||
listOrders: (params: { page: number; size: number; keyword?: string; status?: number; shopId?: number }) => {
|
||||
return adminApi.get<PageResult<OrderVO>>('/order/list', { params })
|
||||
},
|
||||
|
||||
getSignedUrl: (fileId: number, expiryTimeInMinutes?: number) => {
|
||||
return adminApi.get<string>(`/object-storage-file/get-signed-url/${fileId}`, {
|
||||
params: { expiryTimeInMinutes }
|
||||
})
|
||||
updateOrderStatus: (id: number, status: number) => {
|
||||
return adminApi.put<boolean>(`/order/update-status/${id}`, { status })
|
||||
}
|
||||
}
|
||||
|
||||
export interface PermissionVO {
|
||||
// 仪表盘相关接口
|
||||
export interface HotProductVO {
|
||||
productId: number
|
||||
productName: string
|
||||
orderCount: number
|
||||
}
|
||||
|
||||
export interface RecentActivityVO {
|
||||
id: number
|
||||
permissionCode: string
|
||||
permissionName: string
|
||||
permissionGroup: string
|
||||
type: string
|
||||
description: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
time: string
|
||||
}
|
||||
|
||||
export const permissionApi = {
|
||||
listAllPermissions: () => {
|
||||
return adminApi.get<PermissionVO[]>('/permission/list/all')
|
||||
},
|
||||
getUserPermissions: (userId?: number) => {
|
||||
if (userId) {
|
||||
return adminApi.get<PermissionVO[]>(`/permission/user/${userId}`)
|
||||
}
|
||||
return adminApi.get<PermissionVO[]>('/permission/user/current')
|
||||
},
|
||||
assignUserPermissions: (userId: number, permissionIds: number[]) => {
|
||||
return adminApi.post(`/permission/assign/${userId}`, { permissionIds })
|
||||
}
|
||||
export interface DashboardStats {
|
||||
totalUsers: number
|
||||
totalProducts: number
|
||||
totalShops: number
|
||||
todayOrders: number
|
||||
hotProducts: HotProductVO[]
|
||||
recentActivities: RecentActivityVO[]
|
||||
}
|
||||
|
||||
export const adminTagApi = {
|
||||
listAllTags: () => {
|
||||
return adminApi.get<any[]>('/tag/list/all')
|
||||
},
|
||||
listTagsByShopId: (shopId: number) => {
|
||||
return adminApi.get<any[]>('/tag/list/by-shop/' + shopId)
|
||||
},
|
||||
createTag: (data: any) => {
|
||||
return adminApi.post('/tag/create', data)
|
||||
},
|
||||
updateTag: (id: number, data: any) => {
|
||||
return adminApi.put(`/tag/update/${id}`, data)
|
||||
},
|
||||
deleteTag: (id: number) => {
|
||||
return adminApi.delete(`/tag/delete/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export const adminArtistApi = {
|
||||
listArtists: (shopId?: number) => {
|
||||
return adminApi.get<UserVO[]>('/user/list', { params: { shopId, type: 3 } })
|
||||
}
|
||||
}
|
||||
|
||||
export const adminCouponApi = {
|
||||
listAllCoupons: (shopId?: number) => {
|
||||
return adminApi.get<any[]>('/coupon/list', { params: { page: 1, size: 100, shopId } })
|
||||
},
|
||||
createCoupon: (data: any, shopId: number) => {
|
||||
return adminApi.post('/coupon/create', data, { params: { shopId } })
|
||||
},
|
||||
updateCoupon: (id: number, data: any, shopId: number) => {
|
||||
return adminApi.put(`/coupon/update/${id}`, data, { params: { shopId } })
|
||||
},
|
||||
deleteCoupon: (id: number, shopId: number) => {
|
||||
return adminApi.delete(`/coupon/delete/${id}`, { params: { shopId } })
|
||||
},
|
||||
distributeCoupon: (data: { couponId: number; userIds: number[]; quantity: number }, shopId: number) => {
|
||||
// 构建查询字符串,确保userIds以正确的格式传递
|
||||
let queryString = `couponId=${data.couponId}&quantity=${data.quantity}&shopId=${shopId}`;
|
||||
if (data.userIds && data.userIds.length > 0) {
|
||||
data.userIds.forEach(userId => {
|
||||
queryString += `&userIds=${userId}`;
|
||||
});
|
||||
}
|
||||
return adminApi.post(`/coupon/distribute?${queryString}`)
|
||||
export const adminDashboardApi = {
|
||||
getStats: () => {
|
||||
return adminApi.get<DashboardStats>('/dashboard/stats')
|
||||
}
|
||||
}
|
||||
|
||||
export { adminApi }
|
||||
export default adminApi
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import api from './index'
|
||||
import { adminApi } from './admin'
|
||||
|
||||
export interface PermissionVO {
|
||||
id: number
|
||||
@@ -27,28 +27,28 @@ export interface UpdatePermissionRequest {
|
||||
export const permissionApi = {
|
||||
getUserPermissions: (userId?: number) => {
|
||||
if (userId) {
|
||||
return api.get<PermissionVO[]>(`/admin/permission/user/${userId}`)
|
||||
return adminApi.get<PermissionVO[]>(`/permission/user/${userId}`)
|
||||
}
|
||||
return api.get<PermissionVO[]>('/admin/permission/user/current')
|
||||
return adminApi.get<PermissionVO[]>('/permission/user/current')
|
||||
},
|
||||
|
||||
listAllPermissions: () => {
|
||||
return api.get<PermissionVO[]>('/admin/permission/list/all')
|
||||
return adminApi.get<PermissionVO[]>('/permission/list/all')
|
||||
},
|
||||
|
||||
createPermission: (data: CreatePermissionRequest) => {
|
||||
return api.post('/admin/permission/create', data)
|
||||
return adminApi.post('/permission/create', data)
|
||||
},
|
||||
|
||||
updatePermission: (id: number, data: UpdatePermissionRequest) => {
|
||||
return api.put(`/admin/permission/update/${id}`, data)
|
||||
return adminApi.put(`/permission/update/${id}`, data)
|
||||
},
|
||||
|
||||
deletePermission: (id: number) => {
|
||||
return api.delete(`/admin/permission/delete/${id}`)
|
||||
return adminApi.delete(`/permission/delete/${id}`)
|
||||
},
|
||||
|
||||
assignUserPermissions: (userId: number, permissionIds: number[]) => {
|
||||
return api.post(`/admin/permission/assign/${userId}`, { permissionIds })
|
||||
return adminApi.post(`/permission/assign/${userId}`, { permissionIds })
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -16,6 +16,7 @@ declare module 'vue' {
|
||||
ABadge: typeof import('ant-design-vue/es')['Badge']
|
||||
AButton: typeof import('ant-design-vue/es')['Button']
|
||||
ACard: typeof import('ant-design-vue/es')['Card']
|
||||
ACarousel: typeof import('ant-design-vue/es')['Carousel']
|
||||
ACheckbox: typeof import('ant-design-vue/es')['Checkbox']
|
||||
ACheckboxGroup: typeof import('ant-design-vue/es')['CheckboxGroup']
|
||||
ACol: typeof import('ant-design-vue/es')['Col']
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { permissionApi } from '@/api/admin'
|
||||
import { permissionApi } from '@/api/permission'
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
const userPermissions = ref<string[]>([])
|
||||
|
||||
+121
-18
@@ -38,17 +38,24 @@
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<!-- Banner 区域 -->
|
||||
<div class="banner" @click="handleBannerClick">
|
||||
<div class="banner-content">
|
||||
<a-tag color="red" class="banner-tag">限时优惠</a-tag>
|
||||
<h3>Get Winter Discount</h3>
|
||||
<h2>20% Off</h2>
|
||||
<p>For Children</p>
|
||||
<a-button type="primary" size="small" class="banner-btn">立即购买</a-button>
|
||||
</div>
|
||||
<div class="banner-image">
|
||||
<div class="img-placeholder">Banner</div>
|
||||
<!-- Banner 轮播区域 -->
|
||||
<div class="banner-carousel">
|
||||
<a-carousel v-if="bannerImages.length > 0" autoplay :autoplay-speed="3000" effect="fade">
|
||||
<div v-for="(image, index) in bannerImages" :key="index" class="banner-slide" @click="handleBannerClick">
|
||||
<img :src="image" alt="Banner" class="banner-img" />
|
||||
</div>
|
||||
</a-carousel>
|
||||
<div v-else class="banner" @click="handleBannerClick">
|
||||
<div class="banner-content">
|
||||
<a-tag color="red" class="banner-tag">限时优惠</a-tag>
|
||||
<h3>Get Winter Discount</h3>
|
||||
<h2>20% Off</h2>
|
||||
<p>For Children</p>
|
||||
<a-button type="primary" size="small" class="banner-btn">立即购买</a-button>
|
||||
</div>
|
||||
<div class="banner-image">
|
||||
<div class="img-placeholder">Banner</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -130,6 +137,8 @@ import {
|
||||
} from '@ant-design/icons-vue'
|
||||
import { userApi, type UserVO } from '../api/user'
|
||||
import { productApi } from '../api/product'
|
||||
import { shopApi, type ShopVO } from '../api/shop'
|
||||
import { fileApi } from '../api/file'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -148,6 +157,9 @@ const userInfo = ref<UserVO>({
|
||||
// 搜索关键词
|
||||
const searchQuery = ref('')
|
||||
|
||||
// Banner图片数据
|
||||
const bannerImages = ref<string[]>([])
|
||||
|
||||
// 精选商品数据
|
||||
const featuredItems = ref<any[]>([])
|
||||
|
||||
@@ -168,6 +180,56 @@ const loadUserInfo = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载Banner图片
|
||||
const loadBannerImages = async () => {
|
||||
try {
|
||||
const fileIdPromises: Promise<string>[] = []
|
||||
|
||||
// 从店铺获取图片
|
||||
const shops = await shopApi.getAllShops() as ShopVO[]
|
||||
console.log('店铺数量:', shops.length)
|
||||
console.log('店铺数据:', shops)
|
||||
|
||||
// 处理店铺图片 - 只使用coverImageFileId(banner图片)
|
||||
for (const shop of shops) {
|
||||
// 处理coverImageFileId(专门用于banner的图片)
|
||||
if (shop.coverImageFileId) {
|
||||
const fileIds = shop.coverImageFileId.split(',').filter(id => id.trim())
|
||||
for (const idStr of fileIds) {
|
||||
const fileId = parseInt(idStr)
|
||||
if (!isNaN(fileId)) {
|
||||
const promise = fileApi.getSignedUrl(fileId).catch(err => {
|
||||
console.error('获取店铺banner图签名失败:', err)
|
||||
return null
|
||||
})
|
||||
fileIdPromises.push(promise)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 并行请求所有签名URL
|
||||
const results = await Promise.all(fileIdPromises)
|
||||
console.log('原始请求结果:', results)
|
||||
|
||||
// 过滤掉null值并去除反引号
|
||||
const filteredResults = results.filter((url): url is string => url !== null).map(url => url.replace(/[`]/g, '').trim())
|
||||
console.log('过滤后结果:', filteredResults)
|
||||
|
||||
// 去重
|
||||
const uniqueImages = [...new Set(filteredResults)]
|
||||
console.log('去重后结果:', uniqueImages)
|
||||
console.log('去重后数量:', uniqueImages.length)
|
||||
|
||||
// 限制数量并更新bannerImages
|
||||
bannerImages.value = uniqueImages.slice(0, 10) // 最多显示10张
|
||||
console.log('Banner图片数量:', bannerImages.value.length)
|
||||
console.log('Banner图片列表:', bannerImages.value)
|
||||
} catch (error) {
|
||||
console.error('获取Banner图片失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载精选商品
|
||||
const loadFeaturedProducts = async () => {
|
||||
try {
|
||||
@@ -245,6 +307,7 @@ const handleScroll = () => {
|
||||
// 添加滚动监听
|
||||
onMounted(() => {
|
||||
loadUserInfo()
|
||||
loadBannerImages()
|
||||
loadFeaturedProducts()
|
||||
loadPopularProducts()
|
||||
window.addEventListener('scroll', handleScroll)
|
||||
@@ -261,13 +324,6 @@ const getRandomColor = () => {
|
||||
return colors[Math.floor(Math.random() * colors.length)]
|
||||
}
|
||||
|
||||
// 页面加载时获取数据
|
||||
onMounted(() => {
|
||||
loadUserInfo()
|
||||
loadFeaturedProducts()
|
||||
loadPopularProducts()
|
||||
})
|
||||
|
||||
// 处理用户头像点击
|
||||
const handleUserClick = () => {
|
||||
console.log('用户头像被点击')
|
||||
@@ -376,6 +432,53 @@ const handleProductClick = (item: any) => {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Banner轮播区域 */
|
||||
.banner-carousel {
|
||||
margin: 15px 20px;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.banner-carousel :deep(.ant-carousel) {
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.banner-slide {
|
||||
width: 100%;
|
||||
height: 180px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.banner-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
/* 轮播指示器样式 */
|
||||
.banner-carousel :deep(.slick-dots) {
|
||||
bottom: 12px;
|
||||
}
|
||||
|
||||
.banner-carousel :deep(.slick-dots li) {
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
.banner-carousel :deep(.slick-dots li button) {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.banner-carousel :deep(.slick-dots li.slick-active button) {
|
||||
width: 20px;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.banner {
|
||||
margin: 15px 20px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
|
||||
@@ -16,8 +16,14 @@
|
||||
<ShopOutlined class="shop-icon" />
|
||||
</div>
|
||||
<div class="shop-header-content">
|
||||
<h2 class="shop-name">{{ shopInfo.shopName }}</h2>
|
||||
<p class="shop-address">{{ shopInfo.address }}</p>
|
||||
<h2 class="shop-name" @click="copyToClipboard(shopInfo.shopName, '店名')" style="cursor: pointer;">
|
||||
{{ shopInfo.shopName }}
|
||||
<span class="copy-icon">📋</span>
|
||||
</h2>
|
||||
<p class="shop-address" @click="copyToClipboard(shopInfo.address, '地址')" style="cursor: pointer;">
|
||||
{{ shopInfo.address }}
|
||||
<span class="copy-icon">📋</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shop-details">
|
||||
@@ -30,19 +36,27 @@
|
||||
<div class="detail-value">{{ shopInfo.description }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 店铺环境图轮播 -->
|
||||
<div class="shop-images" v-if="shopImages.length > 0">
|
||||
<h3 class="section-title">店铺图片</h3>
|
||||
<div class="image-grid">
|
||||
<a-image
|
||||
v-for="(url, index) in shopImages"
|
||||
:key="index"
|
||||
:width="100"
|
||||
:height="100"
|
||||
:src="url"
|
||||
style="object-fit: cover; border-radius: 4px; margin: 4px;"
|
||||
/>
|
||||
<h3 class="section-title">店铺环境图</h3>
|
||||
<div class="image-carousel">
|
||||
<a-carousel autoplay :autoplay-speed="3000" effect="slide" dots>
|
||||
<div v-for="(url, index) in shopImages" :key="index" class="carousel-item" @click="showImageModal(url)">
|
||||
<img :src="url" :alt="`店铺环境图 ${index + 1}`" class="carousel-image" />
|
||||
</div>
|
||||
</a-carousel>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 图片查看模态框 -->
|
||||
<a-modal
|
||||
v-model:open="imageModalVisible"
|
||||
title="店铺环境图"
|
||||
:width="800"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<img :src="selectedImage" alt="店铺环境图" class="modal-image" />
|
||||
</a-modal>
|
||||
</div>
|
||||
</a-card>
|
||||
</div>
|
||||
@@ -53,8 +67,9 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { fileApi } from '@/api/file'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
@@ -72,13 +87,72 @@ const shopInfo = ref<ShopVO>({
|
||||
|
||||
const shopImages = ref<string[]>([])
|
||||
|
||||
// 图片模态框
|
||||
const imageModalVisible = ref(false)
|
||||
const selectedImage = ref('')
|
||||
|
||||
const handleBackClick = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
// 显示图片模态框
|
||||
const showImageModal = (imageUrl: string) => {
|
||||
selectedImage.value = imageUrl
|
||||
imageModalVisible.value = true
|
||||
}
|
||||
|
||||
// 关闭图片模态框
|
||||
const handleCancel = () => {
|
||||
imageModalVisible.value = false
|
||||
selectedImage.value = ''
|
||||
}
|
||||
|
||||
// 复制到剪贴板
|
||||
const copyToClipboard = async (text: string, type: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
message.success(`${type}已复制到剪贴板`)
|
||||
} catch (err) {
|
||||
console.error('复制失败:', err)
|
||||
message.error('复制失败,请手动复制')
|
||||
}
|
||||
}
|
||||
|
||||
const loadShopImages = async () => {
|
||||
// 由于ShopVO类型中没有imageFileIds属性,这里简化处理
|
||||
shopImages.value = []
|
||||
try {
|
||||
console.log('开始加载店铺环境图')
|
||||
const imageFileIds = shopInfo.value.imageFileIds
|
||||
console.log('imageFileIds:', imageFileIds)
|
||||
|
||||
if (imageFileIds) {
|
||||
const fileIds = imageFileIds.split(',').filter(id => id.trim())
|
||||
console.log('分割后的fileIds:', fileIds)
|
||||
|
||||
const fileIdPromises = fileIds.map(idStr => {
|
||||
const fileId = parseInt(idStr)
|
||||
console.log('处理fileId:', fileId)
|
||||
if (!isNaN(fileId)) {
|
||||
return fileApi.getSignedUrl(fileId).catch(err => {
|
||||
console.error('获取店铺环境图签名失败:', err)
|
||||
return null
|
||||
})
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
||||
const results = await Promise.all(fileIdPromises)
|
||||
console.log('签名URL请求结果:', results)
|
||||
|
||||
const filteredResults = results.filter((url): url is string => url !== null).map(url => url.replace(/[`]/g, '').trim())
|
||||
console.log('过滤后结果:', filteredResults)
|
||||
console.log('过滤后数量:', filteredResults.length)
|
||||
|
||||
shopImages.value = filteredResults
|
||||
console.log('shopImages最终值:', shopImages.value)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载店铺环境图失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const fetchShopDetail = async () => {
|
||||
@@ -91,8 +165,12 @@ const fetchShopDetail = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
console.log('请求店铺详情,shopId:', shopId)
|
||||
const response = await shopApi.getShopById(Number(shopId)) as any
|
||||
console.log('店铺详情响应:', response)
|
||||
|
||||
shopInfo.value = response || {}
|
||||
console.log('shopInfo.value:', shopInfo.value)
|
||||
|
||||
// 加载店铺图片
|
||||
await loadShopImages()
|
||||
@@ -219,6 +297,19 @@ onMounted(() => {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.copy-icon {
|
||||
font-size: 12px;
|
||||
margin-left: 6px;
|
||||
opacity: 0.6;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.shop-name:hover .copy-icon,
|
||||
.shop-address:hover .copy-icon {
|
||||
opacity: 1;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.shop-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -250,9 +341,63 @@ onMounted(() => {
|
||||
margin: 0 0 12px 0;
|
||||
}
|
||||
|
||||
.image-grid {
|
||||
.image-carousel {
|
||||
margin: 12px 0;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.carousel-item {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.carousel-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.carousel-item:hover .carousel-image {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
/* 轮播指示器样式 */
|
||||
.image-carousel :deep(.slick-dots) {
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
.image-carousel :deep(.slick-dots li) {
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
.image-carousel :deep(.slick-dots li button) {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.image-carousel :deep(.slick-dots li.slick-active button) {
|
||||
width: 20px;
|
||||
border-radius: 4px;
|
||||
background: #667eea;
|
||||
}
|
||||
|
||||
.modal-image {
|
||||
width: 100%;
|
||||
max-height: 600px;
|
||||
object-fit: contain;
|
||||
border-radius: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -457,9 +457,15 @@ const fetchCoupons = async () => {
|
||||
const currentUser = getCurrentUserInfo()
|
||||
const shopId = (currentUser && currentUser.shopId) ? currentUser.shopId : undefined
|
||||
const res = await adminCouponApi.listAllCoupons(shopId)
|
||||
// 处理后端返回的分页数据结构
|
||||
couponList.value = res?.list || []
|
||||
pagination.total = res?.total || 0
|
||||
// 后端返回的是数组,直接使用
|
||||
if (Array.isArray(res)) {
|
||||
couponList.value = res
|
||||
pagination.total = res.length
|
||||
} else {
|
||||
// 兼容分页数据结构
|
||||
couponList.value = res?.list || []
|
||||
pagination.total = res?.total || 0
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('获取优惠券列表失败')
|
||||
} finally {
|
||||
|
||||
@@ -69,7 +69,8 @@
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { DashboardOutlined, UserOutlined, ShopOutlined, SafetyCertificateOutlined, HomeOutlined } from '@ant-design/icons-vue'
|
||||
import { userApi, type UserVO, permissionApi, type PermissionVO } from '@/api/admin'
|
||||
import { userApi, type UserVO } from '@/api/admin'
|
||||
import { permissionApi, type PermissionVO } from '@/api/permission'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
import { message } from 'ant-design-vue'
|
||||
|
||||
|
||||
@@ -178,7 +178,8 @@ import { message } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
import { permissionApi, type PermissionVO, userApi, type UserVO } from '@/api/admin'
|
||||
import { userApi, type UserVO } from '@/api/admin'
|
||||
import { permissionApi, type PermissionVO } from '@/api/permission'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
|
||||
@@ -50,6 +50,20 @@
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'banner'">
|
||||
<div class="shop-banner">
|
||||
<a-image
|
||||
v-for="(url, index) in getShopBannerImages(record)"
|
||||
:key="index"
|
||||
:width="80"
|
||||
:height="40"
|
||||
:src="url"
|
||||
style="object-fit: cover; border-radius: 4px; margin-right: 4px;"
|
||||
:preview="false"
|
||||
/>
|
||||
<span v-if="getShopBannerImages(record).length === 0" class="no-banner">暂无Banner</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button v-if="hasPermission('shop:view')" type="link" size="small" @click="showViewModal(record)">
|
||||
@@ -76,7 +90,7 @@
|
||||
<a-modal
|
||||
v-model:open="modalVisible"
|
||||
:title="isEdit ? '编辑店铺' : '新增店铺'"
|
||||
width="600px"
|
||||
width="700px"
|
||||
@ok="handleModalOk"
|
||||
@cancel="handleModalCancel"
|
||||
:confirmLoading="modalLoading"
|
||||
@@ -104,7 +118,28 @@
|
||||
<a-form-item label="营业时间" name="businessHours">
|
||||
<a-input v-model:value="formState.businessHours" placeholder="例如:09:00-21:00" />
|
||||
</a-form-item>
|
||||
<a-form-item label="Banner图片">
|
||||
<div class="upload-tip">首页轮播图,建议尺寸 750x300 像素</div>
|
||||
<a-upload
|
||||
v-model:file-list="bannerFileList"
|
||||
list-type="picture-card"
|
||||
:custom-request="handleUploadBanner"
|
||||
:before-upload="beforeUpload"
|
||||
@preview="handleBannerPreview"
|
||||
@remove="handleBannerRemove"
|
||||
:max-count="5"
|
||||
>
|
||||
<div v-if="bannerFileList.length < 5">
|
||||
<plus-outlined />
|
||||
<div style="margin-top: 8px">上传Banner</div>
|
||||
</div>
|
||||
</a-upload>
|
||||
<a-modal v-model:open="bannerPreviewVisible" :footer="null" @cancel="bannerPreviewVisible = false">
|
||||
<img alt="预览" style="width: 100%" :src="bannerPreviewImage" />
|
||||
</a-modal>
|
||||
</a-form-item>
|
||||
<a-form-item label="店铺图片">
|
||||
<div class="upload-tip">店铺详情展示图</div>
|
||||
<a-upload
|
||||
v-model:file-list="imageFileList"
|
||||
list-type="picture-card"
|
||||
@@ -130,7 +165,7 @@
|
||||
<a-modal
|
||||
v-model:open="viewModalVisible"
|
||||
title="查看店铺详情"
|
||||
width="600px"
|
||||
width="700px"
|
||||
@cancel="handleViewModalCancel"
|
||||
>
|
||||
<a-form
|
||||
@@ -154,6 +189,20 @@
|
||||
<a-form-item label="营业时间">
|
||||
<a-input v-model:value="viewFormState.businessHours" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="Banner图片">
|
||||
<div class="shop-images">
|
||||
<a-image
|
||||
v-for="(url, index) in viewBannerUrls"
|
||||
:key="index"
|
||||
:width="120"
|
||||
:height="60"
|
||||
:src="url"
|
||||
style="object-fit: cover; border-radius: 4px; margin-right: 8px; margin-bottom: 8px;"
|
||||
:preview="false"
|
||||
/>
|
||||
<span v-if="viewBannerUrls.length === 0" class="no-banner">暂无Banner</span>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="店铺图片">
|
||||
<div class="shop-images">
|
||||
<a-image
|
||||
@@ -165,6 +214,14 @@
|
||||
style="object-fit: cover; border-radius: 4px; margin-right: 8px; margin-bottom: 8px;"
|
||||
:preview="false"
|
||||
/>
|
||||
<a-image
|
||||
v-if="viewImageUrls.length === 0"
|
||||
:width="80"
|
||||
:height="80"
|
||||
:src="DEFAULT_SHOP_IMAGE"
|
||||
style="object-fit: cover; border-radius: 4px;"
|
||||
:preview="false"
|
||||
/>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
@@ -194,12 +251,20 @@ const formRef = ref<FormInstance>()
|
||||
const currentShop = ref<Shop | null>(null)
|
||||
const isAdmin = ref(false)
|
||||
|
||||
// 图片相关
|
||||
// Banner图片相关
|
||||
const bannerFileList = ref<any[]>([])
|
||||
const uploadedBannerIds = ref<string[]>([])
|
||||
const bannerPreviewVisible = ref(false)
|
||||
const bannerPreviewImage = ref('')
|
||||
|
||||
// 店铺图片相关
|
||||
const imageFileList = ref<any[]>([])
|
||||
const uploadedFileIds = ref<string[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const shopImageUrls = ref<Record<number, string[]>>({})
|
||||
const shopBannerUrls = ref<Record<number, string[]>>({})
|
||||
const viewImageUrls = ref<string[]>([])
|
||||
const viewBannerUrls = ref<string[]>([])
|
||||
const previewVisible = ref(false)
|
||||
const previewImage = ref('')
|
||||
|
||||
@@ -209,6 +274,7 @@ const viewFormState = reactive({
|
||||
description: '',
|
||||
address: '',
|
||||
businessHours: '',
|
||||
coverImageFileId: '',
|
||||
imageFileIds: ''
|
||||
})
|
||||
|
||||
@@ -226,6 +292,7 @@ const formState = reactive({
|
||||
description: '',
|
||||
address: '',
|
||||
businessHours: '',
|
||||
coverImageFileId: '',
|
||||
imageFileIds: ''
|
||||
})
|
||||
|
||||
@@ -238,6 +305,7 @@ const formRules: any = {
|
||||
|
||||
const columns = [
|
||||
{ title: '图片', key: 'image', width: 150 },
|
||||
{ title: 'Banner', key: 'banner', width: 200 },
|
||||
{ title: '店铺名称', dataIndex: 'shopName', key: 'shopName' },
|
||||
{ title: '店铺描述', dataIndex: 'description', key: 'description' },
|
||||
{ title: '店铺地址', dataIndex: 'address', key: 'address' },
|
||||
@@ -263,6 +331,7 @@ const getCurrentUserInfo = () => {
|
||||
|
||||
const loadImageUrls = async (shops: Shop[]) => {
|
||||
for (const shop of shops) {
|
||||
// 加载店铺图片
|
||||
if (shop.imageFileIds) {
|
||||
const ids = shop.imageFileIds.split(',')
|
||||
const urls: string[] = []
|
||||
@@ -285,14 +354,45 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
|
||||
shopImageUrls.value[shop.id] = urls
|
||||
} else {
|
||||
shopImageUrls.value[shop.id] = [DEFAULT_SHOP_IMAGE]
|
||||
shopImageUrls.value[shop.id] = []
|
||||
}
|
||||
|
||||
// 加载Banner图片
|
||||
if (shop.coverImageFileId) {
|
||||
const ids = shop.coverImageFileId.split(',')
|
||||
const urls: string[] = []
|
||||
|
||||
for (const id of ids) {
|
||||
if (id) {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_SHOP_IMAGE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shopBannerUrls.value[shop.id] = urls
|
||||
} else {
|
||||
shopBannerUrls.value[shop.id] = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getShopImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
const shopId = 'id' in shop ? shop.id : (shop as any).id
|
||||
return shopImageUrls.value[shopId] || [DEFAULT_SHOP_IMAGE]
|
||||
return shopImageUrls.value[shopId] || []
|
||||
}
|
||||
|
||||
const getShopBannerImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
const shopId = 'id' in shop ? shop.id : (shop as any).id
|
||||
return shopBannerUrls.value[shopId] || []
|
||||
}
|
||||
|
||||
const fetchShopList = async () => {
|
||||
@@ -346,6 +446,47 @@ const beforeUpload = (file: File) => {
|
||||
return isImage && isLt2M
|
||||
}
|
||||
|
||||
// Banner图片上传
|
||||
const handleUploadBanner = async (options: any) => {
|
||||
const { file, onSuccess, onError } = options
|
||||
try {
|
||||
const response = await adminFileApi.uploadFile(file)
|
||||
const res = typeof response === 'object' && 'id' in response ? response : (response as any).data
|
||||
uploadedBannerIds.value.push(String(res.id))
|
||||
formState.coverImageFileId = uploadedBannerIds.value.join(',')
|
||||
onSuccess({ url: String(res.id) })
|
||||
message.success('Banner上传成功')
|
||||
} catch (error) {
|
||||
console.error('Banner上传失败:', error)
|
||||
onError(error)
|
||||
message.error('Banner上传失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleBannerPreview = async (file: any) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[file.uid]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(file.uid)) as any
|
||||
imageIdCache.value[file.uid] = response
|
||||
}
|
||||
bannerPreviewImage.value = imageIdCache.value[file.uid] || ''
|
||||
bannerPreviewVisible.value = true
|
||||
} catch (error) {
|
||||
console.error('获取预览链接失败:', error)
|
||||
message.error('获取预览链接失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleBannerRemove = (file: any) => {
|
||||
const index = uploadedBannerIds.value.indexOf(file.uid)
|
||||
if (index > -1) {
|
||||
uploadedBannerIds.value.splice(index, 1)
|
||||
formState.coverImageFileId = uploadedBannerIds.value.join(',')
|
||||
}
|
||||
}
|
||||
|
||||
// 店铺图片上传
|
||||
const handleUploadImage = async (options: any) => {
|
||||
const { file, onSuccess, onError } = options
|
||||
try {
|
||||
@@ -392,8 +533,11 @@ const showAddModal = () => {
|
||||
description: '',
|
||||
address: '',
|
||||
businessHours: '',
|
||||
coverImageFileId: '',
|
||||
imageFileIds: ''
|
||||
})
|
||||
bannerFileList.value = []
|
||||
uploadedBannerIds.value = []
|
||||
imageFileList.value = []
|
||||
uploadedFileIds.value = []
|
||||
modalVisible.value = true
|
||||
@@ -407,9 +551,48 @@ const showEditModal = async (record: Shop | Record<string, any>) => {
|
||||
description: 'description' in record ? record.description : (record as any).description,
|
||||
address: 'address' in record ? record.address : (record as any).address,
|
||||
businessHours: 'businessHours' in record ? record.businessHours : (record as any).businessHours,
|
||||
coverImageFileId: 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId,
|
||||
imageFileIds: 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||||
})
|
||||
|
||||
// 加载Banner图片
|
||||
const coverImageFileId = 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId
|
||||
if (coverImageFileId) {
|
||||
const ids = coverImageFileId.split(',')
|
||||
uploadedBannerIds.value = ids
|
||||
|
||||
// 加载所有图片签名链接
|
||||
const fileList = []
|
||||
for (const [index, id] of ids.entries()) {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
fileList.push({
|
||||
uid: id,
|
||||
name: `Banner${index + 1}`,
|
||||
status: 'done',
|
||||
url: imageIdCache.value[id]
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
fileList.push({
|
||||
uid: id,
|
||||
name: `Banner${index + 1}`,
|
||||
status: 'done',
|
||||
url: ''
|
||||
})
|
||||
}
|
||||
}
|
||||
bannerFileList.value = fileList
|
||||
} else {
|
||||
bannerFileList.value = []
|
||||
uploadedBannerIds.value = []
|
||||
}
|
||||
|
||||
// 加载店铺图片
|
||||
const imageFileIds = 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||||
if (imageFileIds) {
|
||||
const ids = imageFileIds.split(',')
|
||||
@@ -455,11 +638,36 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
|
||||
description: 'description' in record ? record.description : (record as any).description,
|
||||
address: 'address' in record ? record.address : (record as any).address,
|
||||
businessHours: 'businessHours' in record ? record.businessHours : (record as any).businessHours,
|
||||
coverImageFileId: 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId,
|
||||
imageFileIds: 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||||
})
|
||||
|
||||
// 加载Banner图片URL
|
||||
const coverImageFileId = 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId
|
||||
if (coverImageFileId) {
|
||||
const ids = coverImageFileId.split(',')
|
||||
const urls: string[] = []
|
||||
|
||||
for (const id of ids) {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_SHOP_IMAGE)
|
||||
}
|
||||
}
|
||||
viewBannerUrls.value = urls
|
||||
} else {
|
||||
viewBannerUrls.value = []
|
||||
}
|
||||
|
||||
// 加载店铺图片URL
|
||||
const imageFileIds = 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||||
// 加载图片URL
|
||||
if (imageFileIds) {
|
||||
const ids = imageFileIds.split(',')
|
||||
const urls: string[] = []
|
||||
@@ -479,7 +687,7 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
|
||||
}
|
||||
viewImageUrls.value = urls
|
||||
} else {
|
||||
viewImageUrls.value = [DEFAULT_SHOP_IMAGE]
|
||||
viewImageUrls.value = []
|
||||
}
|
||||
|
||||
viewModalVisible.value = true
|
||||
@@ -488,6 +696,7 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
|
||||
const handleViewModalCancel = () => {
|
||||
viewModalVisible.value = false
|
||||
viewImageUrls.value = []
|
||||
viewBannerUrls.value = []
|
||||
}
|
||||
|
||||
const handleModalOk = async () => {
|
||||
@@ -515,6 +724,8 @@ const handleModalOk = async () => {
|
||||
const handleModalCancel = () => {
|
||||
modalVisible.value = false
|
||||
formRef.value?.resetFields()
|
||||
bannerFileList.value = []
|
||||
uploadedBannerIds.value = []
|
||||
imageFileList.value = []
|
||||
uploadedFileIds.value = []
|
||||
}
|
||||
@@ -548,12 +759,21 @@ onMounted(async () => {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.shop-images :deep(.ant-image) {
|
||||
border-radius: 4px;
|
||||
.shop-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
:deep(.ant-upload-list-picture-card .ant-upload-list-item) {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
.no-banner {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
+7
@@ -2,6 +2,7 @@ package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.LoginRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.RefreshTokenRequestDTO;
|
||||
import com.xiaowang.yuminailcore.service.UserService;
|
||||
import com.xiaowang.yuminailcore.vo.LoginResponseVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -24,4 +25,10 @@ public class AdminAuthController {
|
||||
public Result<Boolean> logout() {
|
||||
return Result.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/refresh")
|
||||
public Result<LoginResponseVO> refreshToken(@RequestBody RefreshTokenRequestDTO refreshTokenRequestDTO) {
|
||||
LoginResponseVO loginResponseVO = userService.refreshToken(refreshTokenRequestDTO.getRefreshToken());
|
||||
return Result.success(loginResponseVO);
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -71,6 +71,16 @@ public class AdminCouponController {
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有优惠券
|
||||
*/
|
||||
@GetMapping("/list/all")
|
||||
@RequirePermission("coupon:view")
|
||||
public Result<List<CouponVO>> listAllCoupons() {
|
||||
List<CouponVO> coupons = couponService.listAllCoupons();
|
||||
return Result.success(coupons);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为用户分配优惠券
|
||||
*/
|
||||
|
||||
+9
@@ -9,6 +9,8 @@ import com.xiaowang.yuminailcore.vo.ProductVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/product")
|
||||
@RequiredArgsConstructor
|
||||
@@ -48,4 +50,11 @@ public class AdminProductController {
|
||||
boolean success = productService.deleteProduct(id);
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
@GetMapping("/list/all")
|
||||
@RequirePermission("product:view")
|
||||
public Result<List<ProductVO>> listAllProducts() {
|
||||
List<ProductVO> products = productService.listAllProducts();
|
||||
return Result.success(products);
|
||||
}
|
||||
}
|
||||
|
||||
+32
@@ -11,6 +11,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/user")
|
||||
@@ -75,6 +77,36 @@ public class AdminUserController {
|
||||
return Result.success(userVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有用户
|
||||
* @return 用户列表
|
||||
*/
|
||||
@GetMapping("/list/all")
|
||||
@RequirePermission("user:view")
|
||||
public Result<List<UserVO>> listAllUsers() {
|
||||
List<UserVO> users = userService.listAllUsers();
|
||||
return Result.success(users);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取美甲师列表
|
||||
* @param shopId 店铺ID(可选)
|
||||
* @return 美甲师列表
|
||||
*/
|
||||
@GetMapping("/list/artists")
|
||||
@RequirePermission("user:view")
|
||||
public Result<List<UserVO>> listArtists(@RequestParam(required = false) Long shopId) {
|
||||
// 用户类型 3 表示美甲师
|
||||
List<UserVO> artists = userService.listUsersByType(3);
|
||||
// 如果指定了店铺ID,则过滤该店铺的美甲师
|
||||
if (shopId != null) {
|
||||
artists = artists.stream()
|
||||
.filter(artist -> shopId.equals(artist.getShopId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return Result.success(artists);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class StatusRequest {
|
||||
private Integer status;
|
||||
|
||||
@@ -32,6 +32,11 @@ public class ShopDTO {
|
||||
*/
|
||||
private String businessHours;
|
||||
|
||||
/**
|
||||
* 店铺封面图文件ID集合(Banner图),多个ID以逗号分隔
|
||||
*/
|
||||
private String coverImageFileId;
|
||||
|
||||
/**
|
||||
* 店铺图片文件ID集合,多个ID以逗号分隔
|
||||
*/
|
||||
|
||||
@@ -42,6 +42,12 @@ public class ShopDO extends BaseEntity {
|
||||
@TableField("business_hours")
|
||||
private String businessHours;
|
||||
|
||||
/**
|
||||
* 店铺封面图文件ID集合(Banner图),多个ID以逗号分隔
|
||||
*/
|
||||
@TableField("cover_image_file_id")
|
||||
private String coverImageFileId;
|
||||
|
||||
/**
|
||||
* 店铺图片文件ID集合,多个ID以逗号分隔
|
||||
*/
|
||||
|
||||
@@ -54,6 +54,12 @@ public interface CouponService extends IService<CouponDO> {
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<CouponVO> listCoupons(Integer page, Integer size, Long shopId);
|
||||
|
||||
/**
|
||||
* 获取所有优惠券
|
||||
* @return 优惠券列表
|
||||
*/
|
||||
List<CouponVO> listAllCoupons();
|
||||
|
||||
/**
|
||||
* 为用户分配优惠券
|
||||
|
||||
+12
-1
@@ -134,7 +134,18 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, CouponDO> imple
|
||||
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<CouponVO> listAllCoupons() {
|
||||
List<CouponDO> couponDOs = list(new LambdaQueryWrapper<CouponDO>()
|
||||
.eq(CouponDO::getIsDelete, 0)
|
||||
.orderByDesc(CouponDO::getCreateTime)
|
||||
);
|
||||
return couponDOs.stream()
|
||||
.map(this::convertToCouponVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean assignCouponToUser(Long userId, Long couponId, Long shopId) {
|
||||
|
||||
+4
@@ -37,6 +37,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
shopDO.setDescription(shopDTO.getDescription());
|
||||
shopDO.setAddress(shopDTO.getAddress());
|
||||
shopDO.setBusinessHours(shopDTO.getBusinessHours());
|
||||
shopDO.setCoverImageFileId(shopDTO.getCoverImageFileId());
|
||||
shopDO.setImageFileIds(shopDTO.getImageFileIds());
|
||||
shopDO.setIsDelete(0);
|
||||
shopMapper.insert(shopDO);
|
||||
@@ -53,6 +54,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
shopDO.setDescription(shopDTO.getDescription());
|
||||
shopDO.setAddress(shopDTO.getAddress());
|
||||
shopDO.setBusinessHours(shopDTO.getBusinessHours());
|
||||
shopDO.setCoverImageFileId(shopDTO.getCoverImageFileId());
|
||||
shopDO.setImageFileIds(shopDTO.getImageFileIds());
|
||||
return shopMapper.updateById(shopDO) > 0;
|
||||
}
|
||||
@@ -137,6 +139,8 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
shopVO.setDescription(shopDO.getDescription());
|
||||
shopVO.setAddress(shopDO.getAddress());
|
||||
shopVO.setBusinessHours(shopDO.getBusinessHours());
|
||||
shopVO.setCoverImageFileId(shopDO.getCoverImageFileId());
|
||||
shopVO.setCoverImageUrls(new java.util.ArrayList<>());
|
||||
shopVO.setImageFileIds(shopDO.getImageFileIds());
|
||||
shopVO.setImageUrls(new java.util.ArrayList<>());
|
||||
shopVO.setCreateTime(shopDO.getCreateTime());
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.xiaowang.yuminailcore.vo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺信息表 VO
|
||||
@@ -39,6 +40,16 @@ public class ShopVO {
|
||||
*/
|
||||
private String businessHours;
|
||||
|
||||
/**
|
||||
* 店铺封面图文件ID集合(Banner图),多个ID以逗号分隔
|
||||
*/
|
||||
private String coverImageFileId;
|
||||
|
||||
/**
|
||||
* 店铺封面图URL列表(Banner图)
|
||||
*/
|
||||
private List<String> coverImageUrls;
|
||||
|
||||
/**
|
||||
* 店铺图片文件ID集合,多个ID以逗号分隔
|
||||
*/
|
||||
@@ -47,7 +58,7 @@ public class ShopVO {
|
||||
/**
|
||||
* 店铺图片URL列表
|
||||
*/
|
||||
private java.util.List<String> imageUrls;
|
||||
private List<String> imageUrls;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
|
||||
@@ -75,7 +75,14 @@ spring:
|
||||
- Path=/api/wishlist/**
|
||||
filters:
|
||||
- RewritePath=/api/(?<remaining>.*), /${remaining}
|
||||
# 后台管理API路由
|
||||
# 后台管理API路由(/api/admin/** 格式)
|
||||
- id: admin-api-route
|
||||
uri: lb://yumi-nail-core
|
||||
predicates:
|
||||
- Path=/api/admin/**
|
||||
filters:
|
||||
- RewritePath=/api/admin/(?<remaining>.*), /admin/${remaining}
|
||||
# 后台管理API路由(/admin/api/** 格式)
|
||||
- id: admin-route
|
||||
uri: lb://yumi-nail-core
|
||||
predicates:
|
||||
|
||||
Reference in New Issue
Block a user