<template>
	<view >
		<view class="content">
			<view class="ping" >
				<view class="title">
					咨询评价
				</view>
				<view class="doc-box" v-if="report!=null">
					<view class="left">
						<image :src="report.avatar" mode="aspectFill"></image>
					</view>
					<view class="right">
						<view class="doc-name-box">
							<view class="doc-name">
								{{report.doctorName}}
							</view>
						</view>
					</view>
					
				</view>
				<view class="ping-star">
					<text class="label">评分</text>
					<view class="star">
						<u-rate  size="24" active-color="#fcab36"  v-model="form.pingStar"></u-rate>
					</view>
				</view>
				<view class="ping-content">
					<view class="textarea-box">
						<textarea   v-model="form.pingContent"   placeholder="写入您对医生的评价吧" maxlength="200"   />
						<view class="num-box">{{ form.pingContent.length }}/200</view>
					</view>
				</view>
			</view>
		</view>
		<view class="btn-box">
			<view class="btn" @click="submit()">提交评价</view>
		</view>
	</view>
</template>

<script>
	import {pingReport,getDrugReportById} from '@/api/drugReport'
	export default {
		data() {
			return {
				report:null,
				form:{
					reportId:null,
					pingStar:0,
					pingContent:"",
					 
				}
			}
		},
		onLoad(options) {
			this.form.reportId=options.reportId;
			this.getDrugReportById()
		},
		methods: {
			
			getDrugReportById(){
				var that=this;
				var data={reportId:this.form.reportId}
				getDrugReportById(data).then(
					res => {
						if(res.code==200){
							this.report=res.data;
						}
					},
					err => {
					}
				);
				
			},
			submit(){
				uni.showLoading({
					title:"处理中..."
				})
				pingReport(this.form).then(
					res => {
						uni.hideLoading()
						if(res.code==200){
							uni.showToast({
								icon:'success',
								title: "评价成功",
							});
							uni.$emit('refreshDrugReportList');
							setTimeout(function(){
								uni.navigateBack({
									delta:1,
								})
							},2000);
						}else{
							uni.showToast({
								icon:'none',
								title: res.msg,
							});
						}
					},
					rej => {}
				);
			},
			 
			 
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding: 20rpx 20rpx 140rpx 20rpx;
	}
	.ping{
		margin-bottom:20rpx;
		padding: 20rpx;
		border-radius: 15rpx;
		background: #FFFFFF;
		.title{
			font-size: 34upx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #0F1826;
		}
		.doc-box{
			margin-top: 30rpx;
			display: flex;
			align-items: center;
			justify-content: flex-start;
			.left{
				width: 100upx;
				height: 100upx;
				image{
					border-radius: 50%;
					width: 100upx;
					height: 100upx;
				}
			}
			.right{
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				margin-left: 20rpx;
				height:120upx;
				width: 100%;
				.doc-name-box{
					display: flex;
					align-items: center;
					justify-content: flex-start;
					position: relative;
					.doc-name{
						font-size: 32rpx;
					}
					 
				}
				 
				 
			}
			
		}
		.ping-star{
			padding-top: 30rpx;
			.label{
				font-size: 32upx;
				font-weight: bold;
				font-family: PingFang SC;
				color: #0F1826;
			}
			.star{
				margin-top: 10rpx;
			}
		}
		.ping-content{
			width: 100%;
			padding: 30rpx 0rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			 .textarea-box{
				 width: 100%;
			 	box-sizing: border-box;
			 	height: 330upx;
			 	background: #f6f6f6;
			 	border-radius: 10upx;
			 	padding: 30upx;
			 	position: relative;
			 	.textarea-place{
			 		font-size: 28upx;
			 		font-family: PingFang SC;
			 		font-weight: 400;
			 		color: #C9CED6;
			 	}
			 	textarea{
			 		width: 100%;
			 		height: 100%;
			 		font-size: 28upx;
			 		font-family: PingFang SC;
			 		font-weight: 400;
			 		color: #000000;
			 	}
			 	.num-box{
			 		position: absolute;
			 		right: 20upx;
			 		bottom: 20upx;
			 		font-size: 24upx;
			 		font-family: PingFang SC;
			 		font-weight: 400;
			 		color: #C9CED6;
			 		z-index: 10;
			 		background: #F5F6FA;
			 	}
			 }
		}
	}
	.btn-box{
		height: 140upx;
		z-index: 9999;
		width: 100%;
		padding: 0rpx 30upx;
		position: fixed;
		bottom: 0;
		left: 0;
		box-sizing: border-box;
		background-color: #ffffff;
		display: flex;
		align-items: center;
		justify-content: center;
		.btn{
			width: 100%;
			height: 88upx;
			line-height: 88upx;
			text-align: center;
			font-size: 34upx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			background: #C39A58;
			border-radius: 10upx;
		}
	}
</style>
