api
tj
2025-05-29 05d1310a6ec27656712c0c5e5e57b3365d3faf56
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
<template>
    <view class="wrap">
        <up-button @click="clear">清空列表</up-button>
        
        <up-waterfall v-model="flowList" ref="uWaterfallRef">
            <template v-slot:left="{leftList}">
                <view class="demo-warter" v-for="(item, index) in leftList" :key="index">
                    <!-- 警告:微信小程序中需要hx2.8.11版本才支持在template中结合其他组件,比如下方的lazy-load组件 -->
                    <up-lazy-load threshold="-450" border-radius="10" :image="item.image" :index="index"></up-lazy-load>
                    <view class="demo-title">
                        {{item.title}}
                    </view>
                    <view class="demo-price">
                        {{item.price}}元
                    </view>
                    <view class="demo-tag">
                        <view class="demo-tag-owner">
                            自营
                        </view>
                        <view class="demo-tag-text">
                            放心购
                        </view>
                    </view>
                    <view class="demo-shop">
                        {{item.shop}}
                    </view>
                    <up-icon name="close-circle-fill" color="#fa3534" size="34" class="u-close" @click="remove(item.id)"></up-icon>
                </view>
            </template>
            <template v-slot:right="{rightList}">
                <view class="demo-warter" v-for="(item, index) in rightList" :key="index">
                    <up-lazy-load threshold="-450" border-radius="10" :image="item.image" :index="index"></up-lazy-load>
                    <view class="demo-title">
                        {{item.title}}
                    </view>
                    <view class="demo-price">
                        {{item.price}}元
                    </view>
                    <view class="demo-tag">
                        <view class="demo-tag-owner">
                            自营
                        </view>
                        <view class="demo-tag-text">
                            放心购
                        </view>
                    </view>
                    <view class="demo-shop">
                        {{item.shop}}
                    </view>
                    <up-icon name="close-circle-fill" color="#fa3534" size="34" class="u-close" @click="remove(item.id)"></up-icon>
                </view>
            </template>
        </up-waterfall>
        <up-loadmore bg-color="rgb(240, 240, 240)" :status="loadStatus" @loadmore="addRandomData"></up-loadmore>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                loadStatus: 'loadmore',
                flowList: [],
                list: [
                    {
                        price: 35,
                        title: '北国风光,千里冰封,万里雪飘',
                        shop: '李白杜甫白居易旗舰店',
                        image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23327_s.jpg',
                    },
                    {
                        price: 75,
                        title: '望长城内外,惟余莽莽',
                        shop: '李白杜甫白居易旗舰店',
                        image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23325_s.jpg',
                    },
                    {
                        price: 385,
                        title: '大河上下,顿失滔滔',
                        shop: '李白杜甫白居易旗舰店',
                        image: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg',
                    },
                    {
                        price: 784,
                        title: '欲与天公试比高',
                        shop: '李白杜甫白居易旗舰店',
                        image: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/zzpic23369_s.jpg',
                    },
                    {
                        price: 7891,
                        title: '须晴日,看红装素裹,分外妖娆',
                        shop: '李白杜甫白居易旗舰店',
                        image: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2130_s.jpg',
                    },
                    {
                        price: 2341,
                        shop: '李白杜甫白居易旗舰店',
                        title: '江山如此多娇,引无数英雄竞折腰',
                        image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23346_s.jpg',
                    },
                    {
                        price: 661,
                        shop: '李白杜甫白居易旗舰店',
                        title: '惜秦皇汉武,略输文采',
                        image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23344_s.jpg',
                    },
                    {
                        price: 1654,
                        title: '唐宗宋祖,稍逊风骚',
                        shop: '李白杜甫白居易旗舰店',
                        image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23343_s.jpg',
                    },
                    {
                        price: 1678,
                        title: '一代天骄,成吉思汗',
                        shop: '李白杜甫白居易旗舰店',
                        image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23343_s.jpg',
                    },
                    {
                        price: 924,
                        title: '只识弯弓射大雕',
                        shop: '李白杜甫白居易旗舰店',
                        image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23343_s.jpg',
                    },
                    {
                        price: 8243,
                        title: '俱往矣,数风流人物,还看今朝',
                        shop: '李白杜甫白居易旗舰店',
                        image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23343_s.jpg',
                    },
                ]
            }
        },
        onLoad() {
            this.addRandomData();
        },
        onReachBottom() {
            this.loadStatus = 'loading';
            // 模拟数据加载
            setTimeout(() => {
                this.addRandomData();
                this.loadStatus = 'loadmore';
            }, 1000)
        },
        methods: {
            addRandomData() {
                for(let i = 0; i < 10; i++) {
                    let index = this.$u.random(0, this.list.length - 1);
                    // 先转成字符串再转成对象,避免数组对象引用导致数据混乱
                    let item = JSON.parse(JSON.stringify(this.list[index]))
                    item.id = this.$u.guid();
                    this.flowList.push(item);
                }
            },
            remove(id) {
                this.$refs.uWaterfallRef.remove(id);
            },
            clear() {
                this.$refs.uWaterfallRef.clear();
            }
        }
    }
</script>
 
<style>
    /* page不能写带scope的style标签中,否则无效 */
    page {
        background-color: rgb(240, 240, 240);
    }
</style>
 
<style lang="scss" scoped>
    .demo-warter {
        border-radius: 8px;
        margin: 5px;
        background-color: #ffffff;
        padding: 8px;
        position: relative;
    }
    
    .u-close {
        position: absolute;
        top: 32rpx;
        right: 32rpx;
    }
    
    .demo-image {
        width: 100%;
        border-radius: 4px;
    }
    
    .demo-title {
        font-size: 30rpx;
        margin-top: 5px;
        color: #000000;
    }
    
    .demo-tag {
        display: flex;
        margin-top: 5px;
    }
    
    .demo-tag-owner {
        background-color: #000000;
        color: #FFFFFF;
        display: flex;
        align-items: center;
        padding: 4rpx 14rpx;
        border-radius: 50rpx;
        font-size: 20rpx;
        line-height: 1;
    }
    
    .demo-tag-text {
        border: 1px solid #000000;
        color: #000000;
        margin-left: 10px;
        border-radius: 50rpx;
        line-height: 1;
        padding: 4rpx 14rpx;
        display: flex;
        align-items: center;
        border-radius: 50rpx;
        font-size: 20rpx;
    }
    
    .demo-price {
        font-size: 30rpx;
        color: #000000;
        margin-top: 5px;
    }
    
    .demo-shop {
        font-size: 22rpx;
        color: #000000;
        margin-top: 5px;
    }
</style>