<template>
	<view class="item">
		<view class="love-item" v-for="item in list" :key="item.id" @click="Jump(item.id)">
			<image :src="item.image_input[0]" mode=""></image>
			<view class="content">
				<view class="title">
					{{item.title}}
				</view>
				<view class="time">
					{{item.add_time | time}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getArtList} from '@/api/index.js';
	export default {
		data() {
			return {
				list: [],
				id: 0,
			}
		},
		onLoad(opt) {
			if(opt.id) {
				this.id = opt.id
			}
			this.loadData()
		},
		onShow() {
		},
		filters: {
			time(val) {
				if( val / 1000000000000 < 1){
					val = val*1000
				}
				let date = new Date(val)
				console.log(val,date)
				let Y = date.getFullYear()
				let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth()+1) :( date.getMonth()+1)
				let D = date.getDate()< 10 ? '0' + date.getDate() : date.getDate()
				let h = date.getHours()< 10 ? '0' + date.getHours() : date.getHours()
				let m = date.getMinutes()< 10 ? '0' + date.getMinutes() : date.getMinutes()
				let s = date.getSeconds()< 10 ? '0' + date.getSeconds() : date.getSeconds()
				return Y + '-' + M + '-' + D + ' ' + h +':' + m + ':' + s
			}
		},
		methods:{
			navTo(url) {
				uni.navigateTo({
					url
				})
			},
			loadData(){
				let obj = this;
				getArtList({
					page: 1,
					limit: 100
				},obj.id).then(({ data }) => {
					console.log(data);
					obj.list = data;
				});
			},
			Jump(id) {
				uni.navigateTo({
					url:"/pages/index/artDetail?id="+id
				})	
			},
		}
	}
</script>

<style lang="scss" scoped>
	// .item {}
	.item {
		background-color: #fff;
		
	}
	.love-item {
		margin: 0 auto;
		width: 702rpx;
		height: 208rpx;
		border-bottom: 1px solid #EEEEEE;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		image {
			width: 160rpx;
			height: 160rpx;
			background-color: #eee;
			flex-shrink: 0;
		}
		.content {
			height: 160rpx;
			padding-left: 16rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			
			.title {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
				// line-height: 39px;
			}
			.time {
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
			}
		}
		
	}
</style>
