<template>
	<view class="bg">
		<view class="topLeft flex-center">
			<span class="iconfont" @click="goBack">&#xe660;</span>
		</view>
		<img :src="showImg(headImg)" class="topImg" />
		
		<navigator :url="'/subPackages/novelty/detail?id='+item.id" v-for="(item,index) in list" :key="index" class="item">
			<image class="img" :src="showImg(item.image)" mode="aspectFill"></image>
			<view class="content flex-column">
				<view class="title">{{item.title}}</view>
				<view class="subtitle flex-between">
					<view>
						<image src="https://static.ticket.sz-trip.com/tongli/images/index/user.png" mode=""></image>
						{{item.author}}
					</view>
					<view>
						<image src="https://static.ticket.sz-trip.com/tongli/images/index/eye.png" mode=""></image>
						{{item.view}}
					</view>
				</view>
			</view>
		</navigator>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				finished: false,
				headImg: ''
			}
		},
		onReady() {
			this.getHeadImg('shuhui').then(res => {this.headImg = res})
			this.getArticleByType()
		},
		methods: {
			// 游记攻略
			getArticleByType() {
				this.Post({
					type_id: 46,
					offset: this.list.length,
					limit: 10
				},'/api/Article/getArticleByType').then(res => {
					if (res.data.length < 10) {
						this.finished = true
					}
					this.list = [...this.list, ...res.data]
				})
			},
		},
		//下拉触底事件
		onReachBottom() {
			setTimeout(() => {
				if (!this.finished) this.getArticleByType();
			}, 1000);
		}
	}
</script>

<style lang="scss" scoped>
	.bg {
		width: 750rpx;
		min-height: 100vh;
		background: #F7F7F7;
		padding-bottom: 100rpx;
	}
	
	.topImg {
		width: 100%;
		height: 440rpx;
	}
	
	.item {
		width: 697rpx;
		height: 227rpx;
		background: #FFFFFF;
		border-radius: 13rpx;
		margin: 26rpx auto 0;
		display: flex;
		
		.img {
			width: 280rpx;
			height: 227rpx;
			border-radius: 13rpx;
		}
		
		.content {
			width: 370rpx;
			height: 227rpx;
			margin-left: 20rpx;
			padding: 15rpx 0;
			justify-content: space-between;
			
			.title {
				font-weight: bold;
				font-size: 31rpx;
				color: #000000;
			}
			
			.subtitle {
				font-weight: 500;
				font-size: 27rpx;
				color: #666666;
				
				image {
					width: 26rpx;
					height: 26rpx;
					margin-right: 6rpx;
					vertical-align: text-bottom;
				}
			}
		}
	}
</style>