From 9a3253ad20fd384c3692941ea2fb44323bf6db00 Mon Sep 17 00:00:00 2001 From: dongshanshan Date: Tue, 31 Oct 2023 16:53:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=9A=E5=91=98=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mall/product/favorite.ts | 28 +++ src/hooks/web/useMessage.ts | 12 ++ src/locales/en.ts | 8 +- src/locales/zh-CN.ts | 8 +- .../member/user/detail/UserFavoriteList.vue | 195 ++++++++++++++++++ src/views/member/user/detail/index.vue | 5 +- 6 files changed, 253 insertions(+), 3 deletions(-) create mode 100644 src/api/mall/product/favorite.ts create mode 100644 src/views/member/user/detail/UserFavoriteList.vue diff --git a/src/api/mall/product/favorite.ts b/src/api/mall/product/favorite.ts new file mode 100644 index 00000000..2e54ec78 --- /dev/null +++ b/src/api/mall/product/favorite.ts @@ -0,0 +1,28 @@ +import request from '@/config/axios' + +export interface Favorite { + id?: number + userId?: string // 用户编号 + spuId?: number | null // 商品 SPU 编号 +} + +// 获得 ProductFavorite 列表 +export const getFavoritePage = (params: PageParam) => { + params.keyword = params.name + return request.get({ url: '/product/favorite/page', params }) +} + +// 收藏商品 Favorite +export const createFavorite = (data: Favorite) => { + return request.post({ url: '/product/favorite/create', data }) +} + +// 取消商品收藏 Favorite +export const delFavorite = (data: Favorite) => { + return request.delete({ url: '/product/favorite/delete', data }) +} + +// 是否收藏过商品 Favorite +export const exitsFavorite = (data: Favorite) => { + return request.post({ url: '/product/favorite/exits', data }) +} diff --git a/src/hooks/web/useMessage.ts b/src/hooks/web/useMessage.ts index ac2b552e..9bfb7a3a 100644 --- a/src/hooks/web/useMessage.ts +++ b/src/hooks/web/useMessage.ts @@ -90,6 +90,18 @@ export const useMessage = () => { cancelButtonText: t('common.cancel'), type: 'warning' }) + }, + // 取消收藏窗体 + delStarConfirm(content?: string, tip?: string) { + return ElMessageBox.confirm( + content ? content : t('common.confirmDelStar'), + tip ? tip : t('common.confirmTitle'), + { + confirmButtonText: t('common.ok'), + cancelButtonText: t('common.cancel'), + type: 'warning' + } + ) } } } diff --git a/src/locales/en.ts b/src/locales/en.ts index 4f4d4895..d82e616e 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -54,7 +54,13 @@ export default { updateTime: 'Update Time', copy: 'Copy', copySuccess: 'Copy Success', - copyError: 'Copy Error' + copyError: 'Copy Error', + confirmDelStar: 'Delete the Star?', + starSuccess: 'Star Success', + starFail: 'Star Error', + delStarSuccess: 'Del Star Success', + delStarFail: 'Del Star Error', + existStar: 'exist Star' }, error: { noPermission: `Sorry, you don't have permission to access this page.`, diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 4f95852f..49a3f895 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -54,7 +54,13 @@ export default { updateTime: '更新时间', copy: '复制', copySuccess: '复制成功', - copyError: '复制失败' + copyError: '复制失败', + confirmDelStar: '是否取消收藏?', + starSuccess: '收藏成功', + starFail: '收藏失败', + delStarSuccess: '取消收藏成功', + delStarFail: '取消收藏失败', + existStar: '收藏已存在' }, error: { noPermission: `抱歉,您无权访问此页面。`, diff --git a/src/views/member/user/detail/UserFavoriteList.vue b/src/views/member/user/detail/UserFavoriteList.vue new file mode 100644 index 00000000..009a8b10 --- /dev/null +++ b/src/views/member/user/detail/UserFavoriteList.vue @@ -0,0 +1,195 @@ + + + diff --git a/src/views/member/user/detail/index.vue b/src/views/member/user/detail/index.vue index 1bac010e..6237cca6 100644 --- a/src/views/member/user/detail/index.vue +++ b/src/views/member/user/detail/index.vue @@ -48,7 +48,9 @@ 售后管理(WIP) - 收藏记录(WIP) + + + @@ -76,6 +78,7 @@ import UserExperienceRecordList from './UserExperienceRecordList.vue' import UserOrderList from './UserOrderList.vue' import UserPointList from './UserPointList.vue' import UserSignList from './UserSignList.vue' +import UserFavoriteList from './UserFavoriteList.vue' import { CardTitle } from '@/components/Card/index' import { ElMessage } from 'element-plus'