tj
2025-05-21 7abdb24968bcb88f177851a30e41f282b9189a98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<template>
  <view :class="['app', theme]">
    <!-- <view class="page"> -->
    <view style="padding-top: 10rpx ;">
      <u-search height="70" placeholder="搜索" searchIconSize="30" margin="0rpx 30rpx 0rpx 30rpx" v-model="search"
        :show-action="true" @search="onSearch" @custom="onSearch" @clickIcon="onSearch" />
    </view>
 
    <!-- <u-tabs :list="tabList" @click="click"></u-tabs> -->
    <u-tabs :list="tabList" @click="click">
      <view slot="right" style="padding-left: 4px;" @tap="$u.toast('插槽被点击')">
        <u-icon name="list" size="40" bold></u-icon>
      </view>
    </u-tabs>
 
    <view class="list-view">
      <waterfall ref="helangWaterfall" :col="2">
        <template v-slot:default="{ list, colWidth }">
          <waterfall-col v-for="(col, colIndex) in list" :key="colIndex" :colWidth="colWidth">
            <waterfall-item v-for="(item, itemIndex) in col" :key="item.__waterfall_renderId" :colIndex="colIndex"
              :reportHeightTime="item.__waterfall_reportHeightTime" @height="onRenderHeight">
              <!-- 自定义内容 -->
              <view class="card" @click="handleDetailClick(item)">
                <image :src="item.imgurl" mode="widthFix" class="card-image" style="width: 100%;" />
                <view class="card-title">
                  <u--text :lines="2" size="14px" :text="item.title" :bold="true"></u--text>
                </view>
                <view class="card-footer">
                  <view class="user-info">
                    <u-avatar :src="item.avatar" size="40" shape="circle" />
                    <view class="user-text">
                      <text class="nickname">{{ item.username }}</text>
                      <!-- <text class="date">{{ item.date }}</text> -->
                    </view>
                  </view>
                  <view class="opera-info">
                    <u-icon name="heart" size="30" color="#999" />
                    <text>{{ item.likes }}</text>
                  </view>
                </view>
              </view>
            </waterfall-item>
          </waterfall-col>
        </template>
      </waterfall>
    </view>
 
  </view>
</template>
 
<script>
import Waterfall from '@/uni_modules/helang-waterfall/components/waterfall/waterfall-list';
import WaterfallCol from '@/uni_modules/helang-waterfall/components/waterfall/waterfall-col';
import WaterfallItem from '@/uni_modules/helang-waterfall/components/waterfall/waterfall-item';
 
 
export default {
  components: {
    Waterfall,
    WaterfallCol,
    WaterfallItem,
  },
  data() {
    return {
      theme: 'light', // 默认 light,可切换为 dark
      windowHeight: uni.getSystemInfoSync().windowHeight,
      search: '',
      tabList: [{
        name: '关注',
      }, {
        name: '推荐',
      }, {
        name: '电影'
      }, {
        name: '科技'
      }, {
        name: '音乐'
      }, {
        name: '美食'
      }, {
        name: '文化'
      }, {
        name: '财经'
      }, {
        name: '手工'
      }],
      items: [
        {
          id: 1,
          title: 'iPhone 高清全屏壁纸,划走就后悔',
          url: 'https://ai-public.mastergo.com/ai/img_res/6a226f9e9652c51cd535c3490535dfeb.jpg',
          imgurl: 'https://ai-public.mastergo.com/ai/img_res/6a226f9e9652c51cd535c3490535dfeb.jpg',
          username: '草莓喵喵',
          avatar: '/static/avatar1.jpg',
          date: '2024-12-01',
          likes: 1397,
        },
        {
          id: 2,
          title: '高清 4K 全屏手机壁纸 #高质量壁纸高清 4K 全屏手机壁纸 #高质量壁纸高清 4K 全屏手机壁纸 #高质量壁纸',
          url: 'https://img.yzcdn.cn/vant/cat.jpeg',
          imgurl: 'https://img.yzcdn.cn/vant/cat.jpeg',
          username: '4K wallpaper',
          avatar: '/static/avatar2.jpg',
          date: '02-24',
          likes: 167,
        },
        {
          id: 3,
          title: 'iPhone 实况动态壁纸 #动态壁纸',
          url: '/static/wallpaper3.jpg',
          imgurl: 'https://img.yzcdn.cn/vant/cat.jpeg',
          username: '图墙精选',
          avatar: '/static/avatar3.jpg',
          date: '03-01',
          likes: 980,
        },
        {
          id: 4,
          title: '高清小清新壁纸 浪漫的人都有自己的海',
          url: '/static/wallpaper4.jpg',
          imgurl: 'https://ai-public.mastergo.com/ai/img_res/6a226f9e9652c51cd535c3490535dfeb.jpg',
          username: 'wallpaper',
          avatar: '/static/avatar4.jpg',
          date: '04-10',
          likes: 456,
        }
      ]
    }
  },
  onLoad(options) {
    // 尝试读取缓存设置的主题
    console.log("theme", uni.getStorageSync('theme'))
    const theme = uni.getStorageSync('theme') || 'light'
    this.theme = theme
 
    this.$refs.helangWaterfall.render(this.items, true);
  },
  methods: {
    onSearch(value) {
      debugger;
      uni.showToast({
        title: `搜索:${value}`,
        icon: 'none'
      });
    },
 
    handleDetailClick(item) {
      if (item.id === 1) {
        uni.navigateTo({
          url: '/sub-pages/film-list/film-official-detail?id=' + item.id
        })
      } else {
        uni.navigateTo({
          url: '/sub-pages/film-list/film-detail?id=' + item.id
        })
      }
 
    },
    onRenderHeight({ colIndex, height, reportHeightTimeChange }) {
      this.$refs.helangWaterfall.reportHeight({
        colIndex,
        height,
        reportHeightTimeChange
      })
    },
  }
}
</script>
 
<style scoped>
.page {
  background-color: #F5F5F5;
}
 
.list-view {
  margin-top: 10px;
}
 
.filter-bar {
  flex-wrap: wrap;
}
</style>
<style lang="scss">
.card {
  border-radius: 10rpx;
  background-color: #FFFFFF;
  font-size: 14px;
  line-height: 20px;
  color: rgb(51, 51, 51);
  // border: 1rpx solid rgb(51, 51, 51);
 
  .card-image {
    border-radius: inherit;
  }
 
  .card-title {
    padding: 10rpx;
    // font-size: 14px;
    font-weight: 500;
 
  }
 
  .card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10rpx;
  }
 
  .user-info {
    display: flex;
    align-items: center;
 
    .user-text {
      font-size: 18rpx;
      line-height: 14px;
      margin-left: 10rpx;
 
      .nickname {
        font-weight: bold;
        display: block;
        color: #646464;
      }
 
      .date {
        font-size: 12px;
        color: #aaa;
        margin-top: 10rpx;
      }
    }
  }
 
  .opera-info {
    display: flex;
    align-items: center;
 
    text {
      margin-left: 10rpx;
      font-size: 12px;
    }
  }
}
</style>