<template>
	<view class="center">
		<view class="feedback_info">
			<view class="flex row">
				<view class="left-text" v-if="type == '投诉结果'">反馈时间</view>
				<view class="left-text" v-else>举报时间</view>
				<view class="flex right-text">
					{{formData.createDate}}
				</view>
			</view>
			<view class="flex row">
				<view class="left-text" v-if="type == '投诉结果'">反馈对象</view>
				<view class="left-text" v-else>举报对象</view>
				<view class="flex right-text">
					{{formData.passive}}
				</view>
			</view>
			<view class="flex row">
				<view class="left-text" v-if="type == '投诉结果'">反馈内容</view>
				<view class="left-text" v-else>举报内容</view>
				<view class="flex right-text">
					{{formData.content}}
				</view>
			</view>
			<view class="flex row">
				<view class="left-text">处理结果</view>
				<view class="flex right-text">
					{{formData.processingResults}}
				</view>
			</view>
			<view class="row">
				<view class="">您对处理结果是否满意</view>
				<view class="flex score_css">
					<u-rate :count="count" v-model="scoreValue" @change="scoreChange">
					</u-rate>
					<span style="margin-left: 30rpx;">{{score}}</span>

				</view>
			</view>
		</view>
		<u-toast ref="uToast"></u-toast>
		<u-modal :show="showPips" :title="title" :content='content' showCancelButton @close="showPips = false"
			@cancel="showPips=false" @confirm="$u.throttle(confirmSubmit(), 1000)"></u-modal>
		<u-button type="primary" text="提交" @click="submit"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				count: "5",
				scoreValue: "",
				id: "",
				type: "",
				formData: {},
				score: "非常满意",
				showPips: false,
				title: "",
				content: ""

			}
		},
		onShow() {
			this.getList()

		},
		onLoad(options) {
			this.id = options.id
			this.type = options.type
			if (this.type == '举报结果') {
				uni.setNavigationBarTitle({
					title: '举报处理结果'
				})
			}
		},
		methods: {
			submit() {
				if (this.formData.processingResultsSatisfaction == null) { //未提交过
					this.title = "确定提交反馈结果？"
					this.showPips = true
					this.formData.processingResultsSatisfaction = this.scoreValue
					this.formData.editFlag = 1
				} else { //提交过
					this.$refs.uToast.show({
						type: 'error',
						message: "您已提交过了哦！"
					})
					return
				}
			},
			confirmSubmit() {
				this.$request.baseRequest('post', '/feedbackReport/api/editInfo', this.formData).then(res => {
					if (res.code == 200) {
						this.showPips = false
						this.$refs.uToast.show({
							type: 'success',
							message: "提交成功！",
							complete() {
								uni.navigateBack({
									delta: 1
								})
							}
						})
					}
				})
			},

			scoreChange(e) {
				this.scoreValue = e
				if (this.scoreValue == 1) {
					this.score = "极不满意"
				} else if (this.scoreValue == 2) {
					this.score = "不满意"
				} else if (this.scoreValue == 3) {
					this.score = "一般"
				} else if (this.scoreValue == 4) {
					this.score = "满意"
				} else if (this.scoreValue == 5) {
					this.score = "非常满意"
				}
			},
			getList() {
				this.$request.baseRequest('get', '/feedbackReport/getInfo', {
					id: this.id
				}).then(res => {
					this.formData = res.data
					this.scoreValue = "5"
				})

			}

		}
	}
</script>

<style lang="scss" scoped>
	.center {
		padding: 20rpx;

		.feedback_info {
			.row {
				margin: 30rpx 0;
			}

			.left-text {
				// background: red;
				width: 40%;
				color: #333333;
				display: flex;
				align-items: center;
			}

			.right-text {
				width: 60%;
				justify-content: flex-end;
			}

			.date_css {
				text-align: right;
			}

			.score_css {
				margin-top: 15rpx;
			}
		}

	}
</style>
