index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view class="bg-gray-50 p-2 min-h-screen">
  3. <view class="bg-white rounded-xl shadow-sm p-4">
  4. <!-- 标题 -->
  5. <view class="text-gray-900 text-lg font-medium mb-6">意见反馈</view>
  6. <!-- 表单内容 -->
  7. <view class="space-y-6">
  8. <!-- 反馈输入框(带边框) -->
  9. <view>
  10. <textarea
  11. v-model="feedback.content"
  12. placeholder="请输入"
  13. class="bg-transparent outline-none border-gray-200 border-solid border-1 rounded-lg p-4 min-h-[180rpx] resize-none"
  14. ></textarea>
  15. </view>
  16. <!-- 图片上传区域(使用plus.png) -->
  17. <view>
  18. <text class="text-gray-700 text-sm block mb-3">图片信息</text>
  19. <view class="border-2 border-dashed border-gray-200 rounded-lg p-4 w-32 h-32 flex items-center justify-center relative" @click="chooseImage">
  20. <!-- 初始状态显示plus.png -->
  21. <image
  22. src="/static/plus.png"
  23. class="w-42 h-42 text-gray-400"
  24. v-if="!feedback.imageUrl"
  25. />
  26. <!-- 已选择图片时显示预览 -->
  27. <image
  28. :src="feedback.imageUrl"
  29. class="w-full h-full object-cover rounded"
  30. v-else
  31. />
  32. <!-- 已选择图片时显示删除按钮 -->
  33. <view v-if="feedback.imageUrl" class="absolute top-2 right-2 w-6 h-6 bg-black/50 rounded-full flex items-center justify-center" @click.stop="removeImage">
  34. <text class="text-white text-xs">×</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 确认按钮 -->
  41. <view class="mt-6 px-8">
  42. <view
  43. class="w-full text-center bg-blue-600 text-white py-3 rounded-2xl font-medium shadow-sm hover:bg-blue-700 transition-colors"
  44. @click="submitFeedback"
  45. >
  46. <text>确认</text>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script setup>
  52. import { ref } from 'vue'
  53. // 反馈数据
  54. const feedback = ref({
  55. content: '',
  56. imageUrl: ''
  57. })
  58. // 选择图片
  59. const chooseImage = () => {
  60. // 如果已有图片则先清空
  61. if (feedback.value.imageUrl) {
  62. feedback.value.imageUrl = ''
  63. return
  64. }
  65. // 调用图片选择API
  66. uni.chooseImage({
  67. count: 1,
  68. sizeType: ['original', 'compressed'],
  69. sourceType: ['album', 'camera'],
  70. success: (res) => {
  71. feedback.value.imageUrl = res.tempFilePaths[0]
  72. }
  73. })
  74. }
  75. // 移除图片
  76. const removeImage = () => {
  77. feedback.value.imageUrl = ''
  78. }
  79. // 提交反馈
  80. const submitFeedback = () => {
  81. // 验证反馈内容
  82. if (!feedback.value.content.trim()) {
  83. uni.showToast({
  84. title: '请输入反馈内容',
  85. icon: 'none'
  86. })
  87. return
  88. }
  89. // 提交逻辑
  90. console.log('提交反馈:', feedback.value)
  91. uni.showToast({
  92. title: '反馈提交成功',
  93. icon: 'none'
  94. })
  95. // 实际项目中这里调用接口提交数据
  96. }
  97. </script>