<style lang="less" scoped>
	.container{
		height:100%;
		background:#f6f6f6;
		scroll-view{
			height:100%;
			.date{
				margin:28rpx auto 12rpx auto;
				text-align: center;
				color:#999;
				font-size:24rpx;
			}
			.card{
				margin-top:0;
				.head{
					display: flex;
					align-items: center;
					.PA-news{
						flex-shrink: 0;
						width:76rpx;
						height:76rpx;
						background:#10C176;
						border-radius: 50%;
						color:#fff;
						font-size:40rpx;
						text-align: center;
						line-height: 76rpx;
						box-shadow: 0 4rpx 6rpx rgba(0, 0, 0, 0.1);
						margin-right:20rpx;
						position:relative;
					}
					.type{
						margin-right:auto;
					}
					.name{
						font-size:24rpx;
						display: flex;
						align-items: center;
						margin-left:20rpx;
						&:before{
							content:"";
							background-image: url("data:image/svg+xml,%3Csvg width='12.854980' height='14' viewBox='0 0 12.855 14' fill='none' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg opacity='0.450000'%3E %3Cpath d='M0 12.19C0 12.22 0 12.25 0 12.28C0.01 12.31 0.02 12.34 0.03 12.36C0.04 12.39 0.05 12.42 0.06 12.45C0.08 12.48 0.1 12.51 0.12 12.54C0.14 12.57 0.16 12.6 0.19 12.63C0.21 12.66 0.24 12.68 0.27 12.71C0.3 12.74 0.34 12.77 0.37 12.8C0.41 12.82 0.44 12.85 0.48 12.88C0.52 12.91 0.57 12.93 0.61 12.96C0.66 12.99 0.7 13.01 0.75 13.04C0.8 13.07 0.86 13.09 0.91 13.12C0.96 13.14 1.02 13.17 1.08 13.19C1.14 13.22 1.2 13.24 1.26 13.26C1.32 13.29 1.39 13.31 1.45 13.33C1.52 13.36 1.59 13.38 1.66 13.4C1.73 13.42 1.8 13.44 1.88 13.47C1.95 13.49 2.03 13.51 2.11 13.53C2.18 13.55 2.26 13.57 2.35 13.58C2.43 13.6 2.51 13.62 2.59 13.64C2.68 13.66 2.76 13.67 2.85 13.69C2.94 13.71 3.03 13.72 3.12 13.74C3.21 13.75 3.3 13.77 3.39 13.78C3.49 13.8 3.58 13.81 3.67 13.82C3.77 13.83 3.87 13.85 3.96 13.86C4.06 13.87 4.16 13.88 4.26 13.89C4.36 13.9 4.46 13.91 4.56 13.92C4.66 13.93 4.76 13.93 4.86 13.94C4.96 13.95 5.07 13.95 5.17 13.96C5.27 13.97 5.38 13.97 5.48 13.98C5.58 13.98 5.69 13.98 5.79 13.99C5.9 13.99 6 13.99 6.11 13.99C6.21 13.99 6.32 14 6.42 14C6.53 14 6.63 13.99 6.74 13.99C6.84 13.99 6.95 13.99 7.05 13.99C7.16 13.98 7.26 13.98 7.37 13.98C7.47 13.97 7.57 13.97 7.68 13.96C7.78 13.95 7.88 13.95 7.98 13.94C8.09 13.93 8.19 13.93 8.29 13.92C8.39 13.91 8.49 13.9 8.59 13.89C8.69 13.88 8.79 13.87 8.88 13.86C8.98 13.85 9.08 13.83 9.17 13.82C9.27 13.81 9.36 13.8 9.45 13.78C9.55 13.77 9.64 13.75 9.73 13.74C9.82 13.72 9.91 13.71 9.99 13.69C10.08 13.67 10.17 13.66 10.25 13.64C10.34 13.62 10.42 13.6 10.5 13.58C10.58 13.57 10.66 13.55 10.74 13.53C10.82 13.51 10.89 13.49 10.97 13.47C11.04 13.44 11.11 13.42 11.18 13.4C11.26 13.38 11.32 13.36 11.39 13.33C11.46 13.31 11.52 13.29 11.59 13.26C11.65 13.24 11.71 13.22 11.77 13.19C11.83 13.17 11.88 13.14 11.94 13.12C11.99 13.09 12.04 13.07 12.09 13.04C12.14 13.01 12.19 12.99 12.23 12.96C12.28 12.93 12.32 12.91 12.36 12.88C12.4 12.85 12.44 12.82 12.47 12.8C12.51 12.77 12.54 12.74 12.57 12.71C12.6 12.68 12.63 12.66 12.66 12.63C12.68 12.6 12.71 12.57 12.73 12.54C12.75 12.51 12.77 12.48 12.78 12.45C12.8 12.42 12.81 12.39 12.82 12.36C12.83 12.34 12.84 12.31 12.84 12.28C12.85 12.25 12.85 12.22 12.85 12.19C12.85 12.16 12.85 12.13 12.84 12.1C12.84 12.07 12.83 12.04 12.82 12.01C12.81 11.98 12.8 11.95 12.78 11.92C12.77 11.89 12.75 11.86 12.73 11.83C12.71 11.81 12.68 11.78 12.66 11.75C12.63 11.72 12.6 11.69 12.57 11.66C12.54 11.63 12.51 11.61 12.47 11.58C12.44 11.55 12.4 11.52 12.36 11.5C12.32 11.47 12.28 11.44 12.23 11.41C12.19 11.39 12.14 11.36 12.09 11.34C12.04 11.31 11.99 11.28 11.94 11.26C11.88 11.23 11.83 11.21 11.77 11.18C11.71 11.16 11.65 11.13 11.59 11.11C11.52 11.09 11.46 11.06 11.39 11.04C11.32 11.02 11.26 11 11.18 10.97C11.11 10.95 11.04 10.93 10.97 10.91C10.89 10.89 10.82 10.87 10.74 10.85C10.66 10.83 10.58 10.81 10.5 10.79C10.42 10.77 10.34 10.75 10.25 10.74C10.17 10.72 10.08 10.7 9.99 10.68C9.91 10.67 9.82 10.65 9.73 10.64C9.64 10.62 9.55 10.61 9.45 10.59C9.36 10.58 9.27 10.57 9.17 10.55C9.08 10.54 8.98 10.53 8.88 10.52C8.79 10.51 8.69 10.5 8.59 10.49C8.49 10.48 8.39 10.47 8.29 10.46C8.19 10.45 8.09 10.44 7.98 10.43C7.88 10.43 7.78 10.42 7.68 10.41C7.57 10.41 7.47 10.4 7.37 10.4C7.26 10.4 7.16 10.39 7.05 10.39C6.95 10.39 6.84 10.38 6.74 10.38C6.63 10.38 6.53 10.38 6.42 10.38C6.32 10.38 6.21 10.38 6.11 10.38C6 10.38 5.9 10.39 5.79 10.39C5.69 10.39 5.58 10.4 5.48 10.4C5.38 10.4 5.27 10.41 5.17 10.41C5.07 10.42 4.96 10.43 4.86 10.43C4.76 10.44 4.66 10.45 4.56 10.46C4.46 10.47 4.36 10.48 4.26 10.49C4.16 10.5 4.06 10.51 3.96 10.52C3.87 10.53 3.77 10.54 3.67 10.55C3.58 10.57 3.49 10.58 3.39 10.59C3.3 10.61 3.21 10.62 3.12 10.64C3.03 10.65 2.94 10.67 2.85 10.68C2.76 10.7 2.68 10.72 2.59 10.74C2.51 10.75 2.43 10.77 2.35 10.79C2.26 10.81 2.18 10.83 2.11 10.85C2.03 10.87 1.95 10.89 1.88 10.91C1.8 10.93 1.73 10.95 1.66 10.97C1.59 11 1.52 11.02 1.45 11.04C1.39 11.06 1.32 11.09 1.26 11.11C1.2 11.13 1.14 11.16 1.08 11.18C1.02 11.21 0.96 11.23 0.91 11.26C0.86 11.28 0.8 11.31 0.75 11.34C0.7 11.36 0.66 11.39 0.61 11.41C0.57 11.44 0.52 11.47 0.48 11.5C0.44 11.52 0.41 11.55 0.37 11.58C0.34 11.61 0.3 11.63 0.27 11.66C0.24 11.69 0.21 11.72 0.19 11.75C0.16 11.78 0.14 11.81 0.12 11.83C0.1 11.86 0.08 11.89 0.06 11.92C0.05 11.95 0.04 11.98 0.03 12.01C0.02 12.04 0.01 12.07 0 12.1C0 12.13 0 12.16 0 12.19Z' fill='%2310C176' fill-opacity='1' fill-rule='nonzero'/%3E %3C/g%3E %3Cpath d='M11.15 4.72C11.15 2.11 9.04 0 6.42 0C3.81 0 1.69 2.11 1.69 4.72C1.69 5.84 2.08 6.86 2.72 7.67L5.58 11.88C5.97 12.44 6.8 12.45 7.19 11.89L10.07 7.74C10.75 6.92 11.15 5.87 11.15 4.72Z' fill='%2310C176' fill-rule='nonzero'/%3E %3Cpath d='M6.42 6.67C5.13 6.67 4.08 5.62 4.08 4.33C4.08 3.04 5.13 1.99 6.42 1.99C7.71 1.99 8.77 3.04 8.77 4.33C8.77 5.62 7.72 6.67 6.42 6.67ZM6.42 3.34C5.87 3.34 5.43 3.78 5.43 4.33C5.43 4.88 5.87 5.32 6.42 5.32C6.97 5.32 7.42 4.88 7.42 4.33C7.42 3.78 6.97 3.34 6.42 3.34Z' fill='%23FFF' fill-rule='nonzero'/%3E %3C/svg%3E");
							height:14rpx*2;
							width:13rpx*2;
							margin-right:6rpx;
						}
					}
				}
				.content{
					color:#707070;
					font-size:24rpx;
					margin-top:20rpx;
				}
			}
		}
	}
