<template>
	<view class="page">
		<view v-for="(item,index) in listData" :key="index">
			<view class="itemBox" @click="jumpPage(index)">
				<view class="avatarBox">
					<image class="imgicon" :src="item.imgurl" mode="widthFix"></image>
					<u-badge size="mini" class="badge" :absolute="false"  :count="item.Num"></u-badge>
				</view>
				
				<view class="infoBox">
					<view class="infoTop">
						<view class="infoName">
							{{item.Title}}
						</view>
						<view class="infoDate">
							{{item.Time}}
						</view>
					</view>
					<view class="infoTipMsg">
						{{item.Description}}
					</view>
				</view>
			</view>
		</view>
		 <auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth= 'gbAuth'></auth>
	</view>
</template>

<script>
	import auth from "@/components/auth/index.vue";
	export default {
		components: {
		  auth
		},
		data() {
			return {
				pageTitle: "消息",
				listData: [],
				showAuth:false,
				u:{},
			}
		},
		methods: {
			jumpPage(index){
				let url="";
				if(index==0){
					url="/pages/blindDate/circleNews?pageType=1"
				}else if(index==1){
					url="/pages/blindDate/systemMsg"
				}else if(index==2){
					url="/pages/blindDate/circleNews?pageType=2"
				}else if(index==3){
					url="/pages/blindDate/visitor"
				}
				uni.navigateTo({
					url:url
				})
			},
			getMiaiMessageCenter(){
				this.request2(
				  	{
				  		url: '/api/AppletMiai/GetMiaiMessageCenter',
				  		data:{} 
				  	},
				  	res => {
						if(res.resultCode==1){
							this.listData=[]
							for(let key in res.data ){
								if(key=="CircleModel"){
									res.data.CircleModel.imgurl="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/Blind-quan.png"
								}else if(key=="PPPlusModel"){
									res.data.PPPlusModel.imgurl="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/Blind-xitong.png"
								}else if(key=="SystemModel"){
									res.data.SystemModel.imgurl="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/Blind-ppplus.png"
								}else if(key=="VisitorModel"){
									res.data.VisitorModel.imgurl="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/Blind-fangke.png"
								}
								this.listData.push(res.data[key])
							}
						}
				  	}
				  );
			},
			reloadUserinfo() {
			  this.u = uni.getStorageSync("mall_UserInfo");
			  // this.showAuth=false;
			  this.getMiaiMessageCenter();
			},
			//关闭登录窗口
			gbAuth(){
				uni.navigateBack()
			},
		},
		onShow() {
			this.u = uni.getStorageSync("mall_UserInfo");
			if (!this.u) {
			  this.u = {
				nickName: "未登录",
				avatarUrl: ""
			  };
			  this.showAuth = true;
			}	else{
				this.getMiaiMessageCenter();
			}
			
		},
		mounted() {
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		padding: 0 30rpx;
	}

	.itemBox {
		width: 100%;
		height: 148rpx;
		display: flex;
		align-items: center;
		.avatarBox{
			position: relative;
			width: 88rpx;
			height: 88rpx;
			.imgicon{
				width: 88rpx;
				height: 88rpx;
			}
			/deep/.badge{
				position: absolute;
				top: 0rpx;
				right: 0rpx;
			}
		}
	}
	
	.infoBox{
		height: 148rpx;
		margin-left: 27rpx;
		flex-grow: 5;
		border-bottom: 1rpx solid #E2E2E2;
		padding-top: 40rpx;
		.infoTop{
			width: 100%;
			// height: 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			// margin-bottom: 15rpx;
			.infoName{
				font-size: 30rpx;
				font-weight: bold;
				color: #000000;
				
			}
			.infoDate{
				font-size: 24rpx;
				// font-weight: 500;
				color: #999999;
			}
		}
		.infoTipMsg{
			font-size: 24rpx;
			font-weight: 500;
			color: #999999;
		}
	}
	
	
	
</style>
