<template>
	<view class="bg">
		<img :src="showImg(headImg)" class="topImg" />
		
		<div class="article-container">
			<navigator :url="'/subPackages/letter/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 text-overflowRows">{{item.title}}</view>
					<view class="text-overflow" style="font-size: 24rpx;color: #848484;">{{item.title}}</view>
					<view class="subtitle flex-between">
						<view style="color: #000000;">
							<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>
							<text style="padding-right: 36rpx;">{{item.view}}</text>
							<image src="https://static.ticket.sz-trip.com/tongli/images/index/eye.png" mode=""></image>
							{{item.view}}
						</view>
					</view>
				</view>
			</navigator>
		</div>
		
	</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]
				})
			},
			handleNum (num) {
				if (num>=1000) {
					return (num/1000).toFixed(1)+'k'
				}
			},
		},
		//下拉触底事件
		onReachBottom() {
			setTimeout(() => {
				if (!this.finished) this.getArticleByType();
			}, 1000);
		}
	}
</script>

<style lang="scss" scoped>
	.bg {
		width: 750rpx;
		min-height: 100vh;
		background: #FFFFFF;
		padding-bottom: 50rpx;
	}
	
	.topImg {
		width: 100%;
		height: 380rpx;
	}
	
	.article-container{
		margin-top: -15rpx;
		width: 100%;
		background: #FFFFFF;
		border-radius: 24rpx ;
		position: relative;
		padding: 32rpx;
	}
	
	.item {
		width: 100%;
		height: 198rpx;
		margin-bottom:30rpx;
		display: flex;
		
		.img {
			width: 208rpx;
			height: 198rpx;
			border-radius: 24rpx;
			flex-shrink: 0;
		}
		
		.content {
			width: 370rpx;
			flex: 1;
			height: 198rpx;
			padding: 12rpx 0 0 24rpx;
			justify-content: space-between;
			
			.title {
				font-weight: 400;
				font-size: 28rpx;
				color: #000000;
			}
			
			.subtitle {
				font-weight: 500;
				font-size: 27rpx;
				color: #848484;
				
				image {
					width: 26rpx;
					height: 26rpx;
					margin-right: 6rpx;
					vertical-align: text-bottom;
				}
			}
		}
	}
</style>