index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <view class="complaint-root">
  3. <erp-nav-bar title="投诉与建议" />
  4. <view class="scroll-container">
  5. <scroll-view scroll-y class="scroll-content" :show-scrollbar="false">
  6. <view class="form-body">
  7. <!-- 2. 类型选择 -->
  8. <view class="section-card">
  9. <view class="section-title">反馈类型</view>
  10. <view class="type-grid">
  11. <view class="type-item" v-for="item in types" :key="item.value"
  12. :class="{ active: formData.type === item.value }" @click="formData.type = item.value">
  13. <text>{{ item.label }}</text>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 3. 问题描述 -->
  18. <view class="section-card">
  19. <view class="section-title">反馈内容</view>
  20. <textarea class="content-input" v-model="formData.content" placeholder="请详细描述您遇到的问题或改进建议..."
  21. maxlength="500"></textarea>
  22. <view class="word-count">{{ formData.content.length }}/500</view>
  23. </view>
  24. <!-- 4. 图片上传 -->
  25. <view class="section-card">
  26. <view class="section-title">上传图片 (最多6张)</view>
  27. <view class="upload-grid">
  28. <view class="img-item" v-for="(img, index) in formData.images" :key="index">
  29. <image :src="img" mode="aspectFill" @click="previewImage(index)"></image>
  30. <view class="del-btn" @click.stop="removeImage(index)">
  31. <view class="close-icon">×</view>
  32. </view>
  33. </view>
  34. <view class="add-btn" v-if="formData.images.length < 6" @click="chooseImage">
  35. <text class="add-icon">+</text>
  36. <text class="add-txt">添加图片</text>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="bottom-placeholder"></view>
  42. </scroll-view>
  43. </view>
  44. <!-- 5. 底部提交按钮 -->
  45. <view class="footer-bar">
  46. <button class="submit-btn" :disabled="!isFormValid" @click="handleSubmit">提交反馈</button>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import ErpNavBar from '@/components/erp-nav-bar.vue';
  52. export default {
  53. components: { ErpNavBar },
  54. data() {
  55. return {
  56. types: [
  57. { label: '系统投诉', value: 'complaint' },
  58. { label: '改进建议', value: 'suggestion' },
  59. { label: '其他反馈', value: 'other' }
  60. ],
  61. formData: {
  62. type: 'complaint',
  63. content: '',
  64. images: []
  65. }
  66. }
  67. },
  68. computed: {
  69. isFormValid() {
  70. return this.formData.content && this.formData.content.trim().length >= 5;
  71. }
  72. },
  73. methods: {
  74. goBack() { uni.navigateBack(); },
  75. chooseImage() {
  76. const count = 6 - this.formData.images.length;
  77. uni.chooseImage({
  78. count: count,
  79. sizeType: ['compressed'],
  80. success: (res) => {
  81. this.formData.images = [...this.formData.images, ...res.tempFilePaths];
  82. }
  83. });
  84. },
  85. removeImage(index) {
  86. this.formData.images.splice(index, 1);
  87. },
  88. previewImage(index) {
  89. uni.previewImage({
  90. urls: this.formData.images,
  91. current: index
  92. });
  93. },
  94. handleSubmit() {
  95. uni.showLoading({ title: '提交中' });
  96. setTimeout(() => {
  97. uni.hideLoading();
  98. uni.showToast({ title: '反馈成功' });
  99. setTimeout(() => {
  100. uni.navigateBack();
  101. }, 1500);
  102. }, 1000);
  103. }
  104. }
  105. }
  106. </script>
  107. <style scoped>
  108. .complaint-root {
  109. width: 100vw;
  110. height: 100vh;
  111. background: #f8fafb;
  112. display: flex;
  113. flex-direction: column;
  114. overflow: hidden;
  115. }
  116. .custom-navbar {
  117. background: #fff;
  118. width: 100%;
  119. flex-shrink: 0;
  120. border-bottom: 1rpx solid #f0f0f0;
  121. }
  122. .nav-content {
  123. height: 44px;
  124. display: flex;
  125. align-items: center;
  126. justify-content: space-between;
  127. padding: 0 30rpx;
  128. }
  129. .back-area {
  130. width: 60rpx;
  131. height: 44px;
  132. display: flex;
  133. align-items: center;
  134. }
  135. .back-arrow {
  136. width: 22rpx;
  137. height: 22rpx;
  138. border-left: 4rpx solid #333;
  139. border-bottom: 4rpx solid #333;
  140. transform: rotate(45deg);
  141. margin-left: 10rpx;
  142. }
  143. .nav-title {
  144. font-size: 34rpx;
  145. font-weight: bold;
  146. color: #333;
  147. }
  148. .right-placeholder {
  149. width: 60rpx;
  150. }
  151. .scroll-container {
  152. flex: 1;
  153. height: 0;
  154. width: 100%;
  155. position: relative;
  156. }
  157. .scroll-content {
  158. width: 100%;
  159. height: 100%;
  160. }
  161. .form-body {
  162. padding: 30rpx;
  163. }
  164. .section-card {
  165. background: #fff;
  166. border-radius: 24rpx;
  167. padding: 40rpx 30rpx;
  168. margin-bottom: 30rpx;
  169. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.02);
  170. }
  171. .section-title {
  172. font-size: 30rpx;
  173. font-weight: bold;
  174. color: #1a1a1a;
  175. margin-bottom: 30rpx;
  176. border-left: 8rpx solid #C1001C;
  177. padding-left: 20rpx;
  178. line-height: 1.2;
  179. }
  180. .type-grid {
  181. display: flex;
  182. gap: 20rpx;
  183. }
  184. .type-item {
  185. flex: 1;
  186. height: 80rpx;
  187. background: #f5f6f8;
  188. border-radius: 12rpx;
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. font-size: 28rpx;
  193. color: #666;
  194. border: 2rpx solid #f5f6f8;
  195. transition: all 0.2s;
  196. }
  197. .type-item.active {
  198. background: rgba(193, 0, 28, 0.05);
  199. color: #C1001C;
  200. border-color: #C1001C;
  201. font-weight: bold;
  202. }
  203. .content-input {
  204. width: 100%;
  205. height: 300rpx;
  206. background: #f9fafb;
  207. border-radius: 16rpx;
  208. padding: 24rpx;
  209. box-sizing: border-box;
  210. font-size: 30rpx;
  211. color: #333;
  212. }
  213. .word-count {
  214. text-align: right;
  215. font-size: 24rpx;
  216. color: #ccc;
  217. margin-top: 12rpx;
  218. }
  219. .upload-grid {
  220. display: grid;
  221. grid-template-columns: repeat(3, 1fr);
  222. gap: 20rpx;
  223. }
  224. .img-item {
  225. position: relative;
  226. width: 100%;
  227. padding-top: 100%;
  228. }
  229. .img-item image {
  230. position: absolute;
  231. top: 0;
  232. left: 0;
  233. width: 100%;
  234. height: 100%;
  235. border-radius: 16rpx;
  236. }
  237. .del-btn {
  238. position: absolute;
  239. top: -10rpx;
  240. right: -10rpx;
  241. width: 40rpx;
  242. height: 40rpx;
  243. background: rgba(0, 0, 0, 0.5);
  244. border-radius: 50%;
  245. display: flex;
  246. align-items: center;
  247. justify-content: center;
  248. z-index: 10;
  249. }
  250. .close-icon {
  251. color: #fff;
  252. font-size: 30rpx;
  253. line-height: 1;
  254. }
  255. .add-btn {
  256. width: 100%;
  257. padding-top: 100%;
  258. border: 2rpx dashed #ddd;
  259. border-radius: 16rpx;
  260. display: flex;
  261. flex-direction: column;
  262. align-items: center;
  263. justify-content: center;
  264. position: relative;
  265. background: #fcfcfc;
  266. }
  267. .add-icon {
  268. position: absolute;
  269. top: 35%;
  270. left: 50%;
  271. transform: translateX(-50%);
  272. font-size: 60rpx;
  273. color: #bbb;
  274. }
  275. .add-txt {
  276. position: absolute;
  277. bottom: 20%;
  278. left: 50%;
  279. transform: translateX(-50%);
  280. font-size: 22rpx;
  281. color: #999;
  282. }
  283. .footer-bar {
  284. background: #fff;
  285. padding: 30rpx 40rpx calc(30rpx + env(safe-area-inset-bottom));
  286. flex-shrink: 0;
  287. border-top: 1rpx solid #f0f0f0;
  288. }
  289. .submit-btn {
  290. width: 100%;
  291. height: 96rpx;
  292. background: #C1001C;
  293. color: #fff;
  294. border-radius: 48rpx;
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. font-size: 32rpx;
  299. font-weight: bold;
  300. border: none;
  301. }
  302. .submit-btn[disabled] {
  303. background: #edb3bb !important;
  304. color: rgba(255, 255, 255, 0.6) !important;
  305. }
  306. .bottom-placeholder {
  307. height: 40rpx;
  308. }
  309. </style>