<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="listnews">
				<view class="newbox justify-between" v-for="(item,index) in list" :key="index" @click="toinfo(item.id)">
					<view class="newboxleft flex-row">
						<u-icon name="grid" color="#351C1B" size="24"></u-icon>
						<text class="title" style="margin-left: 10rpx;">{{item.name}}</text>
					</view>
					<view class="newboxright">
						<text class="time">{{item.created_at}}</text>
					</view>
				</view>
			</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-index',
					2: '/api/mobile/other/traffic-notice-index',
					4: '/api/mobile/other/ask-index'
				},
				type: 1,
				list: [],
				isloading: true
			}
		},
		onLoad(options) {
			let that = this;
			uni.getSystemInfo({
				success: function(res) {
					that.height = res.windowHeight - 60;
				}
			});
			this.type = options.type;
			that.loadList();
		},
		methods: {
			toinfo(id) {
				uni.navigateTo({
					url: "info?type=" + this.type + "&id=" + id
				})
			},
			loadList(page) {
				var that = this;
				this.util.request({
					api: this.urls[this.type],
					data: {
						page: page
					},
					utilSuccess: function(res) {
						that.list = res.data;
						this.isloading = false;
					},
					utilFail: function(res) {
						uni.showToast({
							icon: "none",
							title: res
						})
					}
				})
			}
		}
	}
</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%;
	}

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

		box-sizing: border-box;
	}

	.title {}

	.time {
		font-size: 24rpx;
	}

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