<template>
	<view class="main">
		<view>
			<view class="uni-padding-wrap" style="margin-bottom:20upx">
				<view class="uni-title" >请对本次服务做出评价</view>
				<view>
					<radio-group @change="radioChange">
						<label class="radio" v-for="(item, index) in items" :key="item.value">
							<radio class="rediobox" :value="item.value" :checked="index === current" />
							{{ item.name }}
						</label>
					</radio-group>
				</view>
			</view>
		</view>
		<view class="content"><textarea style="border: 1px solid #e5e5e5;border-radius: 10upx;font-size: 28upx;padding: 10upx;" value="" placeholder="请输入评价内容" maxlength="100" v-model="evContent" /></view>
		
		<view class="footer-btn"><view class="btn" @click="submit()">提交</view></view>
	</view>
</template>

<script>
import uniRate from '@/components/uni-rate/uni-rate.vue';
import { submitEvaluate, saveHaircutComment } from '@/common/api.js';
import { callbackRequest, getStorage, alertTip, sureAlterTip } from '@/common/util.js';
export default {
	components: { uniRate },
	data() {
		return {
			evContent:'',
			items: [
				{
					value: '0',
					name: '非常满意'
				},
				{
					value: '1',
					name: '满意',
					checked: 'true'
				},
				{
					value: '2',
					name: '一般'
				}
			],
			current: 0
		};
	},
	onLoad(option) {
		this.type = option.type;
		this.typeId = option.typeId;
		this.spareId = option.spareId;
	},
	methods: {
		radioChange: function(evt) {
			for (let i = 0; i < this.items.length; i++) {
				if (this.items[i].value === evt.target.value) {
					this.current = i;
					break;
				}
			}
		},
		submit() {
			var data = {
				method: saveHaircutComment,
				data: {
					detailId: this.typeId,
					userId: getStorage('userInfo').id,
					applicantName: getStorage('userInfo').username,
					commentContent: this.evContent,
					satisfiedLevel: this.current,
					type:5
				}
			};
			callbackRequest(data).then(res => {
				if(res.data.returnCode == 1){
						alertTip('评价成功');
						setTimeout(res => {
							// uni.redirectTo({
							// 	url: '/pages/cars-management/cars-management?currentTabIndex=1'
							// });
							uni.navigateBack(1);
						}, 1500)
					}else {
						alertTip(res.data.returnMsg)
					}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
@import '@/static/css/common.scss';
.main {
	min-height: 100vh;
	background: #f8f8f8;
}
.content {
	padding: 30rpx;
	background: #fff;
	textarea {
		width: 100%;
		height: 300rpx;
		font-size: 35rpx;
		color: #666;
		line-height: 40rpx;
	}
}
.grade {
	font-size: 28upx;
	padding: 30rpx;
	text {
		font-size: 28rpx;
		color: #444;
		font-weight: bold;
	}
}
.grade .rate {
	margin-left: 80upx;
	margin-top: -18upx;
}
.uni-title {
	padding: 20upx 0upx;
	margin-left: 20px;
	font-size: 18px;
}
.radio {
	padding: 0 20px;
	width: 100%;
	height: 300rpx;
	font-size: 28upx;
	color: #666;
	line-height: 40rpx;
	style: 'transform:scale(0.7)';
}
// .radio {
	
// 	padding: 0 20px;
// 	font-size: 38upx;
// }
.rediobox {
	font-size: 28upx;
	margin-top: 20px;
	width: 20px;
	height: 20px;
}
/deep/.rediobox .uni-radio-input,
/deep/.rediobox .uni-radio-wrapper {
	width: 100%;
	height: 100%;
	border: #e5e5e5;
}
/deep/ .rediobox .uni-radio-input {
	margin-right: 0;
}
</style>
