<template>
	<view class="msg-detail-page">
		<u-navbar title="消息详情" bg-color="#fff" title-color="#111" :border-bottom="true" @leftClick="goBack">
			<view slot="left">
				<u-icon name="arrow-left" size="44" color="#111"></u-icon>
			</view>
		</u-navbar>

		<view class="msg-detail u-p-40">
			<view class="msg-title u-font-20 u-m-b-20">{{ title }}</view>
			<view class="msg-desc u-font-14 u-tips-color">{{ desc }}</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			id:null,
			title: '',
			desc: ''
		}
	},
	onShow() {
		this.$checkToken(this.$getToken()).catch(() => {})
	},
	onLoad(e) {
	   this.id = e.id
	   this.getDetail()
	},
	methods: {
		getDetail(){
			this.$u.get(`/message/detail?id=${this.id}`,{},{
				WT: this.$getToken()
			}).then(res=>{
				if(res.flag) {
					this.title = res.data.title;
					this.desc = res.data.messageContent;
				}
			})
		},
		read(){
			this.$u.get(`/message/read?id=${this.id}`,{},{
				WT: this.$getToken()
			})
		},
		goBack() {
			const pages = getCurrentPages();
			if (pages.length > 1) {
			  uni.navigateBack();
			} else {
			  uni.switchTab({
			  		url:'/pages/index/index'
			  	})
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.msg-detail-page {
	background: #fff;
	min-height: 100vh;
}
.msg-detail {
	line-height: 1.8;
}
.msg-title {
	font-weight: bold;
}
</style>