<template>
	<view class="pad-x50" v-if="loading">
		<view class="disac pad-zy20 pad-sx30">
			<view class="cricle-box"></view>
			<view class="fon36 mar-z20">处理反馈</view>
		</view>
		<view class="pad-zy20 fon30" style="background-color: #f5f5f5;">
			<view class="col9 pad-sx30">{{detail.opinion.operateLog[0].operated_at || ''}}</view>
			<view class="disjb bbot pad-x30">
				<view class="">调查情况</view>
				<view class="col9 tright" style="max-width: 50%;">{{detail.opinion.operateLog[0].operate_desc || '无'}}</view>
			</view>
			<view class="disjb bbot pad-sx30">
				<view class="">处理结果</view>
				<view class="col9 tright" style="max-width: 50%;">{{detail.opinion.operateLog[0].operate_result || '无'}}</view>
			</view>
		</view>
		<view class="disac pad-zy20 pad-sx30">
			<view class="cricle-box"></view>
			<view class="fon36 mar-z20">历史反馈</view>
		</view>
		<view class="" v-if="detail.feedbackLog">
			<view class="pad-zy20 fon30" style="background-color: #f5f5f5;" v-for="(item,index) in detail.opinion.feedbackLog" :key="index">
				<view class="col9 pad-sx30">{{item.create_time}}</view>
				<view class="disjb pad-x30">
					<view class="">反馈意见（{{['不满意','满意'][item.satisfied]}}）</view>
					<view class="col9 tright" style="max-width: 50%;">{{item.content}}</view>
				</view>
			</view>
		</view>
		<view class="disac pad-zy20 pad-sx30">
			<view class="cricle-box"></view>
			<view class="fon36 mar-z20">反馈提交</view>
		</view>
		<view class="disjcac pad-zy20">
			<view @tap="chooseType" class="disjbac radius30 width100 pad-sx20 pad-zy30" style="border: 2rpx solid #d9d9d9;">
				<view class="col9 fon30">{{typeText}}</view>
				<i class="icon icon-zsj colb fon24"></i>
			</view>
		</view>
		<view class="disjcac pad-zy20 mar-s30">
			<view class="disjbac radius30 width100 pad-sx20 pad-zy30" style="border: 2rpx solid #d9d9d9;box-sizing: border-box;">
				<textarea class="col9 fon30" v-model="content" style="height: 272rpx;" placeholder="请输入反馈信息"></textarea>
			</view>
		</view>
		<view class="disjcac mar-s70">
			<view class="disjcac enter-btn" style="margin: 0;" @tap="setFeedBack">提交反馈</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				typeList:['满意','不满意'],
				typeText:'满意',
				content:'',
				id:'',
				detail:'',
				loading:false,
				flag:true
			}
		},
		onLoad(op) {
			this.id = op.id;
			this.getDetailEv(op.id);
		},
		methods: {
			// 查询工单详情
			getDetailEv(id){
				this.$toolAll.tools.showToast('加载中...');
				this.$requst.post('user/feedback-load',{id}).then(res => {
					if(res.code==0){
						this.detail = res.data;
						this.loading = true;
						uni.hideToast();
					} else {
						this.$toolAll.tools.showToast(res.msg);
					}
					uni.hideLoading();
					this.isLoading = true;
				})
			},
			// 选择类型
			chooseType(){
				uni.showActionSheet({
					itemList:this.typeList,
					success: (res) => {
						this.typeText = this.typeList[res.tapIndex];
					}
				})
			},
			// 反馈提交
			setFeedBack(){
				if(this.flag){
					this.flag = false;
					let params = {
						satisfied:this.typeText=="满意"?1:0,
						content:this.content,
						id:this.id
					}
					this.$toolAll.tools.showToast('正在提交...');
					this.$requst.post('user/create-feedback',params).then(res=>{
						if(res.code==0){
							this.$toolAll.tools.showToast('提交成功');
							setTimeout(()=>{
								uni.navigateBack({
									delta:1
								})
							},500)
						}
					})
					setTimeout(()=>{
						this.flag = true;
					},2000)
				} else {
					this.$toolAll.tools.showToast('请勿重复提交');
				}
			}
		}
	}
</script>

<style>
</style>
