<template>
	<view>
		<uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="详情"></uni-nav-bar>
		<u-swiper :list="list" height="428"></u-swiper>
		<view class="quiz">
			<view class="quiz_username">
				<image src="../../static/image/expertDiagnosis/6940a11a251770f1b0d8b7b10ebdf9b.png" mode="" v-if="Number(quizdata.heat)==1"></image>
				<span>{{quizdata.title}}</span>
			</view>
			<view class="quiz_usertime">
				<view style="display: flex;align-items: center;">
					<image src="../../static/image/fourMoodBase/touxiang.png" mode=""></image>
					<span>{{quizdata.username}}</span>
				</view>
				<view>
					<span>{{quizdata.adtime|timeFormat()}}</span>
				</view>
			</view>
			<view class="quiz_usercontert" v-html="quizdata.content"></view>
		</view>
		<view class="comment">
			<p class="comment_title">评论</p>
			<view class="comment_unit" v-for="(item,index) in commentdata" :key="index">
				<view class="comment_unit_user">
					<view class="username">
						<image :src="item.image" mode=""></image>
						<span style="font-size: 26rpx;color:#C1C1C1;">{{item.username}}</span>
						<p v-if="Number(item.user_type) == 1">专家</p>
					</view>
					<view>
						<span style="font-size: 26rpx;color:#C1C1C1;">{{item.uptime|timeFormat()}}</span>
					</view>
				</view>
				<view class="comment_unit_con">
					<p v-html="item.content"></p>
				</view>
			</view>
		</view>
		<view class="issue">
			<input type="text" v-model="issuedata"/>
			<p @click="issue">发布</p>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{}],
				quizdata: {},
				commentdata: [],
				issuedata:'',
				defaultimg: '/images/expertDiagnosis/img01.png',
			}
		},
		methods: {//
			async getParticulars(data) {
				const res = await this.$myRequest({
					url: '/api/api_gateway?method=pest.pests.pests_answers_list',
					data: {
						lower: data.lower
					}
				})
				this.commentdata = res.data
				console.log(this.commentdata)
			},
			async getDiscuss(data) {
				const res = await this.$myRequest({
					url: '/api/api_gateway?method=pest.pests.pests_new_idea',
					data: {
						lower: data.lower,
						content:data.content
					}
				})
				console.log(res)
			},
			clickLeft() {
				uni.navigateTo({
					url: "exchangeShare"
				})
			},
			issue(){//发布评论
				let obj = {}
				obj.lower = this.quizdata.lower
				obj.content=this.issuedata
				if(this.issuedata!=''){
					this.getDiscuss(obj)
				}
				uni.navigateTo({
					url:"particulars?items="+JSON.stringify(this.quizdata)
				})
			}
		},
		onLoad(option) {
			this.quizdata = JSON.parse(option.items)
			console.log(this.quizdata.img_urls)
			if(this.quizdata.img_urls =='' || this.quizdata.img_urls ==null){
				this.list[0].image = 'http://static.yfpyx.com/projectimg'+this.defaultimg
			}else{
				this.list[0].image = this.quizdata.img_urls
			}
			let data = {}
			data.lower = this.quizdata.lower
			this.getParticulars(data)
		}
	}
</script>
<style lang="scss">
	.u-swiper-wrap {
		width: 95%;
		margin: 20rpx auto;
	}

	.quiz {
		width: 95%;
		margin: 20rpx auto;
		border-bottom: 4rpx dashed #E8E8E8;

		.quiz_username {
			width: 100%;

			image {
				width: 40rpx;
				height: 40rpx;
				vertical-align: middle;
				margin-right: 20rpx;
			}
			span{
				font-weight: 700;
				font-size: 32rpx;
			}
		}

		.quiz_usertime {
			width: 100%;
			margin-top: 15rpx;
			display: flex;
			justify-content: space-between;

			image {
				width: 50rpx;
				height: 50rpx;
				margin-right: 20rpx;
			}

			span {
				font-size: 12rpx;
				color: #C1C1C1;
			}
		}

		.quiz_usercontert {
			padding: 20rpx;
			margin-bottom: 20rpx;
		}
	}

	.comment {
		width: 95%;
		margin: 20rpx auto 0;

		.comment_title {
			font-weight: 700;
			font-size: 32rpx;
		}

		.comment_unit {
			.comment_unit_user {
				display: flex;
				justify-content: space-between;
				margin-top: 20rpx;
				.username {
					display: flex;
					align-items: center;

					image {
						width: 50rpx;
						height: 50rpx;
						margin-right: 20rpx;
						border-radius: 50%;
					}
					p{
						width: 60rpx;
						height: 30rpx;
						color: white;
						background-color: #5CA348;
						font-size: 24rpx;
						text-align: center;
						line-height: 30rpx;
						padding: 0 10rpx;
						margin-left: 20rpx;
						border-radius: 8rpx;
					}
				}
			}

			.comment_unit_con {
				padding-left: 60rpx;
				/deep/p {
					margin-top: 20rpx;
					img {
						margin-top: 20rpx;
						display: block;
						width: 180rpx !important;
						height: 180rpx !important;
					}
				}

			}
		}
	}
	.issue{
		width: 95%;
		position: fixed;
		bottom: 0;
		left: 2.5%;
		display: flex;
		padding-bottom: 20rpx;
		input{
			width: 90%;
			background-color: #F3F3F3;
			height: 60rpx;
			text-indent: 1em;
		}
		p{
			width: 10%;
			text-align: right;
			line-height: 60rpx;
			color: #7a7a7a;
		}
	}
</style>
