import { useRouter } from 'expo-router'; import React, { useState } from 'react'; import { Alert, ImageBackground, ScrollView, StatusBar, StyleSheet, Text, TextInput, TouchableOpacity, View, } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { Images } from '@/constants/images'; import { submitFeedback } from '@/services/base'; const FEEDBACK_TYPES = ['BUG', '建议', '投诉', '其他']; export default function FeedbackScreen() { const router = useRouter(); const insets = useSafeAreaInsets(); const [feedbackType, setFeedbackType] = useState('BUG'); const [feedbackContent, setFeedbackContent] = useState(''); const [loading, setLoading] = useState(false); const maxContentLength = 3000; const handleBack = () => { router.back(); }; const handleSubmit = async () => { if (!feedbackContent.trim()) { Alert.alert('提示', '反馈内容是必填的!'); return; } try { setLoading(true); await submitFeedback({ type: feedbackType, text: feedbackContent.trim(), }); Alert.alert('提示', '提交成功!', [ { text: '确定', onPress: () => router.back() } ]); } catch (error) { console.error('提交失败:', error); Alert.alert('提示', '提交失败'); } finally { setLoading(false); } }; return ( {/* 顶部导航 */} 意见反馈 {/* 类型选择 */} {FEEDBACK_TYPES.map((type) => ( setFeedbackType(type)} > {type} ))} {/* 投诉提示 */} 此投诉为本平台自有投诉渠道 {/* 输入框 */} 0 && styles.countNumActive ]}> {feedbackContent.length} /{maxContentLength} {/* 提交按钮 */} {loading ? '提交中...' : '提交'} ); } const styles = StyleSheet.create({ container: { flex: 1, }, header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 10, height: 80, }, backBtn: { width: 40, height: 40, justifyContent: 'center', alignItems: 'center', }, backIcon: { fontSize: 32, color: '#fff', fontWeight: 'bold', }, headerTitle: { fontSize: 16, fontWeight: 'bold', color: '#fff', }, placeholder: { width: 40, }, scrollView: { flex: 1, }, content: { paddingHorizontal: 15, paddingTop: 10, paddingBottom: 30, }, card: { backgroundColor: '#fff', borderRadius: 15, padding: 15, }, typeSelector: { flexDirection: 'row', marginBottom: 10, }, typeItem: { paddingHorizontal: 15, paddingVertical: 8, marginRight: 10, borderRadius: 20, backgroundColor: '#f8f8f8', }, typeItemActive: { backgroundColor: '#FC7D2E', }, typeText: { fontSize: 14, color: '#666', }, typeTextActive: { color: '#fff', }, complaintTip: { backgroundColor: '#fff7e6', borderWidth: 1, borderColor: '#ffd591', borderRadius: 4, padding: 10, marginBottom: 15, }, complaintTipText: { fontSize: 13, color: '#fa8c16', }, inputWrapper: { position: 'relative', marginBottom: 20, }, input: { height: 150, backgroundColor: '#f8f8f8', borderRadius: 8, padding: 12, fontSize: 14, color: '#333', textAlignVertical: 'top', }, inputCount: { position: 'absolute', bottom: 10, right: 10, flexDirection: 'row', }, countNum: { fontSize: 12, color: '#999', }, countNumActive: { color: '#1FA4FF', }, countText: { fontSize: 12, color: '#999', }, submitBtn: { backgroundColor: '#FC7D2E', height: 44, borderRadius: 22, justifyContent: 'center', alignItems: 'center', }, submitBtnText: { fontSize: 16, color: '#fff', fontWeight: '500', }, });