<template>
	<view class="content">
		<u-gap height="30" bgColor="#F8F9FA"></u-gap>
		<view class="evaluationModel">
			<view class="evaluationTitle">
				满意度
			</view>
			<u-rate :count="count" size="40" activeColor="#FBA808" inactiveColor="#8F92A1" v-model="star"></u-rate>
			<view class="evaluationTitle" style="margin-top: 30rpx;">
				评价
			</view>
			<view class="evaluationInitModel">
				<u--textarea v-model="content" border="none" placeholder="请输入内容"></u--textarea>
			</view>
		</view>
		<view class="evaluationBaseModel">
			<view class="evaluationTitle">
				评价模板
			</view>
			<view class="evaluationInitModel" v-for="(item,index) in evaluationList" :key="index"
				@click="copyText(item.content)">
				{{item.content}}
			</view>
		</view>
		<view class="applyModel">
			<view class="applyBtn" @click="add_comment">提交</view>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				count: 5,
				star: 0,
				content: '',
				evaluationList: [],
				og_id: ''
			}
		},
		onLoad(option) {
			this.og_id = option.id;
			this.getevaluationList()
		},
		methods: {
			//获取我的收藏
			getevaluationList() {
				this.$request('/comment-tpl', 'GET', {

				}).then(res => {
					console.log(res.data)
					this.evaluationList = res.data;
				}).catch(err => {
					uni.showToast({

						icon: 'error',

						title: '' + err.message

					})
				})
			},
			copyText(e) {
				this.content = e;
			},
			add_comment() {
				this.$request('/add-comment', 'POST', {
					og_id: this.og_id,
					star: this.star,
					content: this.content
				}).then(res => {
					this.$refs.uToast.show({
						type: 'success',
						message: "评价成功！",
						iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/jump.png',
						complete() {
							uni.navigateBack()
						}
					})
				}).catch(err => {
					uni.showToast({

						icon: 'error',

						title: '' + err.message

					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100vw;
		height: 100vh;
		background: #F8F9FA;
	}

	.evaluationBaseModel {
		width: calc(100% - 60rpx);
		margin: 0 30rpx;
		height: auto;
		overflow-y: scroll;
		padding-top: 40rpx;
		border-radius: 20rpx;

		.evaluationTitle {
			font-size: 28rpx;
			color: #333333;
			height: 60rpx;
		}

		.evaluationInitModel {
			width: calc(100% - 60rpx);
			padding: 30rpx;
			background-color: #f6f7f8;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			min-height: 100rpx;
			font-size: 28rpx;
			color: #666666;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
		}

	}

	.evaluationModel {
		width: calc(100% - 120rpx);
		margin: 0 30rpx;
		padding: 30rpx;
		height: auto;
		overflow-y: scroll;
		background-color: #ffffff;
		border-radius: 20rpx;

		.evaluationTitle {
			font-size: 28rpx;
			color: #333333;
			height: 60rpx;
		}

		.evaluationTitleTip {
			font-size: 24rpx;
		}

		.evaluationTitleTipicon {
			color: #FF3141;
			font-size: 24rpx;
			margin-left: 10rpx;
		}

		.evaluationInitModel {
			width: calc(100% - 60rpx);
			padding: 30rpx;
			background-color: #f6f7f8;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			min-height: 60rpx;
			line-height: 40rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
		}

	}

	::v-deep .u-textarea {
		background-color: #f6f7f8 !important;
	}
</style>