<template>
	<view>
		<uni-card v-bind:title="noticeDetail.title">
			<text class="uni-body">{{noticeDetail.content}}</text></br>
			<view class="bottom">
				<text>成都次元节点网络科技有限公司</text></br>
				<text class="uni-body">{{noticeDetail.createTime}}</text>
			</view>
		</uni-card>
	</view>
</template>

<script>
	import {
		getNoticeDetails
	} from '@/api/userInfo.js'
	export default {
		data() {
			return {
				noticeDetail:{
					id: 0,
					title: '',
					content: '',
					img: '',
					createTime: '',
					userInfo:{}
				}
			}
		},
		created() {
			const userInfo = uni.getStorageSync('userInfo')
			if (!userInfo) {
				console.log('havent userInfo')
				uni.showModal({
					content: '艺术家账户过期,请重新登录！',
					showCancel: false,
					success() {
						//没有缓存则跳转登录页面
						uni.reLaunch({
							url: '/pages/login/login'
						});
					}
				});
			} else {
				this.userInfo = userInfo;
				console.log('have userInfo')
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			this.noticeDetail.id = option.id
			//console.log('this.id',this.id)
			this.getNoticeDetails();
		},
		methods: {
			
			// 查询公告详情
			async getNoticeDetails() {
				let that = this;
				const res = await getNoticeDetails(that.noticeDetail.id)
				console.log('res', res)
				if (res.data.code === 200) {
					that.noticeDetail = res.data.data
				} else {
					uni.showModal({
						content: '公告详情数据加载失败！',
						showCancel: false
					});
				}
			},
		}
	}
</script>

<style>
.bottom{
	margin-top:40rpx;
}
</style>
