<template>
	<view class="feedback-page">
		<view class="header">
			<text class="title">意见反馈</text>
		</view>
		
		<view class="form-section">
			<textarea class="feedback-input" 
				v-model="content" 
				placeholder="请输入您的宝贵意见，我们会认真查看并及时处理..."
				:maxlength="500"
			></textarea>
			<view class="word-count">{{content.length}}/500</view>
			
			<view class="image-upload">
				<view class="title">图片上传（选填）</view>
				<view class="image-list">
					<view class="image-item" v-for="(item, index) in images" :key="index">
						<image :src="item" mode="aspectFill"></image>
						<view class="delete-btn" @tap="deleteImage(index)">×</view>
					</view>
					<view class="upload-btn" @tap="chooseImage" v-if="images.length < 4">
						<text class="iconfont">&#xe685;</text>
						<text>上传图片</text>
					</view>
				</view>
			</view>
			
			<view class="contact-input">
				<input type="text" v-model="contact" placeholder="请留下您的联系方式（选填）" />
			</view>
			
			<button class="submit-btn" @tap="handleSubmit">提交反馈</button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			content: '',
			images: [],
			contact: ''
		}
	},
	methods: {
		// 选择图片
		chooseImage() {
			uni.chooseImage({
				count: 4 - this.images.length,
				success: (res) => {
					this.images = [...this.images, ...res.tempFilePaths];
				}
			});
		},
		
		// 删除图片
		deleteImage(index) {
			this.images.splice(index, 1);
		},
		
		// 提交反馈
		handleSubmit() {
			if (!this.content) {
				uni.showToast({
					title: '请输入反馈内容',
					icon: 'none'
				});
				return;
			}
			
			uni.showLoading({
				title: '提交中...'
			});
			
			// TODO: 调用提交反馈接口
			setTimeout(() => {
				uni.hideLoading();
				uni.showToast({
					title: '提交成功',
					icon: 'success'
				});
				
				setTimeout(() => {
					uni.navigateBack();
				}, 1500);
			}, 1000);
		}
	}
}
</script>

<style lang="scss" scoped>
.feedback-page {
	min-height: 100vh;
	background: #f5f5f5;
}

.header {
	background: #fff;
	padding: 20rpx 30rpx;
	
	.title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
	}
}

.form-section {
	margin-top: 20rpx;
	padding: 30rpx;
	background: #fff;
	
	.feedback-input {
		width: 100%;
		height: 300rpx;
		padding: 20rpx;
		font-size: 28rpx;
		color: #333;
		background: #f8f8f8;
		border-radius: 12rpx;
	}
	
	.word-count {
		text-align: right;
		font-size: 24rpx;
		color: #999;
		margin-top: 10rpx;
	}
	
	.image-upload {
		margin-top: 40rpx;
		
		.title {
			font-size: 28rpx;
			color: #333;
			margin-bottom: 20rpx;
		}
		
		.image-list {
			display: flex;
			flex-wrap: wrap;
			
			.image-item {
				position: relative;
				width: 160rpx;
				height: 160rpx;
				margin-right: 20rpx;
				margin-bottom: 20rpx;
				
				image {
					width: 100%;
					height: 100%;
					border-radius: 8rpx;
				}
				
				.delete-btn {
					position: absolute;
					right: -10rpx;
					top: -10rpx;
					width: 40rpx;
					height: 40rpx;
					line-height: 40rpx;
					text-align: center;
					background: rgba(0, 0, 0, 0.5);
					color: #fff;
					border-radius: 50%;
				}
			}
			
			.upload-btn {
				width: 160rpx;
				height: 160rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				background: #f8f8f8;
				border-radius: 8rpx;
				
				.iconfont {
					font-size: 48rpx;
					color: #999;
					margin-bottom: 10rpx;
				}
				
				text {
					font-size: 24rpx;
					color: #999;
				}
			}
		}
	}
	
	.contact-input {
		margin-top: 40rpx;
		
		input {
			width: 100%;
			height: 88rpx;
			padding: 0 20rpx;
			font-size: 28rpx;
			color: #333;
			background: #f8f8f8;
			border-radius: 12rpx;
		}
	}
	
	.submit-btn {
		width: 100%;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		background: #D93025;
		color: #fff;
		font-size: 32rpx;
		border-radius: 44rpx;
		margin-top: 60rpx;
	}
}
</style> 