jufubao-movie 1.0.39-beta5 → 1.0.39-beta7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/JfbMovieLineLineSeat/JfbMovieLineLineSeat.vue +0 -1
- package/src/components/JfbMovieTfkFilmList/ContentItem.vue +118 -74
- package/src/components/JfbMovieTfkFilmList/JfbMovieTfkFilmList.vue +81 -59
- package/src/components/JfbMovieTfkFilmRecommend/JfbMovieTfkFilmRecommend.vue +0 -1
- package/src/lib/VirtualList.js +111 -47
package/package.json
CHANGED
|
@@ -8,48 +8,53 @@
|
|
|
8
8
|
<image v-if="!errorStatus" :src="item['poster']" :alt="item['show_name']" @error="handleError()" ></image>
|
|
9
9
|
</view>
|
|
10
10
|
<view class="middle">
|
|
11
|
-
<view class="
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<template v-if="item['remark']">
|
|
19
|
-
<text>评分:</text><text :style="{color:color}">{{item['remark']}}</text>
|
|
20
|
-
</template>
|
|
11
|
+
<view class="top">
|
|
12
|
+
<view class="name">{{item['show_name']}}</view>
|
|
13
|
+
<view class="score">
|
|
14
|
+
<template v-if="item['remark']">
|
|
15
|
+
<text>评分:</text><text :style="{color:color}">{{item['remark']}}</text>
|
|
16
|
+
</template>
|
|
17
|
+
</view>
|
|
21
18
|
</view>
|
|
22
|
-
<view class="
|
|
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
|
-
|
|
19
|
+
<view class="bottom">
|
|
20
|
+
<view>
|
|
21
|
+
<view class="other">类型:{{item['type']}}</view>
|
|
22
|
+
<view class="other">导演:{{item['director']}}</view>
|
|
23
|
+
<view class="other">主演:{{item['leading_role']}}</view>
|
|
24
|
+
</view>
|
|
25
|
+
<view class="btn">
|
|
26
|
+
<template v-if="type === 'hot'">
|
|
27
|
+
<xd-button
|
|
28
|
+
v-if="item['show_button'] === '1'"
|
|
29
|
+
type="primary"
|
|
30
|
+
style="display:block;"
|
|
31
|
+
size="small"
|
|
32
|
+
@click.stop="handleBuy(item)">购票</xd-button>
|
|
33
|
+
<xd-button
|
|
34
|
+
v-else-if="item['show_button'] === '2'"
|
|
35
|
+
type="subPrimary"
|
|
36
|
+
style="display:block;"
|
|
37
|
+
size="small"
|
|
38
|
+
@click="handleBuy(item)">预售</xd-button>
|
|
39
|
+
</template>
|
|
40
|
+
<template v-if="type === 'rightnow'">
|
|
41
|
+
<xd-button
|
|
42
|
+
v-if="item['show_button'] === '3'"
|
|
43
|
+
type="success"
|
|
44
|
+
style="display:block;"
|
|
45
|
+
size="small"
|
|
46
|
+
@click.stop="handleDetail(item)"
|
|
47
|
+
>想看</xd-button>
|
|
48
|
+
<xd-button
|
|
49
|
+
v-else-if="item['show_button'] === '2'"
|
|
50
|
+
type="subPrimary"
|
|
51
|
+
style="display:block;"
|
|
52
|
+
size="small"
|
|
53
|
+
@click.stop="handleBuy(item)">预售</xd-button>
|
|
54
|
+
</template>
|
|
55
|
+
</view>
|
|
52
56
|
</view>
|
|
57
|
+
|
|
53
58
|
</view>
|
|
54
59
|
</view>
|
|
55
60
|
</template>
|
|
@@ -125,50 +130,89 @@
|
|
|
125
130
|
}
|
|
126
131
|
.middle {
|
|
127
132
|
flex: 1;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
|
|
134
|
+
& .top {
|
|
135
|
+
display: flex;
|
|
136
|
+
justify-content: space-between;
|
|
137
|
+
align-items: flex-end;
|
|
131
138
|
margin-bottom: 20rpx;
|
|
132
|
-
.uni-max-cut(2, 90);
|
|
133
|
-
line-height: 45rpx;
|
|
134
|
-
}
|
|
135
139
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
& > view:first-child{
|
|
141
|
+
flex: 1;
|
|
142
|
+
font-size: 36rpx;
|
|
143
|
+
font-weight: 600;
|
|
144
|
+
.uni-max-cut(2, 90);
|
|
145
|
+
line-height: 45rpx;
|
|
146
|
+
}
|
|
147
|
+
& >view:nth-child(2) {
|
|
148
|
+
flex-shrink: 0;
|
|
149
|
+
height: 45rpx;
|
|
150
|
+
line-height: 45rpx;
|
|
151
|
+
margin-left: 20rpx;
|
|
152
|
+
text-align: right;
|
|
153
|
+
& > text:nth-child(1) {
|
|
154
|
+
font-size: 20rpx;
|
|
155
|
+
}
|
|
156
|
+
& > text:nth-child(2) {
|
|
157
|
+
font-size: 28rpx;
|
|
158
|
+
}
|
|
144
159
|
}
|
|
145
160
|
}
|
|
146
|
-
}
|
|
147
161
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
align-items: flex-end;
|
|
153
|
-
justify-content: flex-end;
|
|
154
|
-
flex-flow: wrap;
|
|
155
|
-
box-sizing: border-box;
|
|
156
|
-
width: 160rpx;
|
|
157
|
-
height: 200rpx;
|
|
162
|
+
& .bottom {
|
|
163
|
+
display: flex;
|
|
164
|
+
justify-content: space-between;
|
|
165
|
+
align-items: center;
|
|
158
166
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
& > view:first-child {
|
|
168
|
+
flex: 1;
|
|
169
|
+
& > view {
|
|
170
|
+
font-size: 25rpx;
|
|
171
|
+
color: #999;
|
|
172
|
+
.uni-max-cut(1,36);
|
|
173
|
+
line-height: 36rpx;
|
|
174
|
+
margin-bottom: 10rpx;
|
|
175
|
+
&:last-child {
|
|
176
|
+
margin-bottom: 0!important;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
168
179
|
}
|
|
169
180
|
|
|
181
|
+
& .btn {
|
|
182
|
+
width: 140rpx;
|
|
183
|
+
flex-shrink: 0;
|
|
184
|
+
margin-left: 20rpx;
|
|
185
|
+
}
|
|
170
186
|
}
|
|
187
|
+
//& .name {
|
|
188
|
+
// font-size: 36rpx;
|
|
189
|
+
// font-weight: 600;
|
|
190
|
+
// margin-bottom: 20rpx;
|
|
191
|
+
// .uni-max-cut(2, 90);
|
|
192
|
+
// line-height: 45rpx;
|
|
193
|
+
//}
|
|
194
|
+
//
|
|
195
|
+
//& .other {
|
|
171
196
|
|
|
197
|
+
//}
|
|
172
198
|
}
|
|
199
|
+
|
|
200
|
+
//.right {
|
|
201
|
+
// flex-shrink: 0;
|
|
202
|
+
// display: flex;
|
|
203
|
+
// align-content: space-between;
|
|
204
|
+
// align-items: flex-end;
|
|
205
|
+
// justify-content: flex-end;
|
|
206
|
+
// flex-flow: wrap;
|
|
207
|
+
// box-sizing: border-box;
|
|
208
|
+
// width: 160rpx;
|
|
209
|
+
// height: 200rpx;
|
|
210
|
+
//
|
|
211
|
+
// & .score {
|
|
212
|
+
|
|
213
|
+
//
|
|
214
|
+
// }
|
|
215
|
+
//
|
|
216
|
+
//}
|
|
173
217
|
}
|
|
174
218
|
</style>
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
</view>
|
|
82
82
|
</view>
|
|
83
83
|
<!--poster-->
|
|
84
|
-
<view id="content-ref" class="content-ref"></view>
|
|
84
|
+
<view v-if="type === 'hot' || type === 'rightnow'" id="content-ref" class="content-ref"></view>
|
|
85
85
|
<!--film hot|rightnow-->
|
|
86
86
|
<view
|
|
87
87
|
v-if="type === 'hot' || type === 'rightnow'"
|
|
@@ -174,10 +174,15 @@
|
|
|
174
174
|
></xd-query-filter>
|
|
175
175
|
</view>
|
|
176
176
|
</view>
|
|
177
|
+
<view id="content-list-ref" v-if="type === 'list'" class="content-ref"></view>
|
|
177
178
|
<view
|
|
178
179
|
v-if="type === 'list'"
|
|
179
180
|
class="list-cont"
|
|
180
|
-
:style="{
|
|
181
|
+
:style="{
|
|
182
|
+
marginTop:outSpacing + 'rpx',
|
|
183
|
+
paddingTop:paddingTop,
|
|
184
|
+
paddingBottom:paddingBottom,
|
|
185
|
+
}"
|
|
181
186
|
>
|
|
182
187
|
<view class="skeleton-wrap" v-if="dataList === null">
|
|
183
188
|
<view
|
|
@@ -326,7 +331,7 @@
|
|
|
326
331
|
pageSize: 10,
|
|
327
332
|
total: null,
|
|
328
333
|
isFirstLoadingData: false,
|
|
329
|
-
|
|
334
|
+
|
|
330
335
|
cinemaOrgDataList:null,
|
|
331
336
|
cinemaAreaList:null,
|
|
332
337
|
sort_consume_mode:'',//获取影院数据排序
|
|
@@ -386,8 +391,13 @@
|
|
|
386
391
|
|
|
387
392
|
buyPath:'',
|
|
388
393
|
fimeDetailPath:'',
|
|
394
|
+
|
|
395
|
+
//页面列表展示数据
|
|
396
|
+
dataList:null,
|
|
389
397
|
paddingTop: 0,
|
|
390
398
|
paddingBottom: 0,
|
|
399
|
+
|
|
400
|
+
//计算高度预加载列表
|
|
391
401
|
preRendering:[],
|
|
392
402
|
|
|
393
403
|
}
|
|
@@ -442,6 +452,7 @@
|
|
|
442
452
|
}
|
|
443
453
|
return style[this.mode]
|
|
444
454
|
},
|
|
455
|
+
|
|
445
456
|
contMarginComp(){
|
|
446
457
|
let str = `${this.checkValue(this.contMargin.top, 20)}rpx`;
|
|
447
458
|
str = `${str} ${this.checkValue(this.contMargin.right, 20)}rpx`;
|
|
@@ -463,15 +474,12 @@
|
|
|
463
474
|
height: 280,
|
|
464
475
|
}
|
|
465
476
|
},
|
|
466
|
-
|
|
467
|
-
|
|
468
477
|
},
|
|
469
478
|
watch: {
|
|
470
479
|
container(value, oldValue) {
|
|
471
480
|
if (JSON.stringify(value) === JSON.stringify(oldValue)) return;
|
|
472
481
|
if (this.$configProject['isPreview']) this.init(value)
|
|
473
482
|
},
|
|
474
|
-
|
|
475
483
|
posterNum(){
|
|
476
484
|
if (this.$configProject['isPreview']){
|
|
477
485
|
this.onJfbLoad();
|
|
@@ -488,15 +496,12 @@
|
|
|
488
496
|
this.clearDataVar();
|
|
489
497
|
this.getList();
|
|
490
498
|
},
|
|
491
|
-
|
|
499
|
+
|
|
500
|
+
preRendering(val){
|
|
492
501
|
this.$nextTick(()=>{
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
.boundingClientRect((data) => {
|
|
497
|
-
console.log("得到布局位置信息" + JSON.stringify(data));
|
|
498
|
-
})
|
|
499
|
-
.exec();
|
|
502
|
+
if(val.length > 0) {
|
|
503
|
+
this.handlePreRendering(val);
|
|
504
|
+
}
|
|
500
505
|
})
|
|
501
506
|
}
|
|
502
507
|
},
|
|
@@ -504,8 +509,53 @@
|
|
|
504
509
|
this.isPreview = this.$configProject.isPreview;
|
|
505
510
|
this.backgroundColor = Color(this.warningColor).alpha(0.2).toString();
|
|
506
511
|
this.init(this.container);
|
|
512
|
+
|
|
513
|
+
this.virtualList = new VirtualList(this, this.type ==='list'?'#content-list-ref':'#content-ref', {
|
|
514
|
+
fixedHeight: 240 + Number(this.outSpacing) + 20 * 2 ,
|
|
515
|
+
otherHeight: Number(this.outSpacing),
|
|
516
|
+
type:this.type ==='list'?'auto':'fixed',
|
|
517
|
+
//获取节点数据
|
|
518
|
+
getDom:(id)=>{
|
|
519
|
+
return new Promise((resolve,reject)=>{
|
|
520
|
+
uni.createSelectorQuery().in(this).select(id)
|
|
521
|
+
.boundingClientRect((data)=>{
|
|
522
|
+
if(data && data.top !== undefined) resolve(data);
|
|
523
|
+
else reject(null)
|
|
524
|
+
}).exec()
|
|
525
|
+
});
|
|
526
|
+
},
|
|
527
|
+
//获取当前this
|
|
528
|
+
getParentThis(){
|
|
529
|
+
return this
|
|
530
|
+
},
|
|
531
|
+
callback: ({data, paddingTop, paddingBottom}) =>{
|
|
532
|
+
this.paddingTop = paddingTop;
|
|
533
|
+
this.paddingBottom = paddingBottom;
|
|
534
|
+
this.dataList = data;
|
|
535
|
+
},
|
|
536
|
+
});
|
|
507
537
|
},
|
|
508
538
|
methods: {
|
|
539
|
+
/**
|
|
540
|
+
* @description 非固定高度处理
|
|
541
|
+
* @param list
|
|
542
|
+
*/
|
|
543
|
+
handlePreRendering(list){
|
|
544
|
+
const query = uni.createSelectorQuery().in(this);
|
|
545
|
+
query
|
|
546
|
+
.selectAll('#preRendering > .list-cont-item')
|
|
547
|
+
.boundingClientRect((data) => {
|
|
548
|
+
if(data && data.length > 0) {
|
|
549
|
+
let height = [];
|
|
550
|
+
data.map(item=>{
|
|
551
|
+
height[item.dataset.index] = item.height + Number(this.outSpacing) * this.$rpxNum;
|
|
552
|
+
});
|
|
553
|
+
this.virtualList.pushVirtualData(list,height);
|
|
554
|
+
}
|
|
555
|
+
})
|
|
556
|
+
.exec();
|
|
557
|
+
},
|
|
558
|
+
|
|
509
559
|
clearDataVar(){
|
|
510
560
|
this.dataList = null;
|
|
511
561
|
this.pageToken = '1';
|
|
@@ -603,6 +653,7 @@
|
|
|
603
653
|
this.areaName = sortData.area_name;
|
|
604
654
|
this.pageToken = '1';
|
|
605
655
|
this.dataList = null;
|
|
656
|
+
this.virtualList.onChangeTab();
|
|
606
657
|
this.getList();
|
|
607
658
|
setTimeout(()=>{
|
|
608
659
|
this.curQueryTab = '';
|
|
@@ -648,7 +699,6 @@
|
|
|
648
699
|
|
|
649
700
|
//过滤之后不够分页直接返回值
|
|
650
701
|
if(fitlerData.length <= this.pageSize) {
|
|
651
|
-
this.dataList = this.$xdUniHelper.cloneDeep(fitlerData);
|
|
652
702
|
this.preRendering = this.$xdUniHelper.cloneDeep(fitlerData);
|
|
653
703
|
this.pageToken = ''
|
|
654
704
|
return;
|
|
@@ -665,7 +715,6 @@
|
|
|
665
715
|
}
|
|
666
716
|
|
|
667
717
|
this.preRendering = this.$xdUniHelper.cloneDeep(list);
|
|
668
|
-
this.dataList = (this.dataList||[]).concat(this.$xdUniHelper.cloneDeep(list));
|
|
669
718
|
if(this.pageSize < list.length) this.pageToken = '';
|
|
670
719
|
else this.pageToken = (Number(this.pageToken)+1) + '';
|
|
671
720
|
},
|
|
@@ -673,7 +722,10 @@
|
|
|
673
722
|
handleTab(value){
|
|
674
723
|
if(value === this.type) return;
|
|
675
724
|
if(value === 'hot' || value === 'rightnow' ) {
|
|
676
|
-
this.virtualList.onChangeTab();
|
|
725
|
+
this.virtualList.onChangeTab(this,'#content-ref', 'fixed' );
|
|
726
|
+
}
|
|
727
|
+
if(value === 'list') {
|
|
728
|
+
this.virtualList.onChangeTab(this,'#content-list-ref', 'auto' );
|
|
677
729
|
}
|
|
678
730
|
this.type = value;
|
|
679
731
|
this.dataList = null;
|
|
@@ -736,25 +788,26 @@
|
|
|
736
788
|
|
|
737
789
|
//影院列表处理
|
|
738
790
|
if(this.type === 'list') {
|
|
739
|
-
|
|
791
|
+
debugger
|
|
740
792
|
this.cinemaOrgDataList = res['list'];
|
|
741
793
|
this.cinemaAreaList = [{area_code:'all', area_name:'全城'}].concat(res['area_list']);
|
|
742
794
|
|
|
795
|
+
//预览模式
|
|
796
|
+
if(this.isPreview) {
|
|
797
|
+
this.dataList = (this.dataList||[]).concat(res['list'].slice(0, 20));
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
|
|
743
801
|
//小于数量页面显示记录
|
|
744
802
|
if(res['list'].length <= this.pageSize) {
|
|
745
|
-
this.dataList = res['list'];
|
|
803
|
+
//this.dataList = res['list'];
|
|
746
804
|
this.preRendering = this.$xdUniHelper.cloneDeep(res['list']);
|
|
747
805
|
this.pageToken = '';
|
|
748
806
|
return
|
|
749
807
|
}
|
|
750
808
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
}
|
|
754
|
-
else {
|
|
755
|
-
//正常处理
|
|
756
|
-
this.getCinemaOrgData();
|
|
757
|
-
}
|
|
809
|
+
//正常处理
|
|
810
|
+
this.getCinemaOrgData();
|
|
758
811
|
|
|
759
812
|
}
|
|
760
813
|
|
|
@@ -766,34 +819,6 @@
|
|
|
766
819
|
|
|
767
820
|
onJfbLoad(options) {
|
|
768
821
|
this.options = options;
|
|
769
|
-
|
|
770
|
-
this.virtualList = new VirtualList(this, '#content-ref', {
|
|
771
|
-
fixedHeight: 240 + Number(this.outSpacing) + 20 * 2 ,
|
|
772
|
-
otherHeight: Number(this.outSpacing),
|
|
773
|
-
//获取节点数据
|
|
774
|
-
getDom:(id)=>{
|
|
775
|
-
return new Promise((resolve,reject)=>{
|
|
776
|
-
uni.createSelectorQuery().in(this).select(id)
|
|
777
|
-
.boundingClientRect((data)=>{
|
|
778
|
-
if(data && data.top !== undefined) resolve(data);
|
|
779
|
-
else reject(null)
|
|
780
|
-
}).exec()
|
|
781
|
-
});
|
|
782
|
-
},
|
|
783
|
-
//获取当前this
|
|
784
|
-
getParentThis(){
|
|
785
|
-
return this
|
|
786
|
-
},
|
|
787
|
-
callback: ({data, paddingTop, paddingBottom}) =>{
|
|
788
|
-
if(this.type === 'hot' ||this.type ==='rightnow' ) {
|
|
789
|
-
this.paddingTop = paddingTop;
|
|
790
|
-
this.paddingBottom = paddingBottom;
|
|
791
|
-
this.dataList = data;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
},
|
|
795
|
-
});
|
|
796
|
-
|
|
797
822
|
jfbRootExec('getTFKPosterContent', {
|
|
798
823
|
vm: this,
|
|
799
824
|
data: {
|
|
@@ -876,10 +901,7 @@
|
|
|
876
901
|
},
|
|
877
902
|
|
|
878
903
|
onJfbScroll(options){
|
|
879
|
-
|
|
880
|
-
if(this.type === 'hot' || this.type === 'rightnow'){
|
|
881
|
-
this.virtualList.onScrollEvent(options.e.scrollTop);
|
|
882
|
-
}
|
|
904
|
+
this.virtualList.onScrollEvent(options.e.scrollTop);
|
|
883
905
|
},
|
|
884
906
|
|
|
885
907
|
setShowTypeList(){
|
|
@@ -896,7 +918,7 @@
|
|
|
896
918
|
|
|
897
919
|
//已有选中值不设置默认值
|
|
898
920
|
if(this.type === '' && list.length > 0) {
|
|
899
|
-
this.type = list[
|
|
921
|
+
this.type = list[1].value;
|
|
900
922
|
}
|
|
901
923
|
this.showTypeListData = list;
|
|
902
924
|
},
|
package/src/lib/VirtualList.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
//原点对象
|
|
3
3
|
let __orgUpdateTop = null;
|
|
4
|
+
let idx = 0;
|
|
4
5
|
|
|
5
6
|
export default class VirtualList {
|
|
6
7
|
virtualType='fixed';
|
|
7
|
-
virtualBufferHeight=
|
|
8
|
+
virtualBufferHeight= 0;
|
|
8
9
|
virtualFixedItemHeight; //固定模式高度设置
|
|
9
|
-
virtualVue; //当前组件vm实例
|
|
10
|
+
//virtualVue; //当前组件vm实例(小程序不可用)
|
|
10
11
|
virtualTotalData=[]; //数组长度
|
|
11
12
|
virtualHeightObj = {}; //高度序列index: {max:xx,min:xx}
|
|
12
13
|
$el= null; //开始点元素
|
|
@@ -22,7 +23,9 @@ export default class VirtualList {
|
|
|
22
23
|
top=0;
|
|
23
24
|
bottom=0;
|
|
24
25
|
virtualCallback= ()=>{};
|
|
25
|
-
status= false
|
|
26
|
+
status= false;
|
|
27
|
+
options = null;
|
|
28
|
+
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
31
|
* @description 初始化或者重置对象
|
|
@@ -35,59 +38,63 @@ export default class VirtualList {
|
|
|
35
38
|
* @param params.otherHeight {number} 其他高度(rpx)
|
|
36
39
|
* @param params.callback {Function} 回调方法
|
|
37
40
|
*/
|
|
38
|
-
constructor($vm,$el, params ) {
|
|
39
|
-
this.
|
|
40
|
-
this.virtualBufferHeight = 480 *
|
|
41
|
+
constructor($vm ,$el, params ) {
|
|
42
|
+
this.options = params;
|
|
43
|
+
this.virtualBufferHeight = 480 * $vm.$rpxNum;
|
|
41
44
|
if(params.type && ['auto','fixed'].includes(params.type)) this.virtualType = params.type;
|
|
42
|
-
if(params.bufferHeight) this.virtualBufferHeight = params.bufferHeight *
|
|
43
|
-
if(params.otherHeight) this.otherHeight = params.otherHeight *
|
|
44
|
-
if(
|
|
45
|
-
|
|
46
|
-
else this.virtualFixedItemHeight = params.fixedHeight * this.virtualVue.$rpxNum;
|
|
45
|
+
if(params.bufferHeight) this.virtualBufferHeight = params.bufferHeight * $vm.$rpxNum;
|
|
46
|
+
if(params.otherHeight) this.otherHeight = params.otherHeight * $vm.$rpxNum;
|
|
47
|
+
if(params.fixedHeight){
|
|
48
|
+
this.virtualFixedItemHeight = params.fixedHeight * $vm.$rpxNum;
|
|
47
49
|
}
|
|
48
50
|
this.virtualTotalData = [];
|
|
49
|
-
this.virtualVue.virtualViewData = null;
|
|
50
51
|
this.$el = $el;
|
|
51
|
-
|
|
52
|
+
$vm.$nextTick(()=>{
|
|
53
|
+
debugger
|
|
52
54
|
this.checkOffsetTop();
|
|
53
55
|
});
|
|
54
56
|
this.screenHeight = uni.getSystemInfoSync().safeArea.height;
|
|
55
57
|
if(typeof params.callback !== 'function') {
|
|
56
58
|
throw new Error(`FixedHeight is require, got is ${params.fixedHeight}`);
|
|
57
59
|
}else this.virtualCallback = params.callback;
|
|
58
|
-
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* @description 获取原点的偏移量
|
|
64
|
+
*/
|
|
61
65
|
checkOffsetTop(){
|
|
62
|
-
|
|
63
|
-
this.orgUpdateTop = __orgUpdateTop;
|
|
64
|
-
this.status = true;
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
66
|
+
|
|
67
67
|
//相对了10次不在检查
|
|
68
|
-
if(this.eqMaxTimer >=
|
|
68
|
+
if(this.eqMaxTimer >= 5) {
|
|
69
69
|
this.status = true;
|
|
70
|
-
__orgUpdateTop = this.orgUpdateTop;
|
|
71
70
|
return
|
|
72
71
|
}
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
|
|
73
|
+
this.options.getDom(this.$el).then(res=>{
|
|
74
|
+
let offsetTop = res.top
|
|
75
75
|
if(this.offsetTop === offsetTop) {
|
|
76
76
|
this.eqMaxTimer++;
|
|
77
77
|
}
|
|
78
78
|
else this.offsetTop = offsetTop;
|
|
79
79
|
this.orgUpdateTop = offsetTop + this.otherHeight;
|
|
80
80
|
if(this.virtualType === 'fixed') this.computedMinAndMaxFixed();
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
81
|
+
setTimeout(()=>{
|
|
82
|
+
this.checkOffsetTop();
|
|
83
|
+
}, 100)
|
|
84
|
+
}).catch(res=>{
|
|
85
|
+
setTimeout(()=>{
|
|
86
|
+
this.checkOffsetTop();
|
|
87
|
+
}, 100)
|
|
88
|
+
})
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
cloneDeep(data){
|
|
88
92
|
return JSON.parse(JSON.stringify(data));
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @description 固定高度模式初始化列表记录范围
|
|
97
|
+
*/
|
|
91
98
|
computedMinAndMaxFixed(){
|
|
92
99
|
let itemHeight = this.virtualFixedItemHeight;
|
|
93
100
|
this.virtualTotalData.map((item,index)=>{
|
|
@@ -107,32 +114,62 @@ export default class VirtualList {
|
|
|
107
114
|
});
|
|
108
115
|
}
|
|
109
116
|
|
|
117
|
+
/**
|
|
118
|
+
* @description 新增数据时候调用此方法(对外)
|
|
119
|
+
* @param data {Array} 列表数据
|
|
120
|
+
* @param height {Array} 高度数组
|
|
121
|
+
*/
|
|
110
122
|
pushVirtualData(data, height){
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
if(this.status) {
|
|
124
|
+
// data = data.map((item,index)=>{
|
|
125
|
+
// return {
|
|
126
|
+
// ...item,
|
|
127
|
+
// show_name: `【${idx} - ${index}】${item.show_name}`,
|
|
128
|
+
// }
|
|
129
|
+
// });
|
|
130
|
+
idx++;
|
|
131
|
+
//清空响应对象
|
|
132
|
+
if(this.virtualTotalData.length > 0) this.isFirst = false;
|
|
133
|
+
|
|
134
|
+
//非固定模式
|
|
135
|
+
if(this.virtualType === 'auto') {
|
|
136
|
+
if(!height) throw new Error(`height is require, got is ${height}`);
|
|
137
|
+
this.virtualHeightObj = Object.assign({},this.virtualHeightObj, this.cloneDeep(height));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//固定模式
|
|
141
|
+
if(this.virtualType === 'fixed') {
|
|
142
|
+
this.virtualTotalData = this.virtualTotalData.concat(this.cloneDeep(data));
|
|
143
|
+
this.computedMinAndMaxFixed();
|
|
144
|
+
if(this.isFirst) this.onScrollEvent(0);
|
|
145
|
+
}
|
|
120
146
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
147
|
+
this.isFirst = false
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
setTimeout(()=>{
|
|
151
|
+
this.pushVirtualData(data, height)
|
|
152
|
+
},100)
|
|
126
153
|
}
|
|
127
154
|
|
|
128
|
-
this.isFirst = false
|
|
129
155
|
}
|
|
130
156
|
|
|
131
157
|
/**
|
|
132
|
-
* @description
|
|
158
|
+
* @description 滚动事件(对外)
|
|
133
159
|
* @param scrollTop
|
|
134
160
|
*/
|
|
135
161
|
onScrollEvent(scrollTop) {
|
|
162
|
+
//console.log('onScrollEvent',scrollTop)
|
|
163
|
+
if(!this.status || this.virtualTotalData.length === 0) {
|
|
164
|
+
/**@type Function **/
|
|
165
|
+
this.virtualCallback({
|
|
166
|
+
paddingTop:0,
|
|
167
|
+
paddingBottom: 0,
|
|
168
|
+
data: []
|
|
169
|
+
});
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
136
173
|
//非固定计算索引
|
|
137
174
|
let time = new Date().getTime();
|
|
138
175
|
//计算开始索引
|
|
@@ -170,14 +207,41 @@ export default class VirtualList {
|
|
|
170
207
|
|
|
171
208
|
this.top = this.virtualHeightObj[this.startIndex].min - this.orgUpdateTop.toString() + 'px'
|
|
172
209
|
this.bottom = this.virtualHeightObj[this.virtualTotalData.length-1].max - this.virtualHeightObj[this.endIndex-1].max.toString() + 'px'
|
|
173
|
-
console.log('onScrollEvent.index',this.endIndex - this.startIndex, this.startIndex,this.endIndex, this.top, this.bottom)
|
|
210
|
+
console.log('onScrollEvent.index',this.endIndex - this.startIndex, this.startIndex,this.endIndex, this.top, this.bottom);
|
|
211
|
+
|
|
174
212
|
|
|
175
213
|
/**@type Function **/
|
|
176
214
|
this.virtualCallback({
|
|
177
|
-
paddingTop:this.top,
|
|
215
|
+
paddingTop: this.top,
|
|
178
216
|
paddingBottom: this.bottom,
|
|
179
|
-
data:this.cloneDeep(this.virtualTotalData).slice(this.startIndex, this.endIndex + 1)
|
|
180
|
-
);
|
|
217
|
+
data: this.cloneDeep(this.virtualTotalData).slice(this.startIndex, this.endIndex + 1)
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @description 切换Tab调用此方法(对外)
|
|
223
|
+
* @param virtualType {string} 类型 fixed|auto
|
|
224
|
+
* @param $vm {Vue} vue实例 (在自动高度模式必选)
|
|
225
|
+
* @param ref 元素对象 (在自动高度模式必选)
|
|
226
|
+
*/
|
|
227
|
+
onChangeTab($vm , ref , virtualType = 'fixed'){
|
|
228
|
+
this.virtualTotalData = [];
|
|
229
|
+
this.isFirst = true;
|
|
230
|
+
|
|
231
|
+
//改变顶部偏移量元素
|
|
232
|
+
if(virtualType && virtualType !== this.virtualType) {
|
|
233
|
+
if(!$vm) throw new Error(`$vm is require, got is ${$vm.$xdUniHelper.checkVarType($vm)},value is ${$vm}`);
|
|
234
|
+
if(!ref) throw new Error(`ref is require, got is ${$vm.$xdUniHelper.checkVarType(ref)}, value is ${ref}`);
|
|
235
|
+
this.virtualType = virtualType;
|
|
236
|
+
if(type === 'auto' && $vm && ref) {
|
|
237
|
+
this.$el = ref;
|
|
238
|
+
this.status = false;
|
|
239
|
+
this.eqMaxTimer = 3;
|
|
240
|
+
$vm.$nextTick(()=>{
|
|
241
|
+
this.checkOffsetTop();
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
181
245
|
}
|
|
182
246
|
}
|
|
183
247
|
|