<template>
	<view class="box">
		<view class="bgtop">
			<image src="../../static/img/nav_top.png" style="width: 100%;height: 100%;"></image>
		</view>
		<view class="bgcenter" :style="{height:height+'px'}">
			<view class="box-title">
				{{info.name||""}}
			</view>
			<view class="time">
				{{info.created_at||""}}
			</view>
			<view class="box-content">
				<rich-text :nodes="info.content"></rich-text>
			</view>
		</view>
		<view class="bgbottom">
			<image src="../../static/img/nav_bottom.png" style="width: 100%;height: 100%;"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				height: 0,
				urls: {
					1: '/api/mobile/other/visit-notice-show',
					2: '/api/mobile/other/traffic-notice-show',
					4: '/api/mobile/other/ask-show'
				},
				info: {},
				type: 1
			}
		},
		onLoad(options) {
			let that = this;
			uni.getSystemInfo({
				success: function(res) {
					that.height = res.windowHeight - 60;
				}
			});
			this.type = options.type;
			that.loadInfo(options.id);
		},
		methods: {
			loadInfo(id) {
				var that = this;
				this.util.request({
					api: this.urls[this.type],
					data: {
						id: id
					},
					utilSuccess: function(res) {
						res.content = res.content.replace(/\<img/g,
							"<img style='width:100%;height:auto;display:block'")
						that.info = res;
					},
					utilFail: function(res) {
						uni.showToast({
							icon: "none",
							title: res,
							duration: 2000
						})
					}
				})
			}
		}
	}
</script>

<style>
	.box {
		padding: 20rpx;
		box-sizing: border-box;
	}

	.bgtop {
		height: 40rpx;
	}

	.bgcenter {
		background: url("../../static/img/nav_middle.png") repeat-y;
		background-size: 100% 100%;
		padding: 15rpx 20rpx;
	}

	.time {
		padding: 20rpx 0;
	}

	.newbox {
		padding: 15rpx 20rpx;
		color: #351C1B;

		box-sizing: border-box;
	}

	.title {}

	.time {
		font-size: 24rpx;
	}

	.bgbottom {
		height: 40rpx;
	}
</style>
