From 9a3253ad20fd384c3692941ea2fb44323bf6db00 Mon Sep 17 00:00:00 2001 From: dongshanshan Date: Tue, 31 Oct 2023 16:53:44 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E4=BC=9A=E5=91=98=E5=95=86?= =?UTF-8?q?=E5=93=81=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' From f2c71d5836895b7d4ff6520388709f5426d88559 Mon Sep 17 00:00:00 2001 From: niou233 <2922564446@qq.com> Date: Wed, 8 Nov 2023 17:29:57 +0800 Subject: [PATCH 2/5] =?UTF-8?q?refactor:=20=E4=BC=9A=E5=91=98=E5=95=86?= =?UTF-8?q?=E5=93=81=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 | 16 --- .../member/user/detail/UserFavoriteList.vue | 99 ------------------- 2 files changed, 115 deletions(-) diff --git a/src/api/mall/product/favorite.ts b/src/api/mall/product/favorite.ts index 2e54ec78..3834eed0 100644 --- a/src/api/mall/product/favorite.ts +++ b/src/api/mall/product/favorite.ts @@ -8,21 +8,5 @@ export interface Favorite { // 获得 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/views/member/user/detail/UserFavoriteList.vue b/src/views/member/user/detail/UserFavoriteList.vue index 009a8b10..afab9a08 100644 --- a/src/views/member/user/detail/UserFavoriteList.vue +++ b/src/views/member/user/detail/UserFavoriteList.vue @@ -1,46 +1,4 @@ - - - { handleQuery() } -/** 取消收藏按钮操作 */ -const handleDelete = async (row: object) => { - try { - console.log(row) - // 取消的二次确认 - await message.delStarConfirm() - // 发起取消 - await FavoriteApi.delFavorite({ userId: queryParams.userId, spuId: row.spuId }) - message.success(t('common.delStarSuccess')) - row.favoriteStatus = 0 - // 刷新列表 - // await getList() - } catch {} -} - -/** 收藏按钮操作 */ -const handleAdd = async (row: object) => { - try { - const data = { userId: queryParams.userId, spuId: row.spuId } - // 发起收藏 - const result = await FavoriteApi.exitsFavorite(data) - if (result === false) { - // 发起收藏 - await FavoriteApi.createFavorite(data) - message.success(t('common.starSuccess')) - row.favoriteStatus = 1 - // 刷新列表 - // await getList() - } else { - message.warning(t('common.existStar')) - row.favoriteStatus = 1 - } - } catch {} -} - const { userId } = defineProps({ userId: { type: Number, From 2ff97758fd720b281e2b76afa56f2fc637476916 Mon Sep 17 00:00:00 2001 From: niou233 <2922564446@qq.com> Date: Fri, 10 Nov 2023 11:34:32 +0000 Subject: [PATCH 3/5] update src/hooks/web/useMessage.ts. Signed-off-by: niou233 <2922564446@qq.com> --- src/hooks/web/useMessage.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/hooks/web/useMessage.ts b/src/hooks/web/useMessage.ts index 9bfb7a3a..ac2b552e 100644 --- a/src/hooks/web/useMessage.ts +++ b/src/hooks/web/useMessage.ts @@ -90,18 +90,6 @@ 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' - } - ) } } } From 1ab5b44254415e050615d91128df0afb703ccc1d Mon Sep 17 00:00:00 2001 From: niou233 <2922564446@qq.com> Date: Fri, 10 Nov 2023 11:35:54 +0000 Subject: [PATCH 4/5] update src/locales/en.ts. Signed-off-by: niou233 <2922564446@qq.com> --- src/locales/en.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/locales/en.ts b/src/locales/en.ts index d82e616e..4f4d4895 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -54,13 +54,7 @@ export default { updateTime: 'Update Time', copy: 'Copy', copySuccess: 'Copy Success', - copyError: 'Copy Error', - confirmDelStar: 'Delete the Star?', - starSuccess: 'Star Success', - starFail: 'Star Error', - delStarSuccess: 'Del Star Success', - delStarFail: 'Del Star Error', - existStar: 'exist Star' + copyError: 'Copy Error' }, error: { noPermission: `Sorry, you don't have permission to access this page.`, From af5d1cf25ee8898cab5e1d1b520b288021d982bc Mon Sep 17 00:00:00 2001 From: niou233 <2922564446@qq.com> Date: Fri, 10 Nov 2023 11:36:11 +0000 Subject: [PATCH 5/5] update src/locales/zh-CN.ts. Signed-off-by: niou233 <2922564446@qq.com> --- src/locales/zh-CN.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 49a3f895..4f95852f 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -54,13 +54,7 @@ export default { updateTime: '更新时间', copy: '复制', copySuccess: '复制成功', - copyError: '复制失败', - confirmDelStar: '是否取消收藏?', - starSuccess: '收藏成功', - starFail: '收藏失败', - delStarSuccess: '取消收藏成功', - delStarFail: '取消收藏失败', - existStar: '收藏已存在' + copyError: '复制失败' }, error: { noPermission: `抱歉,您无权访问此页面。`,