Feat:删除用户商品浏览足迹

This commit is contained in:
linxi
2026-02-02 10:55:40 +08:00
parent 56c00e61aa
commit 86f1443b42
2 changed files with 43 additions and 3 deletions
+5 -1
View File
@@ -578,6 +578,10 @@ export function getHistory(params) {
return request.get('/history/list', params)
}
export function deleteHistory(id) {
return request.delete(`/history/${id}`)
}
/**
* 购物车猜你喜欢
* @param {*} params
@@ -598,4 +602,4 @@ export function queryUserGuide(params) {
export function setUserGuide(params) {
return request.post('/user/guide/status', params)
}
}
+38 -2
View File
@@ -27,6 +27,13 @@
class="v12-white v12-radius-20 history-card"
@click="goodsDetail(historyItem)"
>
<view class="delete-icon" @click.stop="deleteHistoryItem(historyItem)">
<u-icon
name="close"
color="#fff"
size="16"
/>
</view>
<image
class="goods-img"
:src="historyItem.image"
@@ -83,7 +90,7 @@
</template>
<script>
import { getHistory } from '@/api/user'
import { getHistory, deleteHistory as deleteHistoryApi } from '@/api/user'
export default {
data() {
return {
@@ -179,6 +186,21 @@ export default {
}
})
},
deleteHistoryItem(historyItem) {
const id = historyItem.id
if (!id) return
uni.showModal({
title: '提示',
content: '确认删除该浏览足迹吗?',
success: (res) => {
if (res.confirm) {
deleteHistoryApi(id).then(() => {
this.queryHistory()
})
}
}
})
},
queryHistory() {
this.items = []
this.isLoad = false
@@ -245,6 +267,7 @@ export default {
margin-right: 16rpx;
border-radius: 20rpx;
overflow: hidden;
position: relative;
&:nth-child(3n) {
margin-right: 0;
}
@@ -271,6 +294,19 @@ export default {
}
}
}
.delete-icon{
position: absolute;
top: 8rpx;
right: 8rpx;
z-index: 2;
width: 32rpx;
height: 32rpx;
border-radius: 16rpx;
// background-color: rgba(0, 0, 0, 0.35);
display: flex;
align-items: center;
justify-content: center;
}
.active{
background: #C52733;
color: #fff !important;
@@ -283,4 +319,4 @@ export default {
border-radius: 50%;
}
</style>
</style>