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

177 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. };
  55. },
  56. methods: {
  57. likeComment(index) {
  58. const item = this.feedbackList[index];
  59. item.isLike ? item.likeNum-- : item.likeNum++;
  60. item.isLike = !item.isLike;
  61. },
  62. goWriteComment() {
  63. uni.navigateTo({
  64. url: '/subpkg/pages/feedback/feedback'
  65. });
  66. }
  67. }
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. .feedback-page {
  72. background-color: #f7f8fa;
  73. min-height: 100vh;
  74. }
  75. /* 留言列表 */
  76. .feedback-list {
  77. height: calc(100vh - 80px);
  78. overflow-y: scroll;
  79. padding: 10px;
  80. }
  81. /* 空状态 */
  82. .empty-box {
  83. display: flex;
  84. flex-direction: column;
  85. justify-content: center;
  86. align-items: center;
  87. height: calc(100vh - 200px);
  88. color: #999;
  89. font-size: 15px;
  90. }
  91. /* 单条留言 */
  92. .feedback-item {
  93. background-color: #fff;
  94. border-radius: 8px;
  95. padding: 15px;
  96. margin-bottom: 10px;
  97. box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  98. }
  99. .feedback-item-top {
  100. display: flex;
  101. justify-content: space-between;
  102. align-items: center;
  103. margin-bottom: 10px;
  104. }
  105. .user-info {
  106. display: flex;
  107. align-items: center;
  108. }
  109. .avatar {
  110. width: 30px;
  111. height: 30px;
  112. border-radius: 50%;
  113. margin-right: 8px;
  114. }
  115. .username {
  116. font-size: 14px;
  117. color: #333;
  118. font-weight: 500;
  119. }
  120. .like-box {
  121. display: flex;
  122. align-items: center;
  123. }
  124. .like-count {
  125. font-size: 12px;
  126. color: #999;
  127. margin-left: 4px;
  128. }
  129. .feedback-content {
  130. line-height: 1.6;
  131. }
  132. .content-text {
  133. font-size: 14px;
  134. color: #555;
  135. display: block;
  136. margin-bottom: 8px;
  137. }
  138. .create-time {
  139. font-size: 12px;
  140. color: #999;
  141. }
  142. .write-btn-box {
  143. position: fixed;
  144. bottom: 20px;
  145. left: 0;
  146. right: 0;
  147. padding: 0 15px;
  148. }
  149. .write-btn {
  150. background-color: #007aff;
  151. color: #fff;
  152. border-radius: 25px;
  153. font-size: 14px;
  154. padding: 4px 0;
  155. }
  156. </style>