<template>
	<view class="detail">
		<u-navbar
			back-icon-color="#fff"
			:back-text="$t('common.Back')" 
			:is-back="true" 
			:background="{background:'#1777FE'}"
			:back-text-style="{color:'#fff'}" 
			:border-bottom="true"
			title-color="#fff"
			:title="title"
			:custom-back="back"
		>
		</u-navbar>
		<view class="bg"></view>
		<view class="content">
			<view class="title">{{detail.title}}</view>
			<view class="date">{{formatDate(detail.createDate)}}</view>
			<view class="content">{{detail.content}}</view>
		</view>
	</view>
</template>

<script>

  export default {
    components:{
		
    },
    data() {
      return {
		title:'',
		msgType:'',
		msgId:'',
		detail:{}
      }
    },
	onShow(){
		this.title = this.msgType=='0'?this.$t('common.SystemMessage'):this.$t('common.notification');
		this.detail= uni.getStorageSync('MsgDetail')?uni.getStorageSync('MsgDetail'):{},
		this.readMsg()
		
	},
   onLoad(e) {
		this.msgType=e.msgType;
		this.msgId=e.msgId;
		console.log(e,this.msgType)
   },
   
   onUnload(){
	   uni.removeStorageSync('MsgDetail')
   },
   methods: {
	   
	   //标记已读信息
	   async readMsg(){
		   console.log(this.msgType)
		   if(this.msgType==0){
			   if(this.detail.params!='read'){
				let res = await this.$myRequest({
					url:'/uc/sysPushMessages/updateReadStatus',
					data:{arr:this.msgId}
				})
			}
		   }else{
			   if(this.detail.readStatus!='read'){
					let res = await this.$myRequest({
						url:'/uc/platformNotify/isRead',
						data:{ids:this.msgId}
					})
				}
		   }
	   },
		
		//后退一步
		back(){
			// #ifdef H5
			history.back()
			// #endif
			// #ifndef H5
			uni.navigateBack()
			// #endif
		},
	}
  }
</script>

<style lang="scss" scoped>
	.detail{
		.bg{
			position:fixed;
			top:0;
			left:0;
			right:0;
			bottom:0;
			z-index:-1;
			background:#fff;
		}
		.content{
			width:94%;
			margin:20upx auto;
			.title{
				flex:1;
				text-align:center;
				height:100upx;
				line-height:100upx;
				font-size:36upx;
			}
			.date{
				color:#aaa;
				font-size:24upx;
				text-align:center;
				margin-bottom:60upx;
			}
		}
	 
   }
  
</style>
