<template>
	<view class="feedback-container">
	
		
		<!-- 顶部导航栏 -->
		<navBar :title="'投诉反馈'"></navBar>
		
		<!-- 反馈输入区域 -->
		<view class="feedback-input-container">
			<view class="input-area">
				<!-- <text class="input-placeholder" v-show="!feedbackText">欢迎对我们的软件提供建议,帮助我们更好更快的改进"肝胆相照"APP (200字以内)</text> -->
				<textarea 
					class="feedback-textarea" 
					v-model="feedbackText"
					:maxlength="200"
					placeholder="尊敬的医生您好，若在交流过程中发现患者发布不适当内容，请您及时填写相关信息，我们将第一时间处理，谢谢您的支持。"
					:adjust-position="false"
					@input="onInput"
				></textarea>
				<!-- <view class="voice-button" @click="toggleVoiceInput">
					<text class="voice-icon">🎙</text>
				</view> -->
			</view>
		</view>
		
		<!-- 底部提交按钮 -->
		<view class="submit-container">
			<button class="submit-btn" @click="submitFeedback" >
				提交
			</button>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	import api from '@/api/api';
	const feedbackText = ref('');
	import navBar from "@/components/navBar/navBar.vue"
	// 返回上一页
	const goBack = () => {
		uni.navigateBack();
	};
	
	// 输入处理
	const onInput = (e) => {
		feedbackText.value = e.detail.value;
	};
	
	// 语音输入切换
	const toggleVoiceInput = () => {
		uni.showToast({
			title: '语音输入功能',
			icon: 'none'
		});
	};
	
	// 提交反馈
	const submitFeedback = () => {
		if (!feedbackText.value.trim()) {
			uni.showToast({
				title: '请输入反馈内容',
				icon: 'none'
			});
			return;
		}
		
		uni.showLoading({
			title: '提交中...'
		});
		
		api.addFeedBack({
			content: feedbackText.value
		}).then(res => {
			console.log(res);
			uni.hideLoading();
			uni.showToast({ title: '提交成功', icon: 'none' });
		});
		uni.navigateBack();
	};
</script>

<style scoped>
	.feedback-container {
		background-color: #ffffff;
		min-height: 100vh;
		position: relative;
	}
	
	/* 状态栏占位 */
	.status-bar {
		height: 44rpx;
		background-color: #ffffff;
	}
	
	/* 导航栏样式 */
	.nav-bar {
		display: flex;
		align-items: center;
		height: 88rpx;
		background-color: #f5f5f5;
		padding: 0 30rpx;
		position: relative;
		border-bottom: 1rpx solid #e0e0e0;
	}
	
	.nav-left {
		position: absolute;
		left: 30rpx;
		z-index: 1;
	}
	
	.back-arrow {
		font-size: 48rpx;
		color: #ff0000;
		font-weight: bold;
		line-height: 1;
	}
	
	.nav-title {
		flex: 1;
		text-align: center;
		font-size: 36rpx;
		color: #ff0000;
		font-weight: 500;
	}
	
	/* 反馈输入区域 */
	.feedback-input-container {
		top: calc(var(--status-bar-height) + 44px);
		position: fixed;
		left: 0;
		right: 0;
		bottom: 160rpx;
		overflow-y: scroll;
		z-index: 1;
		padding: 30rpx;
		box-sizing: border-box;
	}
	
	.input-area {
		position: relative;
		background-color: #ffffff;
		border: 2rpx solid #e0e0e0;
		border-radius: 8rpx;
		min-height: 400rpx;
		padding: 30rpx;
	}
	
	.input-placeholder {
		position: absolute;
		top: 30rpx;
		left: 30rpx;
		font-size: 28rpx;
		color: #999999;
		line-height: 1.5;
		pointer-events: none;
		z-index: 1;
		width: calc(100% - 100rpx);
	}
	
	.feedback-textarea {
		width: 100%;
		min-height: 300rpx;
		font-size: 28rpx;
		color: #333333;
		line-height: 1.5;
		background: transparent;
		border: none;
		outline: none;
		resize: none;
		position: relative;
		z-index: 2;
	}
	
	.voice-button {
		position: absolute;
		bottom: 20rpx;
		right: 20rpx;
		width: 60rpx;
		height: 60rpx;
		background-color: #ff0000;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 3;
	}
	
	.voice-icon {
		font-size: 32rpx;
		color: #ffffff;
	}
	
	/* 底部提交按钮 */
	.submit-container {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 30rpx;
		background-color: #ffffff;
		border-top: 1rpx solid #e0e0e0;
		z-index: 999;
	}
	
	.submit-btn {
		width: 100%;
		height: 88rpx;
		background-color: #fff;
		border: 2rpx solid #8B2316;
		border-radius: 8rpx;
		color: #8B2316;
		font-size: 32rpx;
		font-weight: 500;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.submit-btn:active {
		background-color: #fff0f0;
	}
	
	.submit-btn:disabled {
		color: #cccccc;
		border-color: #f0f0f0;
	}
</style>
