mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:03:27 +08:00
【新增】(足迹收藏模块):足迹中收藏/删除功能,收藏中取消收藏功能
This commit is contained in:
@@ -124,4 +124,11 @@ export const queryServicesTickets = (data : any) : Promise<Response<any>> => {
|
||||
return post('Api/User/GetServicesTickets', {
|
||||
data,
|
||||
}, true);
|
||||
}
|
||||
|
||||
/** 删除商品浏览足迹 */
|
||||
export const queryDelGoodsBrowsing = (data : any) : Promise<Response<any>> => {
|
||||
return post('Api/User/DelGoodsBrowsing', {
|
||||
data,
|
||||
}, true);
|
||||
}
|
||||
@@ -1,8 +1,26 @@
|
||||
.item-box {
|
||||
position: relative;
|
||||
padding: 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 15rpx;
|
||||
margin-bottom: 20rpx;
|
||||
.btn-box {
|
||||
position: absolute;
|
||||
right: 10rpx;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
z-index: 99;
|
||||
.collection {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx 10rpx;
|
||||
.tit {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.no-data {
|
||||
text-align: center;
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
</view>
|
||||
</template>
|
||||
</coreshop-goods-card>
|
||||
<view class="btn-box">
|
||||
<view class="collection" @click.stop="handleCanacelCollection(item.goodsId)">
|
||||
<uv-icon name="heart-fill" color="#979797" size="18"></uv-icon>
|
||||
<text class="tit">取消收藏</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="no-data" v-if="state.page === state.totalPages">没有更多了</view>
|
||||
</view>
|
||||
@@ -25,11 +31,12 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, onMounted } from 'vue';
|
||||
import { onReachBottom } from '@dcloudio/uni-app';
|
||||
import { queryGoodscollectionList } from '@/core/api';
|
||||
import { queryGoodscollectionList ,queryGoodsCollection} from '@/core/api';
|
||||
import { Response } from '@/core/models';
|
||||
import { EmptyEnum } from '@/core/enum';
|
||||
import { handleRouteNavigateTo } from '@/core/utils';
|
||||
|
||||
import { handleShowToast } from '@/core/utils';
|
||||
|
||||
const state = reactive<{
|
||||
list : Array<any>;
|
||||
totalPages : number;
|
||||
@@ -46,7 +53,14 @@
|
||||
/** 获取商品收藏列表 */
|
||||
getGoodscollectionList()
|
||||
});
|
||||
|
||||
|
||||
onReachBottom(() => {
|
||||
if (state.totalPages > state.page) {
|
||||
state.page++;
|
||||
getGoodscollectionList();
|
||||
}
|
||||
})
|
||||
|
||||
/** 获取商品收藏列表 */
|
||||
const getGoodscollectionList = async () => {
|
||||
uni.showLoading({
|
||||
@@ -73,13 +87,22 @@
|
||||
brief: '',
|
||||
}
|
||||
}
|
||||
|
||||
onReachBottom(() => {
|
||||
if (state.totalPages > state.page) {
|
||||
state.page++;
|
||||
getGoodscollectionList();
|
||||
|
||||
/** 取消收藏 */
|
||||
const handleCanacelCollection = async (id : number) => {
|
||||
const goodsCollection : Response<any> = await queryGoodsCollection({ id, });
|
||||
if (goodsCollection.status) {
|
||||
handleShowToast(goodsCollection.msg, 'success', () => {
|
||||
setTimeout(() => {
|
||||
state.page = 1;
|
||||
state.list = [];
|
||||
getGoodscollectionList();
|
||||
}, 1000)
|
||||
})
|
||||
} else {
|
||||
handleShowToast(goodsCollection.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './collection.scss';
|
||||
|
||||
@@ -1,8 +1,27 @@
|
||||
.item-box {
|
||||
position: relative;
|
||||
padding: 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 15rpx;
|
||||
margin-bottom: 20rpx;
|
||||
.btn-box {
|
||||
position: absolute;
|
||||
right: 10rpx;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
z-index: 99;
|
||||
.collection,
|
||||
.delete {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx 10rpx;
|
||||
.tit {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.no-data {
|
||||
text-align: center;
|
||||
|
||||
@@ -12,6 +12,17 @@
|
||||
</view>
|
||||
</template>
|
||||
</coreshop-goods-card>
|
||||
<view class="btn-box">
|
||||
<view class="collection" @click.stop="handleCollection(item.goodsId)">
|
||||
<uv-icon v-if="item.isCollection" name="heart-fill" color="#979797" size="18"></uv-icon>
|
||||
<uv-icon v-else name="heart" color="#979797" size="18"></uv-icon>
|
||||
<text class="tit">收藏</text>
|
||||
</view>
|
||||
<view class="delete" @click.stop="handleDelete(item.id)">
|
||||
<uv-icon name="trash" color="#979797" size="18"></uv-icon>
|
||||
<text class="tit">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="no-data" v-if="state.page === state.totalPages">没有更多了</view>
|
||||
</view>
|
||||
@@ -24,9 +35,10 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, onMounted } from 'vue';
|
||||
import { onReachBottom } from '@dcloudio/uni-app';
|
||||
import { queryGoodsBrowsing } from '@/core/api';
|
||||
import { queryGoodsBrowsing, queryDelGoodsBrowsing, queryGoodsCollection } from '@/core/api';
|
||||
import { Response, GoodsFootprintType } from '@/core/models';
|
||||
import { EmptyEnum } from '@/core/enum';
|
||||
import { handleShowToast } from '@/core/utils';
|
||||
|
||||
const state = reactive<{
|
||||
list : Array<GoodsFootprintType>;
|
||||
@@ -82,6 +94,38 @@
|
||||
url: `/pages/subpackage/goods/detail?id=${item.goodsId}`
|
||||
})
|
||||
}
|
||||
|
||||
/** 收藏 */
|
||||
const handleCollection = async (id : number) => {
|
||||
const goodsCollection : Response<any> = await queryGoodsCollection({ id, });
|
||||
if (goodsCollection.status) {
|
||||
handleShowToast(goodsCollection.msg, 'success', () => {
|
||||
setTimeout(() => {
|
||||
state.page = 1;
|
||||
state.list = [];
|
||||
getGoodsBrowsing();
|
||||
}, 1000)
|
||||
})
|
||||
} else {
|
||||
handleShowToast(goodsCollection.msg)
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除商品浏览足迹 */
|
||||
const handleDelete = async (id : number) => {
|
||||
const delGoodsBrowsing : Response<any> = await queryDelGoodsBrowsing({ id, });
|
||||
if (delGoodsBrowsing.status) {
|
||||
handleShowToast(delGoodsBrowsing.msg, 'success', () => {
|
||||
setTimeout(() => {
|
||||
state.page = 1;
|
||||
state.list = [];
|
||||
getGoodsBrowsing();
|
||||
}, 1000)
|
||||
})
|
||||
} else {
|
||||
handleShowToast(delGoodsBrowsing.msg)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './footprint.scss';
|
||||
|
||||
Reference in New Issue
Block a user