图书馆小程序
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.

202 lines
4.5 KiB

1 week ago
  1. <template>
  2. <view class="feedback-page">
  3. <!-- 留言列表 -->
  4. <view class="feedback-list">
  5. <view
  6. class="feedback-item"
  7. v-for="(item, index) in feedbackList"
  8. :key="index"
  9. >
  10. <!-- 头像 + 用户名 + 点赞 -->
  11. <view class="feedback-item-top">
  12. <view class="user-info">
  13. <image
  14. class="avatar"
  15. :src="item.avatar || '@/static/images/avatar.png'"
  16. mode="aspectFill"
  17. ></image>
  18. <text class="username">{{ item.nickname }}</text>
  19. </view>
  20. <!-- 点赞按钮 -->
  21. <view class="like-box" @click="likeComment(index)">
  22. <uni-icons
  23. :type="item.isLike ? 'hand-up-filled' : 'hand-up'"
  24. size="22"
  25. :color="item.isLike ? '#FF4D4F' : '#999'"
  26. ></uni-icons>
  27. <text class="like-count">{{ item.likeNum }}</text>
  28. </view>
  29. </view>
  30. <!-- 留言内容 -->
  31. <view class="feedback-content">
  32. <text class="content-text">{{ item.content }}</text>
  33. <text class="create-time">{{ item.createTime }}</text>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 写留言按钮 -->
  38. <view class="write-btn-box">
  39. <button class="write-btn" @click="goWriteComment">写留言</button>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. // 留言列表数据(可从接口获取)
  48. feedbackList: [
  49. {
  50. nickname: "用户1",
  51. avatar: "@/static/images/avatar.png",
  52. content: "这篇文章充满了激情,从字里行间能体会到作者的喜爱之情,全文层次清晰,语句流畅,叙事生动具体,趣味性强。",
  53. createTime: "2026-04-23 10:23:01",
  54. likeNum: 12,
  55. isLike: false
  56. },
  57. {
  58. nickname: "热情读者",
  59. avatar: "@/static/images/avatar.png",
  60. content: "写得非常棒!情感真挚,结构完整,非常有感染力,值得大家阅读学习。",
  61. createTime: "2026-04-23 11:10:05",
  62. likeNum: 8,
  63. isLike: false
  64. },
  65. {
  66. nickname: "热情读者",
  67. avatar: "@/static/images/avatar.png",
  68. content: "写得非常棒!情感真挚,结构完整,非常有感染力,值得大家阅读学习。",
  69. createTime: "2026-04-23 11:10:05",
  70. likeNum: 8,
  71. isLike: false
  72. },
  73. {
  74. nickname: "热情读者",
  75. avatar: "@/static/images/avatar.png",
  76. content: "写得非常棒!情感真挚,结构完整,非常有感染力,值得大家阅读学习。",
  77. createTime: "2026-04-23 11:10:05",
  78. likeNum: 8,
  79. isLike: false
  80. }
  81. ]
  82. };
  83. },
  84. methods: {
  85. // 点赞功能
  86. likeComment(index) {
  87. const item = this.feedbackList[index];
  88. if (item.isLike) {
  89. // 取消点赞
  90. item.likeNum--;
  91. } else {
  92. // 点赞
  93. item.likeNum++;
  94. }
  95. item.isLike = !item.isLike;
  96. },
  97. // 写留言
  98. goWriteComment() {
  99. uni.navigateTo({
  100. url: '/subpkg/pages/feedback/feedback'
  101. });
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. .feedback-page {
  108. background-color: #f7f8fa;
  109. min-height: 100vh;
  110. }
  111. /* 留言列表 */
  112. .feedback-list {
  113. height: calc(100vh - 80px);
  114. overflow-y: scroll;
  115. }
  116. /* 单条留言 */
  117. .feedback-item {
  118. background-color: #fff;
  119. border-radius: 8px;
  120. padding: 15px;
  121. margin-bottom: 10px;
  122. box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  123. }
  124. /* 顶部:头像 + 用户名 + 点赞 */
  125. .feedback-item-top {
  126. display: flex;
  127. justify-content: space-between;
  128. align-items: center;
  129. margin-bottom: 10px;
  130. }
  131. .user-info {
  132. display: flex;
  133. align-items: center;
  134. }
  135. .avatar {
  136. width: 30px;
  137. height: 30px;
  138. border-radius: 50%;
  139. margin-right: 8px;
  140. }
  141. .username {
  142. font-size: 14px;
  143. color: #333;
  144. font-weight: 500;
  145. }
  146. /* 点赞 */
  147. .like-box {
  148. display: flex;
  149. align-items: center;
  150. }
  151. .like-count {
  152. font-size: 12px;
  153. color: #999;
  154. margin-left: 4px;
  155. }
  156. /* 留言内容 */
  157. .feedback-content {
  158. line-height: 1.6;
  159. }
  160. .content-text {
  161. font-size: 14px;
  162. color: #555;
  163. display: block;
  164. margin-bottom: 8px;
  165. }
  166. .create-time {
  167. font-size: 12px;
  168. color: #999;
  169. }
  170. .write-btn-box {
  171. position: fixed;
  172. bottom: 20px;
  173. left: 0;
  174. right: 0;
  175. padding: 0 15px;
  176. }
  177. .write-btn {
  178. background-color: #007aff;
  179. color: #fff;
  180. border-radius: 25px;
  181. font-size: 14px;
  182. padding: 4px 0;
  183. }
  184. </style>