<template>
	<view class="goods-list">
		<view class="list-column" v-if="list && list.length > 0">
			<view class="list-item" v-for="(item, index) in list" :key="item.productId">
				<GoodsCard :item="item" :show-price="showPrice" @click="$emit('itemClick', item)" />
			</view>
		</view>
		<view class="empty" v-else-if="!loading">
			<text class="empty-text">暂无商品</text>
		</view>
		<view class="loading" v-if="loading">
			<text class="loading-text">加载中...</text>
		</view>
		<view class="load-more" v-if="hasMore && !loading && list.length > 0" @click="$emit('loadMore')">
			<text>加载更多</text>
		</view>
	</view>
</template>

<script>
import GoodsCard from './GoodsCard.vue';
export default {
	name: 'GoodsList',
	components: { GoodsCard },
	props: {
		list: { type: Array, default: () => [] },
		loading: { type: Boolean, default: false },
		hasMore: { type: Boolean, default: true },
		showPrice: { type: Boolean, default: true }
	}
};
</script>

<style lang="scss" scoped>
.goods-list {
	padding: 24rpx;
	background: #f5f5f5;
	min-height: 400rpx;
	padding-bottom: 120rpx;
}
.list-column {
	display: flex;
	flex-direction: column;
	gap: 24rpx;
}
.list-item {
	width: 100%;
}
.empty,
.loading {
	padding: 80rpx 0;
	text-align: center;
}
.empty-text,
.loading-text {
	font-size: 28rpx;
	color: #999;
}
.load-more {
	padding: 32rpx 0;
	text-align: center;
}
.load-more text {
	font-size: 28rpx;
	color: #FF233C;
}
</style>
