index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="complaint-list-root">
  3. <erp-nav-bar title="投诉与建议" />
  4. <scroll-view scroll-y class="list-scroll-view" :show-scrollbar="false" @scrolltolower="onReachEnd">
  5. <view class="list-inner">
  6. <view class="complaint-card" v-for="item in displayList" :key="item.id" @click="goDetail(item)">
  7. <view class="card-header">
  8. <view class="type-badge">{{ item.feedbackTypeLabel }}</view>
  9. <view class="status-text" :class="item.status === '1' ? 'done' : 'pending'">
  10. {{ item.status === '1' ? '已处理' : '待处理' }}
  11. </view>
  12. </view>
  13. <view class="card-content">
  14. <text class="content-text">{{ item.content }}</text>
  15. </view>
  16. <view class="card-footer">
  17. <text class="time-text">{{ item.createTime }}</text>
  18. <view class="arrow-icon"></view>
  19. </view>
  20. </view>
  21. <view class="list-status-info" v-if="displayList.length > 0">
  22. <view class="loading-wrap" v-if="loading">
  23. <text>加载中...</text>
  24. </view>
  25. <view class="nomore-wrap" v-if="noMore">
  26. <text class="nomore-text">没有更多了</text>
  27. </view>
  28. </view>
  29. <view class="empty-state" v-if="displayList.length === 0 && !loading">
  30. <image src="https://img.icons8.com/clouds/200/comments.png" mode="aspectFit"></image>
  31. <text class="empty-txt">暂无反馈记录</text>
  32. </view>
  33. <view class="safe-bottom"></view>
  34. </view>
  35. </scroll-view>
  36. <view class="footer-bar">
  37. <button class="submit-btn" @click="goSubmit">提交反馈</button>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import ErpNavBar from '@/components/erp-nav-bar.vue';
  43. import { getMyComplaintList } from '@/api/system/complaint.js';
  44. import { getDictByType } from '@/api/system/dict.js';
  45. export default {
  46. components: { ErpNavBar },
  47. data() {
  48. return {
  49. loading: false,
  50. noMore: false,
  51. pageNum: 1,
  52. displayList: [],
  53. typeMap: {}
  54. }
  55. },
  56. onLoad() {
  57. this.loadDict();
  58. this.refresh();
  59. },
  60. onShow() {
  61. if (this.displayList.length > 0) {
  62. this.refresh();
  63. }
  64. },
  65. methods: {
  66. async loadDict() {
  67. try {
  68. const res = await getDictByType('sys_complaint_type');
  69. if (res && res.data) {
  70. const map = {};
  71. res.data.forEach(d => { map[d.dictValue] = d.dictLabel; });
  72. this.typeMap = map;
  73. }
  74. } catch (e) { /* 忽略字典加载失败 */ }
  75. },
  76. goBack() { uni.navigateBack(); },
  77. goSubmit() {
  78. uni.navigateTo({ url: '/pages/mine/complaint/submit/index' });
  79. },
  80. goDetail(item) {
  81. uni.navigateTo({ url: `/pages/mine/complaint/detail/index?id=${item.id}` });
  82. },
  83. refresh() {
  84. this.displayList = [];
  85. this.noMore = false;
  86. this.pageNum = 1;
  87. this.loadData();
  88. },
  89. onReachEnd() {
  90. if (!this.loading && !this.noMore) this.loadData();
  91. },
  92. async loadData() {
  93. if (this.loading || this.noMore) return;
  94. this.loading = true;
  95. try {
  96. const params = {
  97. pageNum: this.pageNum,
  98. pageSize: 10
  99. };
  100. const res = await getMyComplaintList(params);
  101. const rows = (res && res.rows) ? res.rows : [];
  102. const formatted = rows.map(item => ({
  103. id: item.id,
  104. feedbackType: item.feedbackType,
  105. feedbackTypeLabel: this.typeMap[item.feedbackType] || item.feedbackType || '未知类型',
  106. content: item.content,
  107. status: item.status || '0',
  108. createTime: item.createTime
  109. }));
  110. this.displayList = [...this.displayList, ...formatted];
  111. this.pageNum++;
  112. this.noMore = rows.length === 0 || this.displayList.length >= (res.total || 0);
  113. } catch (e) {
  114. console.error('加载反馈列表失败', e);
  115. uni.showToast({ title: e || '加载反馈列表失败', icon: 'none' });
  116. } finally {
  117. this.loading = false;
  118. }
  119. }
  120. }
  121. }
  122. </script>
  123. <style scoped>
  124. /deep/ ::-webkit-scrollbar {
  125. display: none !important;
  126. width: 0 !important;
  127. height: 0 !important;
  128. }
  129. .complaint-list-root {
  130. width: 100vw;
  131. height: 100vh;
  132. background: #f8fafb;
  133. display: flex;
  134. flex-direction: column;
  135. overflow: hidden;
  136. }
  137. .list-scroll-view {
  138. flex: 1;
  139. height: 0;
  140. width: 100%;
  141. }
  142. .list-inner {
  143. padding: 30rpx;
  144. }
  145. .complaint-card {
  146. background: #fff;
  147. border-radius: 16rpx;
  148. padding: 30rpx;
  149. margin-bottom: 24rpx;
  150. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  151. }
  152. .card-header {
  153. display: flex;
  154. justify-content: space-between;
  155. align-items: center;
  156. margin-bottom: 20rpx;
  157. }
  158. .type-badge {
  159. font-size: 26rpx;
  160. color: #C1001C;
  161. background: rgba(193, 0, 28, 0.06);
  162. padding: 6rpx 16rpx;
  163. border-radius: 8rpx;
  164. }
  165. .status-text {
  166. font-size: 26rpx;
  167. }
  168. .status-text.pending {
  169. color: #ff9800;
  170. }
  171. .status-text.done {
  172. color: #4caf50;
  173. }
  174. .card-content {
  175. margin-bottom: 20rpx;
  176. }
  177. .content-text {
  178. font-size: 28rpx;
  179. color: #333;
  180. line-height: 1.6;
  181. display: -webkit-box;
  182. -webkit-line-clamp: 2;
  183. -webkit-box-orient: vertical;
  184. overflow: hidden;
  185. }
  186. .card-footer {
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. }
  191. .time-text {
  192. font-size: 24rpx;
  193. color: #bbb;
  194. }
  195. .arrow-icon {
  196. width: 14rpx;
  197. height: 14rpx;
  198. border-right: 3rpx solid #ccc;
  199. border-top: 3rpx solid #ccc;
  200. transform: rotate(45deg);
  201. margin-left: 10rpx;
  202. }
  203. .list-status-info {
  204. padding: 30rpx 0;
  205. display: flex;
  206. justify-content: center;
  207. }
  208. .loading-wrap {
  209. font-size: 26rpx;
  210. color: #999;
  211. }
  212. .nomore-wrap {
  213. display: flex;
  214. align-items: center;
  215. }
  216. .nomore-text {
  217. font-size: 26rpx;
  218. color: #ccc;
  219. }
  220. .empty-state {
  221. display: flex;
  222. flex-direction: column;
  223. align-items: center;
  224. padding-top: 150rpx;
  225. }
  226. .empty-state image {
  227. width: 200rpx;
  228. height: 200rpx;
  229. margin-bottom: 30rpx;
  230. }
  231. .empty-txt {
  232. font-size: 28rpx;
  233. color: #999;
  234. margin-bottom: 40rpx;
  235. }
  236. .safe-bottom {
  237. height: 40rpx;
  238. }
  239. .footer-bar {
  240. background: #fff;
  241. padding: 30rpx 40rpx calc(30rpx + env(safe-area-inset-bottom));
  242. flex-shrink: 0;
  243. border-top: 1rpx solid #f0f0f0;
  244. }
  245. .submit-btn {
  246. width: 100%;
  247. height: 96rpx;
  248. background: #C1001C;
  249. color: #fff;
  250. border-radius: 48rpx;
  251. display: flex;
  252. align-items: center;
  253. justify-content: center;
  254. font-size: 32rpx;
  255. font-weight: bold;
  256. border: none;
  257. }
  258. .submit-btn::after {
  259. border: none;
  260. }
  261. </style>