<template>
	<view class="page">
		<view class="head-bg" style="height: 20rpx;">
		</view>
		
		<view class="mainHeader">
			<view class="borderHeader"></view>
		</view>
		<view class="bodyMain">
			<view class="nodata" v-if="have_nodata">
				<image class="img" mode="widthFix" src="../../static/icon/listen_no_history.png"></image>
				暂无消息
			</view>
			<view class="inform-list">
				<view class="list" v-for="(item,index) in list" :key="index">
					<view class="item" @click="onShowNotify(item)">
						<view class="title">
							<text class="one-omit">
								<text class="one-omit" v-if="type == 'prize'">[{{item.name}}]</text>
								{{item.title}}
							</text>
						</view>
						<view class="describe">
							<text class="two-omit">{{item.intro}}</text>
						</view>
						<view class="tdate">
							<text>{{item.tdate}}</text>
						</view>
						
					</view>
				</view>
			</view>
		</view>
		<view class="rule-win" v-if="isRule">
			<view class="cu-modal" :class="{'show':isRule}">
			  <view class="cu-dialog">
			    <view class="cu-bar bg-white justify-end">
			      <view class="content">详细</view>
			      <view class="action">
			        <text class="cuIcon-close text-red" @click="isRule = false"></text>
			      </view>
			    </view>
			    <view class="rule-content" style="padding:40rpx;text-align:left;box-sizing: content-box;">
						<text style="">
							{{item_content}}
						</text>
						<text></text>
					</view>
			  </view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type:'msg',
				isRule: false,
				item_content:'',
				have_nodata:true,
				list:[]
			};
		},
		onLoad(params) {
			this.skey = params.skey||'1234567xef';
			this.type = params.type||'msg';
			var that = this;
			this.getInfo();
		},
		methods:{
			goBack() {
				uni.navigateBack({delta: 1});
			},
			onShowNotify(item) {
				if(this.type == 'msg') {
					if(item.isDo == undefined || item.isDo == null) {
						item.content = item.content.replace(/[\n]/g, "\n　　");
						item.isDo = 'yes';
					}
					this.item_content = '' + item.content;
					this.isRule = true;
				}
			},
			getInfo() {
				var that = this;
				
				uni.request({
				    url: this.$apiHost + '/Notify/getlist', //仅为示例，并非真实接口地址。
				    data: {
				        id: this.id,
						type: this.type,
						skey:this.skey
				    },
				    header: {
				        'content-type': 'application/json' //自定义请求头信息
				    },
				    success: (res) => {
						this.list = res.data.list;
						
				    }
				});
				
				// setTimeout(function() {
				// 	that.getAdNum();
				// },9000)
			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'NotificationMessage.scss';
</style>
