<template>
	<view class="page" v-if="showPage">
		<view class="pageMain">
			<view class="padding-30 flex">
				<view class="expertHeader">
					<image :src="pageData.expert_head_img" class="width-100p height-100p block" mode="aspectFill"></image>
				</view>
				<view class="flex-one margin-left-15">
					<view class="flex justify-between margin-bottom-10">
						<view class="flex-one margin-right-15 text-34 text-33 text-bold line-50">
							{{pageData.expert_name}}
						</view>
						<view class="text-32 text-bold text-ff85 text-price">{{pageData.expert_price}}</view>
					</view>
					<view class="text-cut-one text-26 text-909298">{{pageData.expert_brief}}</view>
				</view>
			</view>
			<view class="line15"></view>
			<view class="padding-30 flex align-center justify-between">
				<view class="text-28 line-40">描述相符</view>
				<view class="flex align-center">
					<image src="/static/home/star1.png" v-for="(item,index) in score" :key="index"
						class="starImg margin-left-10" @click="changeScore(index,1)"></image>
					<image src="/static/home/star0.png" v-for="(item,index) in (5-score)" :key="index"
						class="starImg margin-left-10" @click="changeScore(index,2)"></image>
				</view>
			</view>
			<view class="line15"></view>
			<view class="padding-30">
				<view class="flex flex-wrap margin-bottom-40" style="width: calc(100% + 14rpx);">
					<view class="eveTab" :class="item.isChoose ? 'activeTab' : 'normalTab’'"
						v-for="(item,index) in tabs" :key="index" @click="changeTabChoose(index)">
						{{item.name}}
					</view>
				</view>
				<textarea placeholder="亲,专家的服务能够达到您的预期吗?您的评价是我们不断进步的源泉，写点什么吧～" maxlength="200"
					v-model="content" placeholder-class="text-aa" class="text-28 line-45 width-100p height-200"></textarea>
			</view>
		</view>
		<view class="bottomBox">
			<view class="bg-2f9 line-height-100 radius-50 text-center text-fe text-32 text-bold" @click="tapSub">
				确定
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				tabs: [{
					id: 1,
					name: '及时快速',
					isChoose:false,
				}, {
					id: 2,
					name: '很有耐心',
					isChoose:false,
				}, {
					id: 3,
					name: '专业权威',
					isChoose:false,
				}, {
					id: 4,
					name: '详细清楚',
					isChoose:false,
				}],
				score: 5,
				content: '',
				pageData:{},
				showPage:false,
			}
		},
		onLoad(options) {
			this.id = options.id ? options.id:'';
			this.getPageData();
		},


		methods: {
			getPageData(){
				this.rq.getData('fire/api/Fire/getOrderReviewData',{
					order_id : this.id
				}).then(res=>{
					if(res.code == 0){
						this.pageData = res.data.order;
						this.showPage = true;
					}
				})
			},
			changeTabChoose(i) {
				this.tabs[i].isChoose = !this.tabs[i].isChoose;
			},
			changeScore(i, type) {
				if (type == 1) {
					this.score = i + 1;
				} else {
					var s = this.score;
					this.score = s + i + 1;
				}
			},
			tapSub(){
				if(this.score == 0){
					this.cn.alert('请选择描述相符度');
					return;
				}
				if(this.content == ''){
					this.cn.alert('请输入评价内容');
					return;
				}
				var l = [];
				this.tabs.forEach((item,index)=>{
					if(item.isChoose){
						l.push(item.id)
					}
				})
				this.rq.getData('fire/api/Fire/submitOrderReview',{
					order_id : this.id,
					star : this.score,
					content : this.content,
					label : l.join(',')
				}).then(res=>{
					if(res.code == 0){
						this.cn.alert('评价成功').then(()=>{
							// uni.navigateBack({
							// 	delta:1
							// })
							uni.redirectTo({
								url: '/pages/expert/orderList'
							})
						})
					}
				})
			},

		}
	}
</script>

<style scoped>
	.pageMain {
		width: 100vw;
		min-height: 100vh;
		background: #fff;
		padding-bottom: calc(150rpx + env(safe-area-inset-bottom));
		box-sizing: border-box;
	}

	.expertHeader {
		width: 110rpx;
		height: 110rpx;
		border-radius: 10rpx;
		overflow: hidden;
	}

	.line15 {
		width: 100vw;
		height: 15rpx;
		background: #F5F5F5;
	}

	.starImg {
		width: 32rpx;
		height: 32rpx;
	}

	.eveTab {
		width: 158rpx;
		line-height: 56rpx;
		border-radius: 30px;
		font-size: 26rpx;
		margin-right: 14rpx;
		text-align: center;
	}

	.activeTab {
		color: #FF8534;
		border: 2rpx solid #FF8534;
	}

	.normalTab {
		color: #333333;
		border: 2rpx solid #DDDDDD;
	}
	.bottomBox {
		width: 100vw;
		background: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		padding: 10rpx 30rpx calc(10rpx + env(safe-area-inset-bottom));
		box-sizing: border-box;
	}
</style>
