FamilyFeed.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="family-feed">
  3. <view class="feed-header" v-if="showHeader">
  4. <text class="feed-icon">📢</text>
  5. <text class="feed-title">动态</text>
  6. </view>
  7. <!-- 平台公告(置顶显示) -->
  8. <view class="notice-list" v-if="notices.length > 0">
  9. <view class="notice-item" v-for="(n, idx) in notices" :key="'n' + idx" @click="onNoticeClick(n)">
  10. <view class="notice-tag" :class="'notice-type-' + n.type">{{ noticeTypeLabel(n.type) }}</view>
  11. <text class="notice-title">{{ n.title }}</text>
  12. <text class="notice-time">{{ n.time }}</text>
  13. </view>
  14. </view>
  15. <!-- 家庭动态(横向滚动) -->
  16. <scroll-view scroll-x class="feed-scroll" scroll-with-animation :show-scrollbar="false" v-if="familyItems.length > 0">
  17. <view class="feed-list">
  18. <view class="feed-item" v-for="(item, idx) in familyItems" :key="idx">
  19. <text class="feed-msg">{{ item.text }}</text>
  20. <text class="feed-time">{{ item.time }}</text>
  21. </view>
  22. </view>
  23. </scroll-view>
  24. <!-- 空态 -->
  25. <view v-if="notices.length === 0 && familyItems.length === 0" class="feed-empty">
  26. <text class="feed-empty-text">暂无动态</text>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. name: 'FamilyFeed',
  33. props: {
  34. items: {
  35. type: Array,
  36. default: function() { return [] }
  37. },
  38. notices: {
  39. type: Array,
  40. default: function() { return [] }
  41. },
  42. showHeader: {
  43. type: Boolean,
  44. default: true
  45. }
  46. },
  47. computed: {
  48. familyItems: function() {
  49. return this.items.filter(function(item) {
  50. return item.type !== 'notice'
  51. })
  52. }
  53. },
  54. methods: {
  55. noticeTypeLabel: function(type) {
  56. var labels = { platform: '公告', activity: '活动', promotion: '优惠' }
  57. return labels[type] || '公告'
  58. },
  59. onNoticeClick: function(n) {
  60. this.$emit('notice-click', n)
  61. }
  62. }
  63. }
  64. </script>
  65. <style>
  66. .family-feed {
  67. margin: 12rpx 30rpx 0;
  68. background: #fff;
  69. border-radius: 16rpx;
  70. padding: 12rpx 16rpx 14rpx;
  71. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  72. }
  73. .feed-header {
  74. display: flex;
  75. flex-direction: row;
  76. align-items: center;
  77. gap: 6rpx;
  78. margin-bottom: 8rpx;
  79. }
  80. .feed-icon {
  81. font-size: 22rpx;
  82. }
  83. .feed-title {
  84. font-size: 22rpx;
  85. font-weight: bold;
  86. color: #333;
  87. }
  88. /* 平台公告 */
  89. .notice-list {
  90. margin-bottom: 12rpx;
  91. }
  92. .notice-item {
  93. display: flex;
  94. flex-direction: row;
  95. align-items: center;
  96. padding: 10rpx 12rpx;
  97. background: #FFF7ED;
  98. border-radius: 10rpx;
  99. margin-bottom: 8rpx;
  100. border-left: 4rpx solid #F97316;
  101. }
  102. .notice-tag {
  103. font-size: 18rpx;
  104. padding: 2rpx 10rpx;
  105. border-radius: 8rpx;
  106. margin-right: 10rpx;
  107. flex-shrink: 0;
  108. }
  109. .notice-tag-platform { background: #FEF3C7; color: #92400E; }
  110. .notice-tag-activity { background: #DBEAFE; color: #1E40AF; }
  111. .notice-tag-promotion { background: #FCE7F3; color: #9D174D; }
  112. .notice-title {
  113. flex: 1;
  114. font-size: 24rpx;
  115. color: #333;
  116. overflow: hidden;
  117. text-overflow: ellipsis;
  118. white-space: nowrap;
  119. }
  120. .notice-time {
  121. font-size: 20rpx;
  122. color: #999;
  123. flex-shrink: 0;
  124. margin-left: 12rpx;
  125. }
  126. /* 家庭动态横向滚动 */
  127. .feed-scroll {
  128. width: 100%;
  129. white-space: nowrap;
  130. }
  131. .feed-list {
  132. display: inline-flex;
  133. flex-direction: row;
  134. gap: 12rpx;
  135. padding: 2rpx 0;
  136. }
  137. .feed-item {
  138. display: flex;
  139. flex-direction: row;
  140. align-items: center;
  141. flex-shrink: 0;
  142. background: #F8FAFC;
  143. border-radius: 20rpx;
  144. padding: 6rpx 14rpx;
  145. white-space: nowrap;
  146. }
  147. .feed-msg {
  148. font-size: 20rpx;
  149. color: #333;
  150. margin-right: 4rpx;
  151. white-space: nowrap;
  152. overflow: hidden;
  153. text-overflow: ellipsis;
  154. }
  155. .feed-time {
  156. font-size: 16rpx;
  157. color: #999;
  158. flex-shrink: 0;
  159. }
  160. .feed-empty {
  161. padding: 20rpx 0;
  162. text-align: center;
  163. }
  164. .feed-empty-text {
  165. font-size: 24rpx;
  166. color: #ccc;
  167. }
  168. </style>