<template>
	<div>
		<common @asynCallBack="asynCallBack"></common>
		<top-header :pageTitle="pageTitle"></top-header>

		<div class="mui-content">
			<div class="vongi-notice">
				<div class="mui-h3">
					{{detail.title}}
					<h6 v-text="detail.createTime"></h6>
				</div>
				<p v-html="detail.content"></p>
			</div>
			<div v-if="noticeList.length" class="vongi-notice-list">
				<h3><img src="~$project/assets/img/text.png" width="12" />相关内容</h3>
				<div class="vongi-floor-padded">
					<a @click="getDetail(item.messageId)" v-for="(item,index) in noticeList" :key="index" class="mui-ellipsis" v-text="item.title"></a>
				</div>
			</div>
		</div>

		<loading :visible="isLoading"></loading>
	</div>
</template>

<script>
	import * as API_Notice from '@/apis/Common/notice'
	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'CommonNoticeInfo',
		components: {
			Common,
			Loading,
			TopHeader
		},
		data() {
			return {
				pageTitle: '消息详情',

				isLoading: false,

				id: this.$route.query.id,
				detail: [],

				noticeList: [],
			}
		},
		created() {

		},
		methods: {
			//获取详情
			getDetail(id) {
				var id = id || this.id;
				this.isLoading = true;
				API_Notice.getMessageInfo(id).then(response => {

					this.detail = response;

					this.isLoading = false;
					//获取最新5条通知消息
					this.getLastNotice();
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//获取最新5条通知消息
			getLastNotice() {
				this.isLoading = true;
				API_Notice.getTopList({
					type: this.detail.type,
					limit: 5,
					excludeMessageId: this.id
				}).then(response => {
					this.noticeList = response;
					this.isLoading = false;
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			asynCallBack() {

			},
		},
		mounted() {
			//获取详情
			this.getDetail();
		},
		destroyed() {},
		computed: {
			...mapGetters({
				openId: 'wx_openid',
				token: 'token',
			})
		},
	}
</script>

<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style scoped>
</style>
