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] =?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,