国外MOSE官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

186 lines
3.3 KiB

<template>
<view class="page">
<!-- 收藏列表 -->
<view class="content">
<view v-if="favoritesList.length > 0" class="list">
<view v-for="item in favoritesList" :key="item.id" class="record-item" @click="viewGoodsDetail(item)">
<image class="record-image" :src="item.image" mode="aspectFit"></image>
<view class="record-content">
<view class="record-info">
<view class="title-row">
<text class="record-title">{{ item.title }}</text>
</view>
<view class="record-points">
<uv-icon name="integral" size="16" color="#218cdd"></uv-icon>
<text class="points-text">{{ item.price }}积分</text>
</view>
<view class="record-time">
<uv-icon name="heart-fill" size="14" color="#ff6b6b"></uv-icon>
<text class="time-text">收藏时间:{{ item.createTime }}</text>
</view>
</view>
<view class="record-action">
<uv-button
type="primary"
size="small"
text="查看详情"
shape="circle"
@click.stop="viewGoodsDetail(item)"
></uv-button>
</view>
</view>
</view>
</view>
<view v-else class="empty">
<uv-empty mode="data" text="暂无收藏商品"></uv-empty>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
favoritesList: [],
pageNo: 1,
pageSize: 10
}
},
methods: {
// 查看商品详情
viewGoodsDetail(item) {
uni.navigateTo({
url: `/subPages/shop/goodsDetail?id=${item.id}`
})
},
// 获取收藏的商品列表
async getGoodsList() {
const res = await this.$api.shop.queryGoodsCollectionList({
pageNo: this.pageNo,
pageSize: this.pageSize
})
if (res.result.records.length) {
this.favoritesList.push(...res.result.records)
this.pageNo++
}else {
uni.showToast({
title: '暂无数据',
icon: 'none'
})
}
},
initData() {
this.favoritesList = []
this.pageNo = 1
this.pageSize = 10
}
},
async onShow() {
this.initData()
// 刷新收藏列表
await this.getGoodsList()
},
onReachBottom() {
this.getGoodsList()
},
onPullDownRefresh() {
this.initData()
this.getGoodsList()
}
}
</script>
<style lang="scss" scoped>
.page {
background-color: #f5f5f5;
min-height: 100vh;
}
.content {
padding: 0;
}
.list {
padding: 20rpx;
}
.record-item {
display: flex;
align-items: flex-start;
margin-bottom: 30rpx;
background: #fff;
border-radius: 12rpx;
padding: 20rpx;
}
.record-image {
width: 215rpx;
height: 215rpx;
border-radius: 8rpx;
margin-right: 20rpx;
flex-shrink: 0;
}
.record-content {
flex: 1;
display: flex;
flex-direction: column;
}
.record-info {
display: flex;
flex-direction: column;
margin-bottom: 20rpx;
}
.title-row {
margin-bottom: 10rpx;
}
.record-title {
font-size: 22rpx;
color: #000;
line-height: 1.4;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.record-points {
display: flex;
align-items: center;
margin-bottom: 8rpx;
}
.points-text {
font-size: 26rpx;
color: #218cdd;
font-weight: bold;
margin-left: 6rpx;
}
.record-time {
display: flex;
align-items: center;
}
.time-text {
font-size: 22rpx;
color: #999;
margin-left: 6rpx;
}
.record-action {
display: flex;
justify-content: flex-end;
border-top: 1rpx solid #f0f0f0;
}
.empty {
margin-top: 200rpx;
}
</style>