<template>
	<view class="page">

		<!-- 收藏列表 -->
		<view class="content" v-if="list.length > 0">
			<view v class="list">
				<view v-for="item in list" :key="item.id" class="record-item" @click="viewGoodsDetail(item)">
					<image class="record-image" :src="item.communityGoods.image" mode="aspectFit"></image>
					<view class="record-content">
						<view class="record-info">
							<view class="title-row">
								<text class="record-title">{{ item.communityGoods.title }}</text>
							</view>
							<view class="record-points">
								<uv-icon name="integral" size="16" color="#218cdd"></uv-icon>
								<text class="points-text">{{ item.communityGoods.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"
							></uv-button>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else class="empty">
			<uv-empty icon="/static/暂无收藏.png" text="暂无收藏商品"></uv-empty>
		</view>
		
	</view>
</template>

<script>
import MixinList from '@/mixins/list'
export default {
	mixins: [MixinList],
	data() {
		return {
			list: [],
			mixinListApi: 'shop.queryGoodsCollectionList'
		}
	},
	methods: {
		// 查看商品详情
		viewGoodsDetail(item) {
			uni.navigateTo({
				url: `/subPages/shop/goodsDetail?id=${item.goodsId}`
			})
		}
	}
}
</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 {
	padding-top: 200rpx;
}
</style>