<template>
	<view class="detail-page-container">
		<dynamic-item :form="form" @refresh="handleRefresh"></dynamic-item>
		<!-- 评论管理区 -->
		<comment-item  :form="form" ></comment-item>
	</view>
</template>

<script>
	import DynamicItem from '@/components/Dynamic-Item.vue';
	import CommentItem from '../../components/Comment-Item.vue';
	import {dynamicDetail,dynamicDetailComments} from '@/api/api.js'
	export default {
		data() {
			return {
				momentId:'',
				form:{},
				queryParams:{
					pageNum:1,
					pageSize:10,
					momentId:''
				},
				commentList:[]
			}
		},
		onLoad(options){
			let {momentId} = options;
			this.momentId = momentId;
			this.queryParams.momentId = momentId
			this.getDetail()
			// this.getCommentList()
		},
		components: {
			DynamicItem,
			CommentItem
		},
		methods: {
			handleRefresh(){
				this.getDetail();
				this.getCommentList()
			},
			getDetail(){
				dynamicDetail(this.momentId).then(res=>{
					if(res.code == 200){
						this.form = {...res.data}
					}
				})
			},
			getCommentList(){
				dynamicDetailComments(this.queryParams).then(res=>{
					console.log(res)
					this.commentList = res.rows
				})
			}
		}
	}
</script>

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