index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="feedback-page">
  3. <view class="header">
  4. <text class="title">意见反馈</text>
  5. </view>
  6. <view class="form-section">
  7. <textarea class="feedback-input"
  8. v-model="content"
  9. placeholder="请输入您的宝贵意见,我们会认真查看并及时处理..."
  10. :maxlength="500"
  11. ></textarea>
  12. <view class="word-count">{{content.length}}/500</view>
  13. <view class="image-upload">
  14. <view class="title">图片上传(选填)</view>
  15. <view class="image-list">
  16. <view class="image-item" v-for="(item, index) in images" :key="index">
  17. <image :src="item" mode="aspectFill"></image>
  18. <view class="delete-btn" @tap="deleteImage(index)">×</view>
  19. </view>
  20. <view class="upload-btn" @tap="chooseImage" v-if="images.length < 4">
  21. <text class="iconfont">&#xe685;</text>
  22. <text>上传图片</text>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="contact-input">
  27. <input type="text" v-model="contact" placeholder="请留下您的联系方式(选填)" />
  28. </view>
  29. <button class="submit-btn" @tap="handleSubmit">提交反馈</button>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. content: '',
  38. images: [],
  39. contact: ''
  40. }
  41. },
  42. methods: {
  43. // 选择图片
  44. chooseImage() {
  45. uni.chooseImage({
  46. count: 4 - this.images.length,
  47. success: (res) => {
  48. this.images = [...this.images, ...res.tempFilePaths];
  49. }
  50. });
  51. },
  52. // 删除图片
  53. deleteImage(index) {
  54. this.images.splice(index, 1);
  55. },
  56. // 提交反馈
  57. handleSubmit() {
  58. if (!this.content) {
  59. uni.showToast({
  60. title: '请输入反馈内容',
  61. icon: 'none'
  62. });
  63. return;
  64. }
  65. uni.showLoading({
  66. title: '提交中...'
  67. });
  68. // TODO: 调用提交反馈接口
  69. setTimeout(() => {
  70. uni.hideLoading();
  71. uni.showToast({
  72. title: '提交成功',
  73. icon: 'success'
  74. });
  75. setTimeout(() => {
  76. uni.navigateBack();
  77. }, 1500);
  78. }, 1000);
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .feedback-page {
  85. min-height: 100vh;
  86. background: #f5f5f5;
  87. }
  88. .header {
  89. background: #fff;
  90. padding: 20rpx 30rpx;
  91. .title {
  92. font-size: 32rpx;
  93. font-weight: bold;
  94. color: #333;
  95. }
  96. }
  97. .form-section {
  98. margin-top: 20rpx;
  99. padding: 30rpx;
  100. background: #fff;
  101. .feedback-input {
  102. width: 100%;
  103. height: 300rpx;
  104. padding: 20rpx;
  105. font-size: 28rpx;
  106. color: #333;
  107. background: #f8f8f8;
  108. border-radius: 12rpx;
  109. }
  110. .word-count {
  111. text-align: right;
  112. font-size: 24rpx;
  113. color: #999;
  114. margin-top: 10rpx;
  115. }
  116. .image-upload {
  117. margin-top: 40rpx;
  118. .title {
  119. font-size: 28rpx;
  120. color: #333;
  121. margin-bottom: 20rpx;
  122. }
  123. .image-list {
  124. display: flex;
  125. flex-wrap: wrap;
  126. .image-item {
  127. position: relative;
  128. width: 160rpx;
  129. height: 160rpx;
  130. margin-right: 20rpx;
  131. margin-bottom: 20rpx;
  132. image {
  133. width: 100%;
  134. height: 100%;
  135. border-radius: 8rpx;
  136. }
  137. .delete-btn {
  138. position: absolute;
  139. right: -10rpx;
  140. top: -10rpx;
  141. width: 40rpx;
  142. height: 40rpx;
  143. line-height: 40rpx;
  144. text-align: center;
  145. background: rgba(0, 0, 0, 0.5);
  146. color: #fff;
  147. border-radius: 50%;
  148. }
  149. }
  150. .upload-btn {
  151. width: 160rpx;
  152. height: 160rpx;
  153. display: flex;
  154. flex-direction: column;
  155. align-items: center;
  156. justify-content: center;
  157. background: #f8f8f8;
  158. border-radius: 8rpx;
  159. .iconfont {
  160. font-size: 48rpx;
  161. color: #999;
  162. margin-bottom: 10rpx;
  163. }
  164. text {
  165. font-size: 24rpx;
  166. color: #999;
  167. }
  168. }
  169. }
  170. }
  171. .contact-input {
  172. margin-top: 40rpx;
  173. input {
  174. width: 100%;
  175. height: 88rpx;
  176. padding: 0 20rpx;
  177. font-size: 28rpx;
  178. color: #333;
  179. background: #f8f8f8;
  180. border-radius: 12rpx;
  181. }
  182. }
  183. .submit-btn {
  184. width: 100%;
  185. height: 88rpx;
  186. line-height: 88rpx;
  187. text-align: center;
  188. background: #D93025;
  189. color: #fff;
  190. font-size: 32rpx;
  191. border-radius: 44rpx;
  192. margin-top: 60rpx;
  193. }
  194. }
  195. </style>