<template>
	<view class="page-container">
		<view class="search-box-common">
			<image src="/static/images/search-icon.png" class="search-icon"></image>
			<input placeholder="搜索" placeholder-class="placeholder-class" />
		</view>

		<scroll-view class="scroll-view-index" scroll-y :show-scrollbar="false" @scrolltolower="loadMore">
			<template v-for="(item,index) in list">
				<dynamic-item :form="item" @refresh="getList" ></dynamic-item>
			</template>
		</scroll-view>
		<!-- 发布按钮 -->
		<view class="add-dynamic-box" @click="toPublishPage"> 
			<image class="icon" src="/static/images/publish-icon.png"></image>
		</view>
		
		
		
	</view>
</template>

<script>
	import DynamicItem from '@/components/Dynamic-Item.vue'
	import {dynamicList} from '@/api/api.js'
	export default {
		data() {
			return {
				list: [],
				queryParams:{
					pageNum:1,
					pageSize:10
				},
				total:0,
				
			}
		},
		components:{
			DynamicItem
		},
		onLoad() {
			this.getList()
			let _this = this;
			uni.$on('hanldeDynamicRefresh',function(){
				_this.getList()
			})
		},
		beforeDestroy() {
			uni.$off('hanldeDynamicRefresh')
		},
		methods: {
			getList(){
				dynamicList(this.queryParams).then(res=>{
					console.log(res)
					this.list = res.rows
				})
			},
			loadMore() {

			},
			toPublishPage(){
				uni.navigateTo({
					url:'/pages/publish/publish'
				})
			},
			toPKDetailPage(){
				uni.navigateTo({
					url:'/pages/pk-detail/pk-detail'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/styles/index.scss';
</style>