<template>
	<view class="container">
		<scroll-view class="padding-wrap" scroll-y @scrolltolower="loadMore">
			<view class="message-box" @click="goDetail" v-for="(item,index) in dataList" :key="'msg'+index">
				<view class="message-image">
					<image class="image" src="@/static/msg-icon.png" mode="widthFix"></image>
				</view>
				<view class="message-info">
					<view class="message-title">
						<view class="title">设备无法制冷设备无法制冷</view>
						<view class="time">2023/07/01</view>
					</view>
					<view class="message-des">
						此处是报警信息详情此处是报警信息详情此处是报警信息详情此处是报警信息详情此处是报警信息详情
					</view>
				</view>
			</view>
			<uni-load-more iconType="circle" :status="status" />
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [],
				pageNo: 1,
				pageSize: 10,
				hasMore: true,
				status: 'loading'
			}
		},
		onLoad() {
			// #ifdef APP-PLUS
			// #endif
			this.loadMore();
		},
		methods: {
			//滚动加载更多
			loadMore() {
				if (this.hasMore) {
					this.pageNo = this.pageNo + 1;
					this.staus = 'loading';
					for (var i = 0; i < 10; i++) {
						this.dataList.push({
							id: (this.pageNo - 1) * this.pageSize + i
						});
					}
					if (this.pageNo > 3) {
						this.hasMore = false;
						this.status = 'noMore';
					}else{
						this.status = 'more';
					}
				}
			},
			goDetail() {
				uni.navigateTo({
					url: '/pages/message/detail'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page,
	.container {
		height: 100vh;
		background-color: #FFFFFF;
	}

	.padding-wrap {
		padding-top: 30upx;
		height: calc(100vh - 30upx);
	}

	.message-box {
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 0 30upx;
		margin-bottom: 44upx;

		.message-image {
			display: block;
			margin-right: 20upx;

			.image {
				width: 88upx;
				height: 88upx;
			}
		}

		.message-info {
			flex: 1;
			color: #031945;
			font-size: 28upx;
			line-height: 40upx;

			.message-title {
				display: flex;
				justify-content: space-between;

				.title {
					max-width: 350upx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					white-space: nowrap;
					text-overflow: ellipsis;
					overflow: hidden;
				}

				.time {
					color: #90959D;
					font-size: 24upx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
				}
			}

			.message-des {
				display: block;
				width: 550upx;
				color: #90959D;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
		}
	}
</style>