jufubao-movie 1.0.39-beta4 → 1.0.39-beta6
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/Mock.js +1 -0
- package/src/components/JfbMovieLineLineSeat/XdOnlineSeatMove.vue +6 -1
- package/src/components/JfbMovieTfkFilmList/ContentItem.vue +128 -77
- package/src/components/JfbMovieTfkFilmList/JfbMovieTfkFilmList.vue +16 -13
- package/src/components/JfbMovieTfkFilmRecommend/Attr.js +31 -3
- package/src/components/JfbMovieTfkFilmRecommend/JfbMovieTfkFilmRecommend.vue +20 -3
- package/src/lib/VirtualList.js +108 -44
package/package.json
CHANGED
|
@@ -4,51 +4,57 @@
|
|
|
4
4
|
class="image"
|
|
5
5
|
:style="{marginRight: outSpacing + 'rpx',borderRadius:borderRadius+'rpx'}"
|
|
6
6
|
>
|
|
7
|
-
<image :src="
|
|
7
|
+
<image v-if="errorStatus" :src="errorImage" :alt="item['show_name']" ></image>
|
|
8
|
+
<image v-if="!errorStatus" :src="item['poster']" :alt="item['show_name']" @error="handleError()" ></image>
|
|
8
9
|
</view>
|
|
9
10
|
<view class="middle">
|
|
10
|
-
<view class="
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<template v-if="item['remark']">
|
|
18
|
-
<text>评分:</text><text :style="{color:color}">{{item['remark']}}</text>
|
|
19
|
-
</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>
|
|
20
18
|
</view>
|
|
21
|
-
<view class="
|
|
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
|
-
|
|
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>
|
|
51
56
|
</view>
|
|
57
|
+
|
|
52
58
|
</view>
|
|
53
59
|
</view>
|
|
54
60
|
</template>
|
|
@@ -80,12 +86,18 @@
|
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
},
|
|
89
|
+
data(){
|
|
90
|
+
return {
|
|
91
|
+
errorImage: 'https://img.jufubao.cn/common/error_movie.png?v20',
|
|
92
|
+
errorStatus: false,
|
|
93
|
+
}
|
|
94
|
+
},
|
|
83
95
|
created() {
|
|
84
96
|
|
|
85
97
|
},
|
|
86
98
|
methods:{
|
|
87
|
-
handleError(
|
|
88
|
-
|
|
99
|
+
handleError(){
|
|
100
|
+
this.errorStatus = true;
|
|
89
101
|
},
|
|
90
102
|
handleDetail(item){
|
|
91
103
|
console.log('handleDetail.item',item,item.id);
|
|
@@ -118,50 +130,89 @@
|
|
|
118
130
|
}
|
|
119
131
|
.middle {
|
|
120
132
|
flex: 1;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
|
|
134
|
+
& .top {
|
|
135
|
+
display: flex;
|
|
136
|
+
justify-content: space-between;
|
|
137
|
+
align-items: flex-end;
|
|
124
138
|
margin-bottom: 20rpx;
|
|
125
|
-
.uni-max-cut(2, 90);
|
|
126
|
-
line-height: 45rpx;
|
|
127
|
-
}
|
|
128
139
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
+
}
|
|
137
159
|
}
|
|
138
160
|
}
|
|
139
|
-
}
|
|
140
161
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
align-items: flex-end;
|
|
146
|
-
justify-content: flex-end;
|
|
147
|
-
flex-flow: wrap;
|
|
148
|
-
box-sizing: border-box;
|
|
149
|
-
width: 160rpx;
|
|
150
|
-
height: 200rpx;
|
|
162
|
+
& .bottom {
|
|
163
|
+
display: flex;
|
|
164
|
+
justify-content: space-between;
|
|
165
|
+
align-items: center;
|
|
151
166
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
+
}
|
|
161
179
|
}
|
|
162
180
|
|
|
181
|
+
& .btn {
|
|
182
|
+
width: 140rpx;
|
|
183
|
+
flex-shrink: 0;
|
|
184
|
+
margin-left: 20rpx;
|
|
185
|
+
}
|
|
163
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 {
|
|
164
196
|
|
|
197
|
+
//}
|
|
165
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
|
+
//}
|
|
166
217
|
}
|
|
167
218
|
</style>
|
|
@@ -471,7 +471,6 @@
|
|
|
471
471
|
if (JSON.stringify(value) === JSON.stringify(oldValue)) return;
|
|
472
472
|
if (this.$configProject['isPreview']) this.init(value)
|
|
473
473
|
},
|
|
474
|
-
|
|
475
474
|
posterNum(){
|
|
476
475
|
if (this.$configProject['isPreview']){
|
|
477
476
|
this.onJfbLoad();
|
|
@@ -716,8 +715,6 @@
|
|
|
716
715
|
}
|
|
717
716
|
}
|
|
718
717
|
|
|
719
|
-
|
|
720
|
-
|
|
721
718
|
jfbRootExec(fName, {
|
|
722
719
|
vm: this,
|
|
723
720
|
data:params
|
|
@@ -727,9 +724,12 @@
|
|
|
727
724
|
|
|
728
725
|
//影片列表处理
|
|
729
726
|
if(this.type === 'rightnow' || this.type==='hot'){
|
|
730
|
-
|
|
731
|
-
this.
|
|
732
|
-
|
|
727
|
+
//预览模式
|
|
728
|
+
if(this.isPreview) this.dataList = (this.dataList||[]).concat(res['list']);
|
|
729
|
+
else {
|
|
730
|
+
this.virtualList.pushVirtualData(res['list']);
|
|
731
|
+
this.pageToken = res.next_page_token;
|
|
732
|
+
}
|
|
733
733
|
return;
|
|
734
734
|
}
|
|
735
735
|
|
|
@@ -739,7 +739,6 @@
|
|
|
739
739
|
this.cinemaOrgDataList = res['list'];
|
|
740
740
|
this.cinemaAreaList = [{area_code:'all', area_name:'全城'}].concat(res['area_list']);
|
|
741
741
|
|
|
742
|
-
|
|
743
742
|
//小于数量页面显示记录
|
|
744
743
|
if(res['list'].length <= this.pageSize) {
|
|
745
744
|
this.dataList = res['list'];
|
|
@@ -748,8 +747,14 @@
|
|
|
748
747
|
return
|
|
749
748
|
}
|
|
750
749
|
|
|
751
|
-
|
|
752
|
-
|
|
750
|
+
if(this.isPreview) {
|
|
751
|
+
this.dataList = (this.dataList||[]).concat(res['list'].slice(0, 20));
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
//正常处理
|
|
755
|
+
this.getCinemaOrgData();
|
|
756
|
+
}
|
|
757
|
+
|
|
753
758
|
}
|
|
754
759
|
|
|
755
760
|
}).catch(e=>{
|
|
@@ -870,9 +875,7 @@
|
|
|
870
875
|
},
|
|
871
876
|
|
|
872
877
|
onJfbScroll(options){
|
|
873
|
-
|
|
874
|
-
this.virtualList.onScrollEvent(options.e.scrollTop);
|
|
875
|
-
}
|
|
878
|
+
this.virtualList.onScrollEvent(options.e.scrollTop);
|
|
876
879
|
},
|
|
877
880
|
|
|
878
881
|
setShowTypeList(){
|
|
@@ -895,7 +898,7 @@
|
|
|
895
898
|
},
|
|
896
899
|
|
|
897
900
|
onJfbReachBottom(options) {
|
|
898
|
-
if(!this.pageToken) return false;
|
|
901
|
+
if(!this.pageToken || this.dataList === null) return false;
|
|
899
902
|
this.getList();
|
|
900
903
|
},
|
|
901
904
|
|
|
@@ -261,21 +261,49 @@ export default {
|
|
|
261
261
|
groupKey:'style',
|
|
262
262
|
},
|
|
263
263
|
{
|
|
264
|
-
label: '
|
|
264
|
+
label: '总数量文字颜色:',
|
|
265
265
|
ele: 'xd-color',
|
|
266
266
|
valueKey: 'totalColor',
|
|
267
267
|
value: data['totalColor'] || '',
|
|
268
268
|
groupKey:'style',
|
|
269
|
-
placeholder: '
|
|
269
|
+
placeholder: '请输入总数量文字颜色',
|
|
270
|
+
classNmae: 'input60',
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
{
|
|
275
|
+
ele: 'title',
|
|
276
|
+
label: '标题显示样式:<span style="color:red">“下划线样式”</span> 设置',
|
|
277
|
+
size: 'small',
|
|
278
|
+
groupKey:'style',
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
label: '标题文字颜色:',
|
|
282
|
+
ele: 'xd-color',
|
|
283
|
+
valueKey: 'titleLineTextColor',
|
|
284
|
+
value: data['titleLineTextColor'] || '',
|
|
285
|
+
groupKey:'style',
|
|
286
|
+
placeholder: '请输入标题文字颜色',
|
|
287
|
+
classNmae: 'input60',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
label: '标题选中文字颜色:',
|
|
291
|
+
ele: 'xd-color',
|
|
292
|
+
valueKey: 'titleLineActTextColor',
|
|
293
|
+
value: data['titleLineActTextColor'] || '',
|
|
294
|
+
groupKey:'style',
|
|
295
|
+
placeholder: '请输入选中文字颜色',
|
|
270
296
|
classNmae: 'input60',
|
|
271
297
|
},
|
|
272
298
|
|
|
273
299
|
{
|
|
274
300
|
ele: 'title',
|
|
275
|
-
label: '
|
|
301
|
+
label: '标题显示样式:<span style="color:red">“按钮样式”</span> 设置',
|
|
276
302
|
size: 'small',
|
|
277
303
|
groupKey:'style',
|
|
278
304
|
},
|
|
305
|
+
|
|
306
|
+
|
|
279
307
|
{
|
|
280
308
|
label: '标题背景颜色:',
|
|
281
309
|
ele: 'xd-color',
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
v-if="showTypeListData.length > 0"
|
|
21
21
|
:style="{
|
|
22
22
|
padding: outSpacing + 'rpx',
|
|
23
|
-
backgroundImage:bgImageComp
|
|
23
|
+
backgroundImage:bgImageComp,
|
|
24
|
+
backgroundColor: bgColor
|
|
24
25
|
}">
|
|
25
26
|
<view
|
|
26
27
|
class="tfk-recommend__tab"
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
:class="{active: type === item.value}"
|
|
44
45
|
v-for="(item,index) in showTypeListData"
|
|
45
46
|
:key="index"
|
|
47
|
+
:style="{color: (type === item.value? titleLineActTextColor: titleLineTextColor)}"
|
|
46
48
|
>{{item.label}}<text v-if="type === item.value" :style="{backgroundColor:mainColor}"></text></view>
|
|
47
49
|
</view>
|
|
48
50
|
<view
|
|
@@ -58,7 +60,8 @@
|
|
|
58
60
|
:style="{
|
|
59
61
|
backgroundColor: type === item.value? titleTextActBgColor: titleTextBgColor,
|
|
60
62
|
color: type === item.value ? titleTextActColor: titleTextColor,
|
|
61
|
-
borderRadius:titleTextRradius+'rpx'
|
|
63
|
+
borderRadius:titleTextRradius+'rpx',
|
|
64
|
+
marginRight:outSpacing + 'rpx',
|
|
62
65
|
}"
|
|
63
66
|
>{{item.label}}</view>
|
|
64
67
|
</view>
|
|
@@ -88,7 +91,7 @@
|
|
|
88
91
|
backgroundColor:contBgColor,
|
|
89
92
|
borderRadius: contRradius + 'rpx',
|
|
90
93
|
border:contBorder,
|
|
91
|
-
boxShadow:contShadow
|
|
94
|
+
boxShadow:contShadow
|
|
92
95
|
}"
|
|
93
96
|
>
|
|
94
97
|
<view class="skeleton-wrap" v-if="dataList === null">
|
|
@@ -192,6 +195,7 @@
|
|
|
192
195
|
showTypeListData:[],
|
|
193
196
|
|
|
194
197
|
//基础配置
|
|
198
|
+
bgColor:'',
|
|
195
199
|
outSpacing:'',
|
|
196
200
|
showMoreBtn: 'Y',
|
|
197
201
|
showTotal:'Y',
|
|
@@ -223,6 +227,10 @@
|
|
|
223
227
|
moreRradius: '40',
|
|
224
228
|
totalColor: '#999',
|
|
225
229
|
|
|
230
|
+
//line
|
|
231
|
+
titleLineTextColor:'',
|
|
232
|
+
titleLineActTextColor:'',
|
|
233
|
+
|
|
226
234
|
//内容
|
|
227
235
|
contMargin: {},
|
|
228
236
|
contBgColor:'#fff',
|
|
@@ -388,6 +396,7 @@
|
|
|
388
396
|
* @param container {object} 业务组件对象自己
|
|
389
397
|
*/
|
|
390
398
|
init(container) {
|
|
399
|
+
this.bgColor = getContainerPropsValue(container, 'content.bgColor', '');
|
|
391
400
|
this.outSpacing = getContainerPropsValue(container, 'content.outSpacing', '20');
|
|
392
401
|
this.titleMargin = getContainerPropsValue(container, 'content.titleMargin', {});
|
|
393
402
|
this.titleBgColor = getContainerPropsValue(container, 'content.titleBgColor', '#fff');
|
|
@@ -409,6 +418,10 @@
|
|
|
409
418
|
this.showHotName = getContainerPropsValue(container, 'content.showHotName', '');
|
|
410
419
|
this.showRightnowName = getContainerPropsValue(container, 'content.showRightnowName', '');
|
|
411
420
|
|
|
421
|
+
//line
|
|
422
|
+
this.titleLineTextColor = getContainerPropsValue(container, 'content.titleLineTextColor', '#333');
|
|
423
|
+
this.titleLineActTextColor= getContainerPropsValue(container, 'content.titleLineActTextColor', '#333');
|
|
424
|
+
|
|
412
425
|
this.isTitleBorder = getContainerPropsValue(container, 'content.isTitleBorder', 'N');
|
|
413
426
|
this.isTitleBorderColor = getContainerPropsValue(container, 'content.isTitleBorderColor', '#eee');
|
|
414
427
|
this.isTitleShadow = getContainerPropsValue(container, 'content.isTitleShadow', 'N');
|
|
@@ -493,6 +506,10 @@
|
|
|
493
506
|
}
|
|
494
507
|
&.button > view {
|
|
495
508
|
padding: 0 30rpx;
|
|
509
|
+
&:last-child {
|
|
510
|
+
margin-right: 0!important;
|
|
511
|
+
}
|
|
512
|
+
|
|
496
513
|
}
|
|
497
514
|
|
|
498
515
|
& > view {
|
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
8
|
virtualBufferHeight= 300;
|
|
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 *
|
|
45
|
+
if(params.bufferHeight) this.virtualBufferHeight = params.bufferHeight * $vm.$rpxNum;
|
|
46
|
+
if(params.otherHeight) this.otherHeight = params.otherHeight * $vm.$rpxNum;
|
|
44
47
|
if(this.virtualType === 'fixed'){
|
|
45
48
|
if(params.fixedHeight === undefined) throw new Error(`FixedHeight is require, got is ${params.fixedHeight}`);
|
|
46
|
-
else this.virtualFixedItemHeight = params.fixedHeight *
|
|
49
|
+
else this.virtualFixedItemHeight = params.fixedHeight * $vm.$rpxNum;
|
|
47
50
|
}
|
|
48
51
|
this.virtualTotalData = [];
|
|
49
|
-
this.virtualVue.virtualViewData = null;
|
|
50
52
|
this.$el = $el;
|
|
51
|
-
|
|
53
|
+
$vm.$nextTick(()=>{
|
|
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} 类型
|
|
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
|
|