<template>
	<view class="center">
		<view class="massage flex" v-for="(item, index) in list" :key="index"
			@click="nav('/pages/index/messageInfo?id=' + item.id)">
			<view class="imagebox" v-if="type == 7">
				<image class="image" :src="item.image_input[0]" mode="scaleToFill"></image>
			</view>
			<view class="right flex">
				<view class="title">{{ item.title }}</view>
				<view class="time">{{ item.add_time }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		article
	} from '@/api/user.js';
	export default {
		data() {
			return {
				list: [],
				type: ''
			};
		},
		onLoad(opt) {
			if (opt.type) {
				this.type = opt.type;
				let title = '';
				if (opt.type == 1) {
					title = '官方公告';
				} else if (opt.type == 2) {
					title = '拍品介绍';
				} else if (opt.type == 6) {
					title = '首页新闻';
				} else if (opt.type == 7) {
					title = '最新资讯';
				}
				uni.setNavigationBarTitle({
					title
				});
			}
			let obj = this;
			article({
				page: 1,
				limit: 1000
			}, this.type).then(({
				data
			}) => {
				this.list = data;
			});
		},
		methods: {
			nav(url) {
				uni.navigateTo({
					url
				});
			}
		}
	};
</script>

<style lang="less">
	.center {
		background: #f3f3f3;
		font-family: PingFang SC;

		.right {
			align-self: stretch;
			flex-grow: 1;
			flex-direction: column;
			align-items: flex-start;
		}
		.imagebox{
				flex-shrink: 0;
				padding-right: 20rpx;
			.image{
				width: 200rpx;
				height: 160rpx;
			}
		}
		
	}

	.massage {
		background: #ffffff;
		padding: 30rpx;
		border-bottom: 1px solid #e9e9e9;
		font-weight: 500;

		.title {
			font-size: 28rpx;
			color: #333333;
		}

		.time {
			margin-top: 18rpx;
			font-size: 20rpx;
			color: #999999;
		}
	}
</style>