<template>
	<view class="detail-page-container topic-detail-page">
		<view class="topic-box">
			<view class="topic-container">
				<view class="topic-title-num">
					<view class="title">{{topicName}}</view>
					<view class="num">话题动态数 {{list.length}}</view>
				</view>
				<image src="/static/images/topic.png" class="topic-img"></image>
			</view>
		</view>
		<scroll-view class="scroll-view-topic" scroll-y :show-scrollbar="false" v-if="list.length>0">
			<template v-for="(item,index) in list">
				<dynamic-item :form="item"></dynamic-item>
			</template>
		</scroll-view>
		<scroll-view class="scroll-view-topic" scroll-y :show-scrollbar="false" v-else>
			
		</scroll-view>
		<view class="publisb-box">
			<view class="publish-btn" @click="handleToPublish">
				<image src="/static/images/publish-gray.png" class="icon"></image>
				<view class="text">发表动态</view>
			</view>
		</view>
	</view>
</template>

<script>
	import DynamicItem from '@/components/Dynamic-Item.vue';
	import {topicDynamics} from '@/api/api.js';
	export default {
		data() {
			return {
				list:[],
				topicName:'',
				queryParams:{
					pageNum:1,
					pageSize:10,
					topicId:''
				}
			}
		},
		components:{
			DynamicItem
		},
		onLoad(options) {
			let {topicId,topicName} = options;
			this.topicName = topicName
			if(topicId){
				this.queryParams.topicId = topicId
				this.getDetail()
			}
		},
		methods: {
			getDetail(){
				topicDynamics(this.queryParams).then(res=>{
					console.log(res)
					this.list = res.rows
				})
			},
			handleToPublish(){
				uni.navigateTo({
					url:`/pages/publish/publish?topicId=${this.queryParams.topicId}&topicName=${this.topicName}`
				})
			}
		}
	}
</script>

<style lang="scss">
@import '@/static/styles/common.scss';
.topic-detail-page{
	background-color: white;
	.topic-box{
		padding: 32rpx 34rpx 0 32rpx;
		.topic-container{
			width: 92vw;
			height: 180rpx;
			border-radius: 12rpx;
			background: linear-gradient(89.31deg, rgba(230,246,254,1) 1.2%,rgba(186,239,255,1) 99.53%);
			text-align: center;
			padding: 0 30rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.topic-title-num{
				width: calc(100% - 180rpx);
				text-align: left;
				.title{
					color: rgba(16, 16, 16, 1);
					font-size: 36rpx;
				}
				.num{
					color: rgba(162, 170, 184, 1);
					font-size: 24rpx;
					margin-top: 12rpx;
				}
			}
			.topic-img{
				width: 160rpx;
				height: 160rpx;
			}
		}
	}
	
	.scroll-view-topic{
		@include scroll-view-container(calc(100vh - 340rpx))
	}
	
	.publisb-box{
		height:124rpx ;
		background-color: rgba(244, 244, 244, 1);
		display: flex;
		justify-content: center;
		align-items: center;
		.publish-btn{
			width: 240rpx;
			height: 80rpx;
			border-radius: 12rpx;
			background-color: rgba(255, 255, 255, 1);
			text-align: center;
			border: 1px solid rgba(230, 230, 230, 1);
			display: flex;
			align-items: center;
			justify-content: center;
			.icon{
				width: 36rpx;
				height: 36rpx;
				margin-right: 16rpx;
			}
			.text{
				color: rgba(187, 187, 187, 1);
				font-size: 32rpx;
			}
		}
	}
}
</style>
