<template>
	<view class="postDetail">
		<navbar leftClick @leftClick="$utils.navigateBack" />

		<view class="swipe">
			<uv-swiper 
			:list="item.image &&
			item.image.split(',')" 
			indicator 
			height="320rpx"></uv-swiper>
		</view>

		<view class="box">

			<view class="topInfo">
				<view class="title">
					{{ item.name }}
				</view>
			</view>

			<view class="createBy">
				<view class="">
					发布人：{{ item.userId }}
				</view>
				<view class="">
					发布时间：{{ item.createTime }}
				</view>
			</view>


			<view class="controls">
				<contentControls/>
			</view>


			<view class="content">
				<uv-parse :content="item.photographerContent"></uv-parse>
			</view>
			
			<view class="works">
				<view class="item" 
				v-for="(item, index) in list"
				:key="index">
					<view class="item-title">
						{{ item.title }}
					</view>
					<view class="item-image">
						<image :src="item.image" mode=""></image>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import contentControls from '@/components/content/contentControls.vue'
	export default {
		components : {
			contentControls
		},
		data() {
			return {
				item: {},
				list : [],
				queryParams: {
					pageNo: 1,
					pageSize: 10
				},
				total : 0,
			}
		},
		onLoad(options) {
			// this.$route.query的参数
			this.getData(options.id)
			this.getList()
		},
		//滚动到屏幕底部
		onReachBottom() {
			if(this.queryParams.pageSize < this.total){
				this.queryParams.pageSize += 10
				this.indexGetTrendsPage()
			}
		},
		methods: {
			getData(id){
				this.$api('indexGetActorDetail', {
					id
				}, res => {
					if(res.code == 200){
						this.item = res.result
					}
				})
			},
			getList(){
				this.$api('indexGetGetWorkPage', {
					token : uni.getStorageSync('token')
				}, res => {
					if(res.code == 200){
						this.list = res.result.records
						this.total = res.result.total
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.postDetail {
		.box {
			padding: 20rpx;

			.title {
				font-size: 30rpx;
				font-weight: 600;
				color: #000;
			}

			.createBy {
				display: flex;
				margin-top: auto;
				margin-bottom: 10rpx;
				font-size: 24rpx;
				margin-top: 20rpx;
				color: #555;

				&>view {
					display: flex;
					align-items: center;
					justify-content: center;
					padding-right: 20rpx;
				}
			}

			.controls {
				margin-top: 30rpx;
			}

			.content {
				margin-top: 30rpx;
				color: #777;
			}
			
			.works{
				display: flex;
				flex-wrap: wrap;
				margin-top: 20rpx;
				.item{
					width: 320rpx;
					margin: 15rpx;
					.item-title{
						padding-bottom: 10rpx;
						color: #000;
					}
					.item-image{
						background-color: #999;
						width: 100%;
						height: 250rpx;
						image{
							width: 100%;
							height: 100%;
						}
					}
				}
			}
		}
	}
</style>