<!-- 意见反馈 -->

<template>
	<view v-if="allow" class="main_width">
		<textarea :value="content" @input="ipt_change" placeholder="请输入意见反馈" class="main_text_area"></textarea>
		<view @click="confirm" class="main_btn">确定</view>
	</view>
	<view style="text-align: center;margin-top: 60upx;" v-else>感谢您的反馈，请耐心等待！</view>
</template>

<script>
	import commonData from '../../../commonData.js'
	import commonFun from '../../../commonFun.js'

	export default {
		data() {
			return {
				content: '',
				allow: false,
			}
		},
		methods: {
			// 获取最新反馈（如果反馈了未回复则不允许继续反馈）
			get_data() {
				uni.showLoading({
					title: '加载中...',
					mask: true
				})
				commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle', {
						bizCatalog: 'InteractionEntity',
						handleMode: 'fetchLastSuggestion',
					},
					res => {
						if (res.status) {
							uni.hideLoading()
							console.log('获取最新反馈结果')
							console.log(res)
							if (!res.data.Result) {
								this.allow = true
								return
							}
							if (res.data.Result.status == 3) {
								this.allow = true
								return
							}
						}
					})
			},
			ipt_change(e) {
				this.content = e.target.value
			},
			confirm() {
				if (this.content == '') {
					uni.showModal({
						content: '请输入反馈内容！',
						showCancel: false,
					});
					return
				}
				uni.showLoading({
					title: '加载中...',
					mask: true
				})
				commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle', {
						bizCatalog: 'InteractionEntity',
						handleMode: 'submitNewSuggestion',
						content: this.content
					},
					res => {
						if (res.status) {
							uni.showModal({
								content: '反馈成功！',
								showCancel: false,
								success: () => {
									uni.navigateBack({
										delta: 1
									})
								}
							})
							uni.hideLoading()
						}
					})
			},
		},
		components: {},
		onLoad() {
			this.get_data()
		},
	}
</script>

<style>
	page {}
</style>
