图书馆小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
3.6 KiB

2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
  1. <template>
  2. <view class="feedback-page">
  3. <!-- 留言列表 -->
  4. <view class="feedback-list">
  5. <!-- 空状态无留言时显示 -->
  6. <view class="empty-box" v-if="feedbackList.length === 0">
  7. <uni-icons style="margin-left: 20px;" custom-prefix="iconfont" type="icon-kongshuju" size="80" color="#ccc"></uni-icons>
  8. <text style="margin-top: 20px;">暂无留言</text>
  9. </view>
  10. <!-- 有数据时显示列表 -->
  11. <view
  12. class="feedback-item"
  13. v-for="(item, index) in feedbackList"
  14. :key="index"
  15. >
  16. <!-- 头像 + 用户名 + 点赞 -->
  17. <view class="feedback-item-top">
  18. <view class="user-info">
  19. <image
  20. class="avatar"
  21. :src="item.avatar || '/static/images/avatar.png'"
  22. mode="aspectFill"
  23. ></image>
  24. <text class="username">{{ item.nickname }}</text>
  25. </view>
  26. <!-- 点赞按钮 -->
  27. <view class="like-box" @click="likeComment(index)">
  28. <uni-icons
  29. :type="item.isLike ? 'hand-up-filled' : 'hand-up'"
  30. size="22"
  31. :color="item.isLike ? '#FF4D4F' : '#999'"
  32. ></uni-icons>
  33. <text class="like-count">{{ item.likeNum }}</text>
  34. </view>
  35. </view>
  36. <!-- 留言内容 -->
  37. <view class="feedback-content">
  38. <text class="content-text">{{ item.content }}</text>
  39. <text class="create-time">{{ item.createTime }}</text>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- 写留言按钮 有数据才显示 -->
  44. <view class="write-btn-box" v-if="feedbackList.length > 0">
  45. <button class="write-btn" @click="goWriteComment">写留言</button>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. feedbackList: [] // 测试空数据
  54. // feedbackList: [你的数据]
  55. };
  56. },
  57. methods: {
  58. likeComment(index) {
  59. const item = this.feedbackList[index];
  60. item.isLike ? item.likeNum-- : item.likeNum++;
  61. item.isLike = !item.isLike;
  62. },
  63. goWriteComment() {
  64. uni.navigateTo({
  65. url: '/subpkg/pages/feedback/feedback'
  66. });
  67. }
  68. }
  69. };
  70. </script>
  71. <style lang="scss" scoped>
  72. .feedback-page {
  73. background-color: #f7f8fa;
  74. min-height: 100vh;
  75. }
  76. /* 留言列表 */
  77. .feedback-list {
  78. height: calc(100vh - 80px);
  79. overflow-y: scroll;
  80. padding: 10px;
  81. }
  82. /* 空状态 */
  83. .empty-box {
  84. display: flex;
  85. flex-direction: column;
  86. justify-content: center;
  87. align-items: center;
  88. height: calc(100vh - 200px);
  89. color: #999;
  90. font-size: 15px;
  91. }
  92. /* 单条留言 */
  93. .feedback-item {
  94. background-color: #fff;
  95. border-radius: 8px;
  96. padding: 15px;
  97. margin-bottom: 10px;
  98. box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  99. }
  100. .feedback-item-top {
  101. display: flex;
  102. justify-content: space-between;
  103. align-items: center;
  104. margin-bottom: 10px;
  105. }
  106. .user-info {
  107. display: flex;
  108. align-items: center;
  109. }
  110. .avatar {
  111. width: 30px;
  112. height: 30px;
  113. border-radius: 50%;
  114. margin-right: 8px;
  115. }
  116. .username {
  117. font-size: 14px;
  118. color: #333;
  119. font-weight: 500;
  120. }
  121. .like-box {
  122. display: flex;
  123. align-items: center;
  124. }
  125. .like-count {
  126. font-size: 12px;
  127. color: #999;
  128. margin-left: 4px;
  129. }
  130. .feedback-content {
  131. line-height: 1.6;
  132. }
  133. .content-text {
  134. font-size: 14px;
  135. color: #555;
  136. display: block;
  137. margin-bottom: 8px;
  138. }
  139. .create-time {
  140. font-size: 12px;
  141. color: #999;
  142. }
  143. .write-btn-box {
  144. position: fixed;
  145. bottom: 20px;
  146. left: 0;
  147. right: 0;
  148. padding: 0 15px;
  149. }
  150. .write-btn {
  151. background-color: #007aff;
  152. color: #fff;
  153. border-radius: 25px;
  154. font-size: 14px;
  155. padding: 4px 0;
  156. }
  157. </style>