From db313f4aa65d5dca664a58be72ffd677f95bb259 Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Fri, 16 Oct 2026 16:33:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E6=96=B0=E5=A2=9E=E5=95=86?= =?UTF-8?q?=E5=93=81=E9=85=8D=E7=BD=AE=E4=B8=8E=E7=B3=BB=E7=BB=9F=E5=85=AC?= =?UTF-8?q?=E5=91=8A=E4=B8=A4=E4=B8=AA=E5=90=8E=E5=8F=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - src/api/admin/product.ts、src/api/admin/notice.ts 对齐后端新接口 - ProductManagementView:列表/筛选/新建编辑/上下架/删除,新建默认下架有提示 - NoticeManagementView:列表/筛选/新建编辑/发布下架/删除 - 状态列一律用接口返回的 statusText,不在前端写死中文 - id 按字符串处理(雪花 id 超过 JS 安全整数范围,数字会被四舍五入) --- src/api/admin/notice.ts | 66 +++ src/api/admin/product.ts | 85 ++++ src/views/commerce/ProductManagementView.vue | 463 +++++++++++++++++++ src/views/operation/NoticeManagementView.vue | 354 ++++++++++++++ 4 files changed, 968 insertions(+) create mode 100644 src/api/admin/notice.ts create mode 100644 src/api/admin/product.ts create mode 100644 src/views/commerce/ProductManagementView.vue create mode 100644 src/views/operation/NoticeManagementView.vue diff --git a/src/api/admin/notice.ts b/src/api/admin/notice.ts new file mode 100644 index 0000000..d95d23d --- /dev/null +++ b/src/api/admin/notice.ts @@ -0,0 +1,66 @@ +// Author: fruit.com.cn + +import request from '@/axios' +import type { PageResult } from './types' + +/** 系统公告:字段与 /admin/notices 的响应一一对应 */ +export interface NoticeItem { + /** 雪花 id,后端以字符串下发(超过 JS 安全整数范围),原样回传即可 */ + id: string + title: string + content: string + /** ALL / USER / CREATOR */ + target: string + targetText: string + /** SYSTEM / AUDIT / PAYMENT / ACTIVITY */ + type: string + typeText: string + /** 1 已发布 / 0 已下架 */ + status: number + statusText: string + publishAt?: string + expireAt?: string + createdAt?: string +} + +export interface NoticePageParams { + pageIndex?: number + pageSize?: number + status?: number + target?: string + type?: string + keyword?: string +} + +export interface NoticeSaveData { + title: string + content: string + target: string + type: string + publishAt?: string | null + expireAt?: string | null +} + +export const pageNoticesApi = (params: NoticePageParams) => { + return request.get>({ url: '/admin/notices/page', params }) +} + +export const getNoticeApi = (id: string | number) => { + return request.get({ url: `/admin/notices/${id}` }) +} + +export const createNoticeApi = (data: NoticeSaveData) => { + return request.post({ url: '/admin/notices', data }) +} + +export const updateNoticeApi = (id: string | number, data: NoticeSaveData) => { + return request.put({ url: `/admin/notices/${id}`, data }) +} + +export const updateNoticeStatusApi = (id: string | number, status: number) => { + return request.put({ url: `/admin/notices/${id}/status`, params: { status } }) +} + +export const deleteNoticeApi = (id: string | number) => { + return request.delete({ url: `/admin/notices/${id}` }) +} diff --git a/src/api/admin/product.ts b/src/api/admin/product.ts new file mode 100644 index 0000000..391bcea --- /dev/null +++ b/src/api/admin/product.ts @@ -0,0 +1,85 @@ +// Author: fruit.com.cn + +import request from '@/axios' +import type { PageResult } from './types' + +/** 商品(金币包):字段与 /admin/products 的响应一一对应 */ +export interface ProductItem { + /** 雪花 id,后端以字符串下发(超过 JS 安全整数范围),原样回传即可 */ + id: string + code: string + name: string + /** COIN_PACK / VIP */ + type: string + typeText: string + /** ALL / GOOGLE / APPLE */ + platform: string + storeProductId: string + coinAmount: number + bonusCoin: number + /** coinAmount + bonusCoin,服务端算好,前端不再自己加 */ + totalCoin: number + priceAmount: number + currency: string + displayPrice: string + regionCodes: string + vipDays: number + sort: number + /** 1 已上架 / 0 已下架 */ + status: number + statusText: string + effectiveAt?: string + expireAt?: string + createdAt?: string +} + +export interface ProductPageParams { + pageIndex?: number + pageSize?: number + type?: string + status?: number + platform?: string + keyword?: string +} + +export interface ProductSaveData { + code: string + name: string + type: string + platform: string + storeProductId: string + coinAmount: number + bonusCoin: number + priceAmount: number + currency: string + displayPrice: string + regionCodes: string + vipDays: number + sort: number + effectiveAt?: string | null + expireAt?: string | null +} + +export const pageProductsApi = (params: ProductPageParams) => { + return request.get>({ url: '/admin/products/page', params }) +} + +export const getProductApi = (id: string | number) => { + return request.get({ url: `/admin/products/${id}` }) +} + +export const createProductApi = (data: ProductSaveData) => { + return request.post({ url: '/admin/products', data }) +} + +export const updateProductApi = (id: string | number, data: ProductSaveData) => { + return request.put({ url: `/admin/products/${id}`, data }) +} + +export const updateProductStatusApi = (id: string | number, status: number) => { + return request.put({ url: `/admin/products/${id}/status`, params: { status } }) +} + +export const deleteProductApi = (id: string | number) => { + return request.delete({ url: `/admin/products/${id}` }) +} diff --git a/src/views/commerce/ProductManagementView.vue b/src/views/commerce/ProductManagementView.vue new file mode 100644 index 0000000..26ba5e6 --- /dev/null +++ b/src/views/commerce/ProductManagementView.vue @@ -0,0 +1,463 @@ + + + + + diff --git a/src/views/operation/NoticeManagementView.vue b/src/views/operation/NoticeManagementView.vue new file mode 100644 index 0000000..6b775a1 --- /dev/null +++ b/src/views/operation/NoticeManagementView.vue @@ -0,0 +1,354 @@ + + + + +