Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f2c71d58
authored
Nov 08, 2023
by
niou233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 会员商品收藏
parent
18e2c33c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
115 deletions
+0
-115
src/api/mall/product/favorite.ts
+0
-16
src/views/member/user/detail/UserFavoriteList.vue
+0
-99
No files found.
src/api/mall/product/favorite.ts
View file @
f2c71d58
...
@@ -8,21 +8,5 @@ export interface Favorite {
...
@@ -8,21 +8,5 @@ export interface Favorite {
// 获得 ProductFavorite 列表
// 获得 ProductFavorite 列表
export
const
getFavoritePage
=
(
params
:
PageParam
)
=>
{
export
const
getFavoritePage
=
(
params
:
PageParam
)
=>
{
params
.
keyword
=
params
.
name
return
request
.
get
({
url
:
'/product/favorite/page'
,
params
})
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
})
}
src/views/member/user/detail/UserFavoriteList.vue
View file @
f2c71d58
<
template
>
<
template
>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class=
"-mb-15px"
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form-item
label=
"商品名称"
prop=
"name"
>
<el-input
v-model=
"queryParams.name"
placeholder=
"请输入商品名称"
clearable
@
keyup
.
enter=
"handleQuery"
class=
"!w-240px"
/>
</el-form-item>
<el-form-item
label=
"收藏时间"
prop=
"createTime"
>
<el-date-picker
v-model=
"queryParams.createTime"
value-format=
"YYYY-MM-DD HH:mm:ss"
type=
"daterange"
start-placeholder=
"开始日期"
end-placeholder=
"结束日期"
:default-time=
"[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class=
"!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button
@
click=
"handleQuery"
>
<Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
>
<Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<!-- 列表 -->
<ContentWrap>
<ContentWrap>
<el-table
v-loading=
"loading"
:data=
"list"
>
<el-table
v-loading=
"loading"
:data=
"list"
>
...
@@ -67,28 +25,6 @@
...
@@ -67,28 +25,6 @@
<dict-tag
:type=
"DICT_TYPE.PRODUCT_SPU_STATUS"
:value=
"scope.row.status"
/>
<dict-tag
:type=
"DICT_TYPE.PRODUCT_SPU_STATUS"
:value=
"scope.row.status"
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
align=
"center"
fixed=
"right"
label=
"操作"
min-width=
"200"
>
<
template
#
default=
"{ row }"
>
<el-button
v-if=
"row.favoriteStatus === 0"
v-hasPermi=
"['product:spu:delete']"
link
type=
"danger"
@
click=
"handleAdd(row)"
>
收藏
</el-button>
<el-button
v-if=
"row.favoriteStatus === 1"
v-hasPermi=
"['product:spu:delete']"
link
type=
"danger"
@
click=
"handleDelete(row)"
>
取消收藏
</el-button>
</
template
>
</el-table-column>
</el-table>
</el-table>
<!-- 分页 -->
<!-- 分页 -->
<Pagination
<Pagination
...
@@ -145,41 +81,6 @@ const resetQuery = () => {
...
@@ -145,41 +81,6 @@ const resetQuery = () => {
handleQuery
()
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
({
const
{
userId
}
=
defineProps
({
userId
:
{
userId
:
{
type
:
Number
,
type
:
Number
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment