<template>
	<view class="message-list">
		<!-- 消息提示 -->
		<view class="message-item" @click="$navigateTo('/pages/messageList/messageList?type=6')">
			<uni-badge class="uni-badge-left-margin" :text="testCount[6]" absolute="rightTop" size="small">
				<view class="message-system-icon">
					<uni-icons type="icon-jigoukehudaishenheshuliang" custom-prefix="iconfont" size="30" color="#fff">
					</uni-icons>
				</view>
			</uni-badge>
			<view class="message-content">
				<view class="message-title">项目邀请通知</view>
				<view class="message-sub-content">
					{{!testCount[6] ?'暂无消息通知' : `您有${testCount[6]}条未读消息，请查看～`}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getMessageTest
	} from '@/request/api/message.js'
	export default {
		data() {
			return {
				testCount: {}
			}
		},
		onShow() {
			this.init();
		},
		methods: {
			init() {
				getMessageTest(this.$store.getters.user.userId).then(res => {
					if (res.code == 200) {
						let obj = {};
						for (var i = 0; i < res.data.length; i++) {
							obj[res.data[i].messageType] = res.data[i].count;
						}
						this.testCount = obj;
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.message-list {
		margin-top: 30rpx;

		.message-item {
			background: #fff;
			display: flex;
			padding: 24rpx 30rpx;
			position: relative;

			&::before {
				content: '';
				position: absolute;
				bottom: 0;
				right: 0;
				left: 150rpx;
				height: 2rpx;
				background: $uni-border-1;
			}
		}

		.message-system-icon {
			width: 100rpx;
			height: 100rpx;
			border-radius: 16rpx;
			text-align: center;
			line-height: 100rpx;
			background: $uni-primary;
		}

		.message-image {
			width: 100rpx;
			height: 100rpx;
			border-radius: 16rpx;
			overflow: hidden;
		}

		.message-content {
			flex: 1;
			width: 0;
			margin-left: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
		}

		.message-title {
			font-size: 32rpx;
			font-weight: 600;
			margin-bottom: 10rpx;
		}

		.message-sub-content {
			font-weight: 300;
			color: $uni-secondary-color;
		}

		.message-date {
			position: absolute;
			top: 34rpx;
			right: 30rpx;
			font-size: 24rpx;
			font-weight: 300;
			color: $uni-secondary-color;
		}
	}
</style>