<template>
	<view class="postList">
		
		<navbar 
		leftClick
		@leftClick="$utils.navigateBack"
		title="动态列表"/>
		
		<view class="title">
			动态列表
		</view>
		
		<view class="box">
			<view class="search">
				<view class="icon">
					<uv-icon
					size="40rpx"
					name="search"></uv-icon>
				</view>
				<input type="text" placeholder="搜索相关..."/>
				<view class="text">
					搜索
				</view>
			</view>
			
			<postList :list="postList"/>
		</view>
	</view>
</template>

<script>
	import postList from '@/components/post/postList.vue'
	export default {
		components : {
			postList
		},
		data() {
			return {
				postList : [],
				total : 0,
				queryParams : {
					pageNo : 1,
					pageSize : 10,
				}
			}
		},
		onShow() {
			this.getData()
		},
		onReachBottom(){
			let allTotal = this.queryParams.pageNo * this.queryParams.pageSize
			if(allTotal < this.total){
				//当前条数小于总条数 则增加请求数
				this.queryParams.pageSize += 10
				this.getData() //调用加载数据方法
			}
		},
		methods: {
			getData(){
				this.$api('indexGetTrendsPage', this.queryParams, res => {
					if(res.code == 200){
						this.postList = res.result.records
						this.total = res.result.total
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.postList{
	.title{
		padding-top: 20rpx;
		padding-left: 30rpx;
		font-size: 32rpx;
	}
	.box{
		padding: 30rpx;
		.search{
			background-color: #fff;
			height: 70rpx;
			width: 100%;
			margin: 20rpx 0;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 28rpx;
			border-radius: 10rpx;
			.icon{
				margin: 0 20rpx;
			}
			input{
				
			}
			.text{
				margin-left: auto;
				margin-right: 20rpx;
			}
		}
	}
}
</style>
