<template>
	<view class="u-flex u-f-d-c">
		<!-- 	<view class="u-font-24 u-m-t-14" style="color: #a6a6a6;">我的评价 </view> -->
		<view class="u-m-t-60">
			<u-rate size="56" gutter="18" active-color="#f6db4d" :count="count" v-model="form.score"></u-rate>
			<view class="u-font-28 u-flex u-box-active6" style="color: #a6a6a6;">
				<view v-for="(index,key) in text" :key="key" :class="key==0?'':'u-m-l-20'">{{index}}</view>
			</view>
		</view>
		<!-- <view class="u-m-t-26 u-m-b-14 m-w" style="height: 1px;  background: #d9d9d9;"></view> -->
		<view class="  m-w textar u-m-l-6" style=" background:#FFFFFF;">
			<textarea v-model="form.content" maxlength="300" placeholder="请输入300字以内的评价" />
		</view>
		<view class="eva-btn" @click="submit"> 评论</view>
		<u-toast ref="evast" />
	</view>
</template>

<script>
	import {
		commentsave
	} from '@/api/index'
	export default {
		data() {
			return {
				count: 5,
				text: ['极差', '较差', '一般', '不错', '很棒'],
				form: {
					score: undefined,
					respondentUserId: null,
					respondentUsername: null,
					content: undefined,
				}
			}
		},
		onLoad(option) {
			this.form.respondentUserId = option.userId
			this.form.respondentUsername = option.username
		},
		methods: {
			submit() {
				const {
					content,
					score
				} = this.form
				if (content && score) {
					commentsave(this.form)
						.then(({
							data,
							message,
							code
						}) => {
							if (code == 200) {
								this.$refs.evast.show({
									title: "评价成功",
									type: 'success',
									callback: () => {
										uni.navigateBack(1)
									}
								})
							} else {
								this.$refs.evast.show({
									title: "评价失败",
									type: 'info',
								})
							}
						})
				} else {
					this.$refs.evast.show({
						title: '请评价和评论',
						type: 'error',
					})
				}
			},
		}
	}
</script>

<style>
	.textar {
		box-sizing: border-box;
		width: 690rpx !important;
		height: 300rpx;
		background: #F2F2F2;
		margin-top: 65rpx;

	}

	.textar textarea {
		box-sizing: border-box;
		width: 100%;
		height: 300rpx;
		background: #F2F2F2;
		padding: 30rpx;

	}

	.eva-btn {
		width: 690rpx;
		height: 90rpx;
		background: #4A8BFF;
		border-radius: 4rpx;
		font-size: 28rpx;
		font-family: Microsoft YaHei-3970(82674968);
		font-weight: bold;
		color: #FFFFFF;
		line-height: 90rpx;
		text-align: center;
		margin-top: 36rpx;
	}
</style>
