| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <template>
- <view class="family-feed">
- <view class="feed-header" v-if="showHeader">
- <text class="feed-icon">📢</text>
- <text class="feed-title">动态</text>
- </view>
- <!-- 平台公告(置顶显示) -->
- <view class="notice-list" v-if="notices.length > 0">
- <view class="notice-item" v-for="(n, idx) in notices" :key="'n' + idx" @click="onNoticeClick(n)">
- <view class="notice-tag" :class="'notice-type-' + n.type">{{ noticeTypeLabel(n.type) }}</view>
- <text class="notice-title">{{ n.title }}</text>
- <text class="notice-time">{{ n.time }}</text>
- </view>
- </view>
- <!-- 家庭动态(横向滚动) -->
- <scroll-view scroll-x class="feed-scroll" scroll-with-animation :show-scrollbar="false" v-if="familyItems.length > 0">
- <view class="feed-list">
- <view class="feed-item" v-for="(item, idx) in familyItems" :key="idx">
- <text class="feed-msg">{{ item.text }}</text>
- <text class="feed-time">{{ item.time }}</text>
- </view>
- </view>
- </scroll-view>
- <!-- 空态 -->
- <view v-if="notices.length === 0 && familyItems.length === 0" class="feed-empty">
- <text class="feed-empty-text">暂无动态</text>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'FamilyFeed',
- props: {
- items: {
- type: Array,
- default: function() { return [] }
- },
- notices: {
- type: Array,
- default: function() { return [] }
- },
- showHeader: {
- type: Boolean,
- default: true
- }
- },
- computed: {
- familyItems: function() {
- return this.items.filter(function(item) {
- return item.type !== 'notice'
- })
- }
- },
- methods: {
- noticeTypeLabel: function(type) {
- var labels = { platform: '公告', activity: '活动', promotion: '优惠' }
- return labels[type] || '公告'
- },
- onNoticeClick: function(n) {
- this.$emit('notice-click', n)
- }
- }
- }
- </script>
- <style>
- .family-feed {
- margin: 12rpx 30rpx 0;
- background: #fff;
- border-radius: 16rpx;
- padding: 12rpx 16rpx 14rpx;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
- }
- .feed-header {
- display: flex;
- flex-direction: row;
- align-items: center;
- gap: 6rpx;
- margin-bottom: 8rpx;
- }
- .feed-icon {
- font-size: 22rpx;
- }
- .feed-title {
- font-size: 22rpx;
- font-weight: bold;
- color: #333;
- }
- /* 平台公告 */
- .notice-list {
- margin-bottom: 12rpx;
- }
- .notice-item {
- display: flex;
- flex-direction: row;
- align-items: center;
- padding: 10rpx 12rpx;
- background: #FFF7ED;
- border-radius: 10rpx;
- margin-bottom: 8rpx;
- border-left: 4rpx solid #F97316;
- }
- .notice-tag {
- font-size: 18rpx;
- padding: 2rpx 10rpx;
- border-radius: 8rpx;
- margin-right: 10rpx;
- flex-shrink: 0;
- }
- .notice-tag-platform { background: #FEF3C7; color: #92400E; }
- .notice-tag-activity { background: #DBEAFE; color: #1E40AF; }
- .notice-tag-promotion { background: #FCE7F3; color: #9D174D; }
- .notice-title {
- flex: 1;
- font-size: 24rpx;
- color: #333;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .notice-time {
- font-size: 20rpx;
- color: #999;
- flex-shrink: 0;
- margin-left: 12rpx;
- }
- /* 家庭动态横向滚动 */
- .feed-scroll {
- width: 100%;
- white-space: nowrap;
- }
- .feed-list {
- display: inline-flex;
- flex-direction: row;
- gap: 12rpx;
- padding: 2rpx 0;
- }
- .feed-item {
- display: flex;
- flex-direction: row;
- align-items: center;
- flex-shrink: 0;
- background: #F8FAFC;
- border-radius: 20rpx;
- padding: 6rpx 14rpx;
- white-space: nowrap;
- }
- .feed-msg {
- font-size: 20rpx;
- color: #333;
- margin-right: 4rpx;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .feed-time {
- font-size: 16rpx;
- color: #999;
- flex-shrink: 0;
- }
- .feed-empty {
- padding: 20rpx 0;
- text-align: center;
- }
- .feed-empty-text {
- font-size: 24rpx;
- color: #ccc;
- }
- </style>
|