mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-05 04:59:48 +08:00
【新增】(足迹收藏模块):足迹中收藏/删除功能,收藏中取消收藏功能
This commit is contained in:
@@ -125,3 +125,10 @@ export const queryServicesTickets = (data : any) : Promise<Response<any>> => {
|
|||||||
data,
|
data,
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 删除商品浏览足迹 */
|
||||||
|
export const queryDelGoodsBrowsing = (data : any) : Promise<Response<any>> => {
|
||||||
|
return post('Api/User/DelGoodsBrowsing', {
|
||||||
|
data,
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
@@ -1,8 +1,26 @@
|
|||||||
.item-box {
|
.item-box {
|
||||||
|
position: relative;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 15rpx;
|
border-radius: 15rpx;
|
||||||
margin-bottom: 20rpx;
|
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 {
|
.no-data {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -13,6 +13,12 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</coreshop-goods-card>
|
</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>
|
||||||
<view class="no-data" v-if="state.page === state.totalPages">没有更多了</view>
|
<view class="no-data" v-if="state.page === state.totalPages">没有更多了</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -25,10 +31,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, onMounted } from 'vue';
|
import { reactive, onMounted } from 'vue';
|
||||||
import { onReachBottom } from '@dcloudio/uni-app';
|
import { onReachBottom } from '@dcloudio/uni-app';
|
||||||
import { queryGoodscollectionList } from '@/core/api';
|
import { queryGoodscollectionList ,queryGoodsCollection} from '@/core/api';
|
||||||
import { Response } from '@/core/models';
|
import { Response } from '@/core/models';
|
||||||
import { EmptyEnum } from '@/core/enum';
|
import { EmptyEnum } from '@/core/enum';
|
||||||
import { handleRouteNavigateTo } from '@/core/utils';
|
import { handleRouteNavigateTo } from '@/core/utils';
|
||||||
|
import { handleShowToast } from '@/core/utils';
|
||||||
|
|
||||||
const state = reactive<{
|
const state = reactive<{
|
||||||
list : Array<any>;
|
list : Array<any>;
|
||||||
@@ -47,6 +54,13 @@
|
|||||||
getGoodscollectionList()
|
getGoodscollectionList()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onReachBottom(() => {
|
||||||
|
if (state.totalPages > state.page) {
|
||||||
|
state.page++;
|
||||||
|
getGoodscollectionList();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/** 获取商品收藏列表 */
|
/** 获取商品收藏列表 */
|
||||||
const getGoodscollectionList = async () => {
|
const getGoodscollectionList = async () => {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
@@ -74,12 +88,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onReachBottom(() => {
|
/** 取消收藏 */
|
||||||
if (state.totalPages > state.page) {
|
const handleCanacelCollection = async (id : number) => {
|
||||||
state.page++;
|
const goodsCollection : Response<any> = await queryGoodsCollection({ id, });
|
||||||
|
if (goodsCollection.status) {
|
||||||
|
handleShowToast(goodsCollection.msg, 'success', () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
state.page = 1;
|
||||||
|
state.list = [];
|
||||||
getGoodscollectionList();
|
getGoodscollectionList();
|
||||||
}
|
}, 1000)
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
handleShowToast(goodsCollection.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import './collection.scss';
|
@import './collection.scss';
|
||||||
|
|||||||
@@ -1,8 +1,27 @@
|
|||||||
.item-box {
|
.item-box {
|
||||||
|
position: relative;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 15rpx;
|
border-radius: 15rpx;
|
||||||
margin-bottom: 20rpx;
|
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 {
|
.no-data {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -12,6 +12,17 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</coreshop-goods-card>
|
</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>
|
||||||
<view class="no-data" v-if="state.page === state.totalPages">没有更多了</view>
|
<view class="no-data" v-if="state.page === state.totalPages">没有更多了</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -24,9 +35,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, onMounted } from 'vue';
|
import { reactive, onMounted } from 'vue';
|
||||||
import { onReachBottom } from '@dcloudio/uni-app';
|
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 { Response, GoodsFootprintType } from '@/core/models';
|
||||||
import { EmptyEnum } from '@/core/enum';
|
import { EmptyEnum } from '@/core/enum';
|
||||||
|
import { handleShowToast } from '@/core/utils';
|
||||||
|
|
||||||
const state = reactive<{
|
const state = reactive<{
|
||||||
list : Array<GoodsFootprintType>;
|
list : Array<GoodsFootprintType>;
|
||||||
@@ -82,6 +94,38 @@
|
|||||||
url: `/pages/subpackage/goods/detail?id=${item.goodsId}`
|
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>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import './footprint.scss';
|
@import './footprint.scss';
|
||||||
|
|||||||
Reference in New Issue
Block a user