</style>
<template>
	<view class="container flex">
		<scroll-view scroll-y @scrolltolower="search">
			<view style="border:0.5rpx solid transparent"/>
			<template v-for="(v,k) in list">
				<view class="date" :key="k">{{v.sendTime}}</view>
				<view class="card" :key="`_${k}`">
					<view class="head">
						<text class="PA-news"/>
						<text class="type">{{v.msgType}}</text>
						<text class="name over">{{v.baseName}}</text>
					</view>
					<view class="content">{{v.msgContent}}</view>
				</view>
			</template>
			<u-empty :show="list.length<=0" text="未查询到相关信息" width="50%" icon="/static/noData.png"/>
			<view style="border:0.5rpx solid transparent"/>
		</scroll-view>
	</view>
</template>
<script>
import request,{host} from '@/common/request.js'
export default {
	data(){
		return{
			host:host('imgUrl'),
			searchVal:{
				companyId:this.$store.getters.userInfo.companyId,
				msgType:0,
				pageNo: 1,
				pageSize: 6,
				type: ""
			},
			list:[],
			total:0,
			eventChannel:null,
		}
	},
	onLoad(options){
		this.eventChannel=this.getOpenerEventChannel()
		this.searchVal.msgType=options.msgType
		this.searchVal.type=options.type
		this.search()
	},
	methods:{
		async search(e){
			if(this.total==0||this.list.length<this.total){
				var res=await request("/suyuan/messageApi/queryMessageList",{
					method:"post",
					body:this.searchVal
				})
				if(res.statu){
					this.list=this.list.concat(res.data.list)
					this.searchVal.pageNo++
					this.total=res.data.total
					if(this.list.length==this.total)uni.showToast({title:"加载完成！",icon:"none"})
				}else{
					uni.showModal({
						title:"提示",
						content:res.msg||"获取消息失败！",
						showCancel:false,
					})
				}
			}
		},
	},
	destroyed(){
		if(this.searchVal.msgType==0){
			this.eventChannel.emit("update")
			this.$store.dispatch("getSysMsg")
		}
	},
}
</script>