<template>
	<view class="messageList_wrap">
		<u-navbar title="提醒消息" :autoBack="true" :placeholder="true" v-hideNav></u-navbar>
		<view class="message_item" v-for="item in listData" :key="item.id">
			<view class="message_top" :class="{ status_0 : item.status === '0' }">
				{{handleMessage(item)}}
			</view>
			<view class="message_bottom">
				<u-icon name="clock" color="#C0C0C7"></u-icon>
				<text class="date">{{item.receiveTime}}</text>
			</view>
		</view>
		<u-loadmore :status="finished ? 'nomore' : loadStatus" icon line />
	</view>
</template>

<script>
	import pullUpRefresh from "@/utils/pullUpRefresh";
	export default {
		mixins : [pullUpRefresh],
		onLoad: function(option) {
			this.queryParams.type = option.type;
		},
		data() {
			return {
				queryParams: {
					pageSize: 10,
					pageNum: 1,
					receiveUserId : this.$store.state.user.userInfo.userId,
					type: undefined
				},
			}
		},
		methods : {
			handleMessage(item){
				return item.sysMessageSend.content ? item.sysMessageSend.content.replace(/<\/?.+?>/g,"").replace(/ /g,"") : "";
			},
			async getList(){
				const { rows } = await uni.$u.api.sysMessageReceive(this.queryParams);
				return rows;
			}
		},
		mounted() {
			this.handleLoadData();
		}
	}
</script>

<style lang="scss" scoped>
	.messageList_wrap {
		padding: 20rpx 30rpx;

		.message_item {
			background: #fff;
			border-radius: 12rpx;
			padding: 40rpx 56rpx;
			margin-bottom: 20rpx;
			.message_top {
				position: relative;
				color: #202020;
				font-size: 28rpx;
			}

			.status_0 {
				&::before {
					content: "";
					display: inline-block;
					width: 12rpx;
					height: 12rpx;
					background: #ff2a2a;
					border-radius: 50%;
					position: absolute;
					top: 12rpx;
					left: -20rpx;
				}
			}

			.message_bottom {
				display: flex;
				margin-top: 20rpx;

				::v-deep .u-icon__icon {
					font-size: 24rpx !important;
				}

				.date {
					color: #c0c0c7;
					font-size: 24rpx;
					margin-left: 10rpx;
				}
			}
		}
	}
</style>
