<template>
	<view class="container-main">
		<view class="list">
			<view class="list-item" v-for="item in list" :key="item.id">
				<view class="item-title">{{item.productName}}</view>
				<view class="data-row">
					<view class="data-lable">产地:</view>
					<view class="data-value">{{item.enterpriseName}}</view>
				</view>
				<view class="data-row">
					<view class="data-lable">生产时间:</view>
					<view class="data-value">{{item.productTime}}</view>
				</view>
				<view class="data-row">
					<view class="data-lable">上市时间:</view>
					<view class="data-value">{{item.marketTime}}</view>
				</view>
			</view>
			<u-loadmore :status="status" :load-text="loadText" />
		</view>
	</view>
</template>

<script>
	import {
		getFamousList,
	} from '@/api/shianliaoning/famousShow.js'
	export default {
		data() {
			return {
				status: "nomore",
				loadText: {
					loading: "努力加载中",
					nomore: "已经到底了~",
				},
				list: [],
				total: 0,
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					endTime: "",
					enterpriseName: "",
					startTime: "",
				}
			}
		},
		onLoad() {
			this.getList()
		},
		onReachBottom() {
			if (this.queryParams.pageNum < this.total) {
				if (this.status == 'loading') return
				this.queryParams.pageNum = this.queryParams.pageNum + 1;
				this.getList()
			}
		},
		methods: {
			//获取数据
			getList() {
				this.status = 'loading'
				getFamousList(this.queryParams).then(res => {
					this.list = [...this.list, ...res.data.result.list];
					this.total = Math.ceil(res.data.result.total / this.queryParams.pageSize) || 1;
					this.status = 'nomore'
				})

			},
		},
	}
</script>

<style lang="scss" scoped>
	.list {
		box-sizing: border-box;
		padding: 20rpx;

		&>.list-item {
			min-height: 20rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			margin-bottom: 20rpx;
			box-sizing: border-box;
			padding: 20rpx;

			.item-title {
				font-size: 30rpx;
				font-weight: 550;
			}

			.data-row {
				margin-top: 20rpx;
				display: flex;
				align-items: center;

				.data-lable {
					width: 130rpx;
					font-size: 28rpx;
					font-weight: 400;
					color: #9DA2AB;
				}

				.data-value {
					flex: 1;
					font-size: 28rpx;
					font-weight: 400;
					color: #34373B;
					box-sizing: border-box;
					padding-left: 20rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
			}
		}

		.list-item:active {
			background-color: rgba(196, 204, 216, 0.2);
		}
	}
</style>