Category.js
56.6 KB
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
//分类
var Common = require('Common');
var Network = require('Network');
var TVFocus = require('TVFocus');
var CCTVFocus = require('CCTVFocus');
var FocusInfo = require('FocusInfo');
var TVCanvas = require('TVCanvas');
var TVScrollParameter = require('TVScrollParameter');
var ListView = require('ListView');
var BusinessParameter = require('BusinessParameter');
var ListCell = require('ListCell');
cc.Class({
extends: TVCanvas,
properties: {
_oInit: null,
TYPE_LIST_CELL_SIZE: 5,
_bBackStatus: false,
PFB_TYPE: {
default: null,
type: cc.Prefab,
},
PFB_RECOMMEND: {
default: null,
type: cc.Prefab
},
},
onLoad: function () {
// cc.log("Category(onLoad)------------------>");
this._super();
this._bIsSongListMoving = false;
this._strPageBackgroundCId = "";
this._iShowCellRows = 3;
this._iAlphaCellRows = 0;
this._iHiddenCellRows = 3;
this._iCellCountEachRow = 2;
this._iBeginPositionX = -200;
this._iBeginPositionY = 210;
this._fCellMarginTop = 20;
this._fCellMarginRight = 15;
this._fCellMarginBottom = 10;
this._fCellMarginLeft = 0;
//-----------上下文及参数相关处理------------
let oSceneParameter = this._cApplication.getTopSceneParameter();
if (oSceneParameter) { //其他界面跳转过来的
this._strAppId = oSceneParameter.appId;//应用id
}
//恢复上下文
// if (this._cApplication.getBackStatus()) { //回退界面回来时,把之前的找回来
// this._oSceneContext = this._cApplication.popSceneContext();
// this._cApplication.setBackStatus(false);
// this._bBackStatus = true;
// this._strAppId = this._oSceneContext.appId;
// } else {
this._oSceneContext = {};
this._oSceneContext.focusPath = "NaviList/NaviCell0";
this._oSceneContext.iNaviIndex = 0;
this._oSceneContext.iTypeIndex = 0;
this._oSceneContext.iTypeId = -1; //默认的第一个typeid就是-1
this._oSceneContext.categoryRecordIndexOfFirstCell = 0;
this._oSceneContext.typeListY = 0;
this._oSceneContext.appId = "";
// this._oSceneContext.elderTypeId = oSceneParameter.elderTypeId || 37; //从上级拿过来的二级父Id
// }
//-----上下文及参数处理结束---------
this._oInit = {
bIsNaviDataInit: false,
bIsCatPromotionDataInit: false,
bIsTypeListDataInit: false,
oCatList: {}, //各个应用分类列表集合
oCatProList: {}, //各个应用分类推荐标签的推荐位组合
};
//左分类框框
this._nodeTypeListWrapper = cc.find("TypeListArea/TypeListWrapper", this.node);
this._nodeTypeList = cc.find("TypeList", this._nodeTypeListWrapper);
this._nodeTypeList.addComponent(TVScrollParameter);
//滚动条按钮
let nodeScrollBtn = cc.find("CategoryList/ScrollBarContainer/ScrollBarShadow/ScrollBarBlock", this.node);
var fiScrollBtn = nodeScrollBtn.addComponent(FocusInfo);
this._aFocusTargets[0]['scroll_bar_block'] = nodeScrollBtn;
fiScrollBtn.init(null, true);
this.getPageBg(this, "background");
this.getNavList(); //获取导航栏信息
// this.getCatPromotion(); //获取分类栏上的推荐位组 //暂时用不着
},
getNavList: function () {
var oNavParas = {
'view': 'json',
"start": 0,
"limit": 100,
"parentId": 2,
"sortField": "sequence",
"sortDirection": 'asc',
'token': Common.TEST_API_TOKEN_EDU,
};
Network.ajax("GET", Common.TOPDRAW_API_SERVER_EDU + "Category/ListByParent", null, oNavParas,
function (strResponse) {
try {
var oJSONResult = JSON.parse(strResponse);
if (oJSONResult.businessCode == 'success') {
this._oInit.aNavList = [];
for (var i = 0; i < oJSONResult.resultSet.length; i++) {
var oProgram = oJSONResult.resultSet[i];
// var oTvlink = JSON.parse(oProgram.description);
//copy了一份
var oListCell = {};
// oListCell.appId = oTvlink.appId;
oListCell.id = oProgram.id;
// oListCell.dirURL = oTvlink.dirURL;
// oListCell.destURL = oTvlink.destURL;
// oListCell.playURL = oProgram.value;
oListCell.commonSrc = "";
// oListCell.focusSrc = "";
oListCell.leftSrc = '';
// oListCell.rightSrc = '';
oListCell.commonSrcWidth = ''; //记录选中时的宽度
oListCell.commonSrcHeight = ''; //高度
// if (typeof (oProgram.images.map.normal) != 'undefined' && typeof (oProgram.images.map.normal[0]) != 'undefined') {
// oListCell.focusSrc = oProgram.images.list[oProgram.images.map.normal[0]].fileUrl;
// oListCell.width = oProgram.images.list[oProgram.images.map.normal[0]].width;
// }
if (typeof (oProgram.images.map.icon) != 'undefined' && typeof (oProgram.images.map.icon[0]) != 'undefined') {
oListCell.commonSrc = oProgram.images.list[oProgram.images.map.icon[0]].fileUrl;
oListCell.commonSrcWidth = oProgram.images.list[oProgram.images.map.icon[0]].width;
oListCell.commonSrcHeight = oProgram.images.list[oProgram.images.map.icon[0]].height;
}
if (typeof (oProgram.images.map.stills) != 'undefined' && typeof (oProgram.images.map.stills[0]) != 'undefined') {
oListCell.leftSrc = oProgram.images.list[oProgram.images.map.stills[0]].fileUrl;
}
// if (typeof (oProgram.images.map.background) != 'undefined' && typeof (oProgram.images.map.background[0]) != 'undefined') {
// oListCell.rightSrc = oProgram.images.list[oProgram.images.map.background[0]].fileUrl;
// }
// oListCell.parentId = this.Global[oListCell.appId].baseCId;
this._oInit.aNavList.push(oListCell);
}
} else {
cc.log("Business Error:get nav..." + oJSONResult.description);
}
this._oInit.bIsNaviDataInit = true;
this.initNaviList();
if (this._oInit.bIsNaviDataInit) {
// this.initData();
this.getTypeList();
}
} catch (error) {
cc.log("Business Exception:get nav..." + error);
}
},
function (strResponse) {
cc.log("Business Error:get nav..." + strResponse);
}, this, "uuid");
},
//初始化导航栏
initNaviList: function () {
var self = this;
this._nodeNaviList = cc.find("NaviList", this.node);
this._oInit.aNavTextureList = [];
let count = this._oInit.aNavList.length;
for (let i = 0; i < this._oInit.aNavList.length; i++) {
let oTextureCell = {}; //存储缓存
let nodeNaviCell = new cc.Node();
this._nodeNaviList.addChild(nodeNaviCell, 10, "NaviCell" + i);
//准备焦点坐标
let fiTypeBlock = nodeNaviCell.addComponent(FocusInfo);
fiTypeBlock.init('', true, null, null, 1.0);
this._aFocusTargets[0]['navi_list_cell_' + i] = nodeNaviCell;
if (this._oInit.aNavList[i].commonSrc) {
// nodeNaviCell.width=this._oInit.aNavList[i].width;
// if (this._strAppId && this._strAppId == this._oInit.aNavList[i].appId) { //其他界面跳过来就依据appId选中
// this._oSceneContext.iNaviIndex = i;
// if (!this._bBackStatus) //不是退回来的界面要指定导航栏位置
// this._oSceneContext.focusPath = "NaviList/NaviCell" + i;
// Network.loadImageInNativeRuntime(
// Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.aNavList[i].focusSrc,
// function (texture) {
// count--;
// nodeNaviCell.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
// if (!count) {
// // setTimeout(function () {
// cc.find("NaviList", self.node).getComponent(cc.Layout).updateLayout();
// self._bInitNavSuccess = true;
// self.checkDataReadyAndInitFocus(); //弄焦点
// // }, 300);
// }
// }, null, this
// );
// } else
if (!this._strAppId && i == 0) { //默认是第一个
Network.loadImageInNativeRuntime(
Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.aNavList[i].commonSrc,
function (texture) {
count--;
nodeNaviCell.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, self._oInit.aNavList[i].commonSrcHeight / 2, self._oInit.aNavList[i].commonSrcWidth, self._oInit.aNavList[i].commonSrcHeight / 2));
if (!count) {
// setTimeout(function () {
cc.find("NaviList", self.node).getComponent(cc.Layout).updateLayout();
self._bInitNavSuccess = true;
self.checkDataReadyAndInitFocus(); //弄焦点
// }, 300);
}
}, null, this
);
} else {
Network.loadImageInNativeRuntime(
Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.aNavList[i].commonSrc,
function (texture) {
nodeNaviCell.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, self._oInit.aNavList[i].commonSrcWidth, self._oInit.aNavList[i].commonSrcHeight / 2));
count--;
// cc.log("NavList---------------->" + count);
//等待所有导航初始化完,然后还有Layout排列过程,需要延时下避免焦点位置错乱
if (!count) {
// setTimeout(function () {
cc.find("NaviList", self.node).getComponent(cc.Layout).updateLayout();
self._bInitNavSuccess = true;
self.checkDataReadyAndInitFocus(); //弄焦点
// }, 300);
}
}, null, this
);
}
}
//缓存图片
cc.loader.load(Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.aNavList[i].commonSrc, function (err, texture) {
oTextureCell.commonSrc = texture;
});
// cc.loader.load(Common.TOPDRAW_IMAGE_SERVER + this._oInit.aNavList[i].focusSrc, function (err, texture) {
// oTextureCell.focusSrc = texture;
// });
this._oInit.aNavTextureList.push(oTextureCell);
}
},
// getCatPromotion: function () {
// var oCatPromotionParas = {
// 'view': 'json',
// // "name": "categoryPromotion",
// "start": "0",
// "limit": "20",
// "parentId": 4,
// "sortField": "sequence",
// "sortDirection": "asc",
// 'token': Common.TEST_API_TOKEN_EDU,
// };
// Network.ajax("GET", Common.TOPDRAW_API_SERVER_EDU + "Category/ListByParent", null, oCatPromotionParas,
// function (strResponse) {
// try {
// var oJSONResult = JSON.parse(strResponse);
// if (oJSONResult.businessCode == 'success') {
// this._oInit.oCatPromotion = {};//分类栏上的推荐位集合
// for (var i = 0; i < oJSONResult.resultSet.length; i++) {
// var oProgram = oJSONResult.resultSet[i];
// var oTvlink = JSON.parse(oProgram.tvlink);
// this._oInit.oCatPromotion[oTvlink.id] = {};
// this._oInit.oCatPromotion[oTvlink.id].appId = oTvlink.appId;
// this._oInit.oCatPromotion[oTvlink.appId].promotion = oTvlink.promotion;
// if (oProgram.image != 'undefined') {
// this._oInit.oCatPromotion[oTvlink.appId].imgSrc = oProgram.image[0].fileUrl;
// this._oInit.oCatPromotion[oTvlink.appId].width = oProgram.image[0].width;
// this._oInit.oCatPromotion[oTvlink.appId].height = oProgram.image[0].height;
// }
// }
// } else {
// cc.log("Business Error:catPromotion..." + oJSONResult.description);
// }
// this._oInit.bIsCatPromotionDataInit = true;
// if (this._oInit.bIsCatPromotionDataInit && this._oInit.bIsNaviDataInit) {
// this.initData();
// }
// } catch (error) {
// cc.log("Business Exception:catPromotion..." + error);
// }
// },
// function (strResponse) {
// cc.log("Business Error:catPromotion..." + strResponse);
// }, this, "uuid");
// },
// initData: function () {
// this._oInit.oDefaultCollectionId = {};
// this.getDefaultCollectId(); //获取默认收藏
// },
// getDefaultCollectId: function () {
// // this.playTheMedia(); //播放声音
// // if (this._oInit.oDefaultCollectionId[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId] != "undefined") {
// this.getTypeList();
// // return;
// // }
// var oGetDefaultCollectParas = {
// 'view': 'json',
// "appId": this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId,
// 'token': Common.TEST_API_TOKEN,
// };
// Network.ajax("GET", Common.TOPDRAW_API_SERVER + "User/GetDefaultCollection", null, oGetDefaultCollectParas,
// function (strResponse) {
// try {
// var oJSONResult = JSON.parse(strResponse);
// if (oJSONResult.businessCode == 'success') {
// this._oInit.oDefaultCollectionId[oGetDefaultCollectParas.appId] = oJSONResult.resultSet[0].id;//默认收藏id
// this.getTypeList();
// } else {
// cc.log("Business Error:getdefault ..." + oJSONResult.description);
// }
// } catch (error) {
// cc.log("Business Exception:getdefault ..." + error);
// }
// },
// function (strResponse) {
// cc.log("Business Error:getdefault ..." + strResponse);
// }, this, "uuid");
// },
//获取各个应用的分类列表,然后初始化渲染分类栏
getTypeList: function () {
var self = this;
if (this._oInit.aNavList[this._oSceneContext.iNaviIndex]) {
Network.loadImageInNativeRuntime(
Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.aNavList[this._oSceneContext.iNaviIndex].leftSrc,
function (texture) {
cc.find("leftBg", self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}, null, this
);
// Network.loadImageInNativeRuntime(
// Common.TOPDRAW_IMAGE_SERVER + this._oInit.aNavList[this._oSceneContext.iNaviIndex].rightSrc,
// function (texture) {
// cc.find("rightBg", self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
// }, null, this
// );
}
if (this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id]) {//之前已经保存过应用的分类列表数组时
// this._oCat.iItemSize = this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId].length;
this.updateCatPage(true);
return;
}
var oCatgoryListParas = {
'view': 'json',
"start": "0",
"limit": "100",
// 'parentId': this._oInit.aNavList[this._oSceneContext.iNaviIndex].parentId, //废弃使用该字段,筛选所有带有“基础分类”的结果
"sortField": "sequence",
"sortDirection": "asc",
"parentId": this._oInit.aNavList[this._oSceneContext.iNaviIndex].id, //
'token': Common.TEST_API_TOKEN_EDU,
};
Network.ajax("GET", Common.TOPDRAW_API_SERVER_EDU + "Category/ListByParent", null, oCatgoryListParas,
function (strResponse) {
try {
var oJSONResult = JSON.parse(strResponse);
if (oJSONResult.businessCode == 'success') {
this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id] = [];
for (var i = 0; i < oJSONResult.resultSet.length; i++) {
// if (!oJSONResult.resultSet[i].entrance_url || -1 == oJSONResult.resultSet[i].entrance_url.indexOf("基础分类2/")) continue; //剔除多余数据,因为没有带parentId字段,数据有点杂
this._iNavItemSize = oJSONResult.resultSet.length;
let oProgram = oJSONResult.resultSet[i];
let strId = oProgram.id;
let strName = oProgram.name;
let strImgSrc = '';
let width = '';
let height = '';
if (typeof (oProgram.images.map.normal) != 'undefined' && oProgram.images.map.normal[0] != null) {
let index = oProgram.images.map.normal[0];
strImgSrc = oProgram.images.list[index].fileUrl;
width = oProgram.images.list[index].width;
height = oProgram.images.list[index].height;
}
//copy了一份
let oListCell = {};
oListCell.cId = strId;//分类的id
oListCell.name = strName;
oListCell.imgSrc = strImgSrc;
oListCell.width = width;
oListCell.height = height;
oListCell.tvlink = "requestMediaList('" + strId + "')";
this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id].push(oListCell);
}
// let oCell = {};
// oCell.cId = '-1';//推荐位的Id
// oCell.name = '推荐';
// oCell.imgSrc = this._oInit.oCatPromotion[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id].imgSrc;
// oCell.width = this._oInit.oCatPromotion[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id].width;
// oCell.height = this._oInit.oCatPromotion[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id].height;
// oCell.tvlink = "requestPromotion('" + this._oInit.oCatPromotion[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id].promotion + "')";
// this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id].unshift(oCell);//把推荐添加到分类列表
// this._oCat.iItemSize = this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId].length;
// if (!this._bIsFocusInited) {
// this.initCatIndex();
// }
this.updateCatPage(true);
} else {
cc.log("Business Error:CatgoryList ..." + oJSONResult.description);
}
this._oInit.bIsTypeListDataInit = true;
} catch (error) {
cc.log("Business Exception:CatgoryList ..." + error);
}
},
function (strResponse) {
cc.log("Business Error:CatgoryList ..." + strResponse);
}, this, "uuid");
},
//ture时渲染节目出来,需要两个值iRequestPageIndex,iCurrentActiveIndex
updateCatPage: function (flag) {
var self = this;
this._nodeTypeList.y = 0; //每次初始化typeList,先推上去,如果回退回来的界面会有其他变量恢复它
//先释放以前数据
// this._nodeTypeList.removeAllChildren(); //内存泄漏
// this._nodeTypeList.destroyAllChildren(); //释放不干净
//------------------------
for (let i = 0; i < this._nodeTypeList.childrenCount; i++) {
this._nodeTypeList.children[i].active = false;
// cc.log("子节点名称:"+this._nodeTypeList.children[i].name);
}
//------------------------
let count = this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id].length;
// cc.log("count-------------"+count);
if (!count) this._bInitTypeSuccess = true;
for (let i = 0; i < this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id].length; i++) {
let id = this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i].cId;
let nodeTypeListCell = cc.find("TypeListCell_" + id + "_" + i, this._nodeTypeList);
if (!nodeTypeListCell) {
// cc.log("造新节点");
nodeTypeListCell = cc.instantiate(this.PFB_TYPE);
nodeTypeListCell.y = -nodeTypeListCell.height / 2 - i * (nodeTypeListCell.height);
this._nodeTypeList.addChild(nodeTypeListCell, 10, "TypeListCell_" + id + "_" + i);
//准备焦点坐标
let fiTypeBlock = nodeTypeListCell.addComponent(FocusInfo);
fiTypeBlock.init('', true, null, null, 1.15);
this._aFocusTargets[0]['type_list_cell_' + id] = nodeTypeListCell;
}
nodeTypeListCell.active = true;
// cc.log("nodeTypeListCell位置:"+nodeTypeListCell.position); //
// cc.log("nodeTypeList: "+this._nodeTypeList.active);
// nodeTypeListCell.getComponent('pfbCategoryTypeCell').init(this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i], null);
// cc.log("/////"+this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i]);
if (this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i]) {
let width = this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i].width;
let height = this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i].height / 2;
nodeTypeListCell.width = width;
nodeTypeListCell.height = height;
this._nodeTypeHeight = height;
// cc.log("inittype------------------>" + this._oSceneContext.iTypeIndex);
if (i == this._oSceneContext.iTypeIndex) { //默认第一个Type为选中状态
this._oSceneContext.iTypeId = id;
//这种方式加载远程图片有问题 ,切换Type导航时不能显示图片
// Network.loadImageInNativeRuntime(
// Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i].imgSrc,
// function (texture) {
// cc.find('Bg', nodeTypeListCell).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, height, width, height));
// count--;
// if (!count) { //可能为最后一个!!!
// self._bInitTypeSuccess = true;
// self.checkDataReadyAndInitFocus(); //弄焦点
// }
// }, null, this
// );
cc.loader.load(Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i].imgSrc,
function (err, texture) {
cc.find('Bg', nodeTypeListCell).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, height, width, height));
count--;
if (!count) { //可能为最后一个!!!
self._bInitTypeSuccess = true;
self.checkDataReadyAndInitFocus(); //弄焦点
}
});
} else {
var self = this;
// cc.log("type list "+(Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i].imgSrc));
// Network.loadImageInNativeRuntime(
// Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i].imgSrc,
// function (texture) {
// cc.find('Bg', nodeTypeListCell).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, width, height));
// count--;
// // cc.log("InitType-------------------->" + count);
// if (!count) {
// self._bInitTypeSuccess = true;
// self.checkDataReadyAndInitFocus(); //弄焦点
// }
// }, null, this
// );
cc.loader.load(Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][i].imgSrc,
function (err, texture) {
cc.find('Bg', nodeTypeListCell).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, width, height));
count--;
if (!count) { //可能为最后一个!!!
self._bInitTypeSuccess = true;
self.checkDataReadyAndInitFocus(); //弄焦点
}
});
}
// cc.log("nodeTypeListCell位置:"+nodeTypeListCell.position);
}
}
let tvlink = this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][this._oSceneContext.iTypeIndex].tvlink;
eval(tvlink);
var self = this;
// function requestPromotion(strName) { //默认第一个时才显示右侧推荐位
// self.requestPromotion(strName);
// };
function requestMediaList(cId) {
self.requestMediaList(cId);
};
},
// //右边推荐位
// requestPromotion: function (strName) {
// cc.find("CategoryList", this.node).active = false;
// cc.find("DataPosition", this.node).active = false;
// cc.find("rightBg", this.node).active = true;
// cc.find("Promotion", this.node).active = true;
// if (this._oInit.oCatProList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId]) {
// this.updatePromotion();
// return;
// }
// var oCatPromotionParas = {
// 'view': 'json',
// "categoryId": strName,
// "start": "0",
// "limit": "20",
// 'token': Common.TEST_API_TOKEN_EDU,
// };
// Network.ajax("GET", Common.TOPDRAW_API_SERVER + "Promotion/ListItemByName", null, oCatPromotionParas,
// function (strResponse) {
// try {
// var oJSONResult = JSON.parse(strResponse);
// if (oJSONResult.businessCode == 'success') {
// this._oInit.oCatProList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId] = [];
// this._oInit.oCatProList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId] = oJSONResult.resultSet;
// this.updatePromotion();
// } else {
// cc.log("Business Error:CatPromotion ..." + oJSONResult.description);
// }
// } catch (error) {
// cc.log("Business Exception:CatPromotion ..." + error);
// }
// },
// function (strResponse) {
// cc.log("Business Error:CatPromotion ..." + strResponse);
// }, this, "uuid");
// },
// updatePromotion: function () {
// //先释放以前数据
// // cc.find("Promotion", this.node).removeAllChildren(); //内存泄漏
// // cc.find("Promotion", this.node).destroyAllChildren(); //destroy不干净
// for (let i = 0; i < cc.find("Promotion", this.node).childrenCount; i++) { //
// cc.find("Promotion", this.node).children[i].active = false;
// }
// //将列表的空占位图隐藏
// cc.find('BlankIcon', this.node).opacity = 0;
// var self = this;
// var aResult = this._oInit.oCatProList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId];
// let count = aResult.length;
// if (!count) this._bInitRightPromotionSuccess = true;
// for (let i = 0; i < aResult.length; i++) {
// let id = aResult[i].id;
// let nodePromotion = cc.find("Promotion/promotion" + id, this.node);
// if (!nodePromotion) {
// nodePromotion = cc.instantiate(this.PFB_RECOMMEND);
// this.node.getChildByName("Promotion").addChild(nodePromotion, 10, "promotion" + id);
// //准备焦点坐标
// let fiElevenBlock = nodePromotion.addComponent(FocusInfo);
// fiElevenBlock.init(
// aResult[i].tvlink, true, null, null, 1.0 //最后一个参数决定要不要放大显示
// );
// this._aFocusTargets[0]['promotion' + id] = nodePromotion;
// }
// nodePromotion.active = true;
// nodePromotion.getComponent('pfbRecommendCell').init(aResult[i], function () { //让细胞自己渲染
// count--;
// if (!count) {
// self._bInitRightPromotionSuccess = true;
// self.checkDataReadyAndInitFocus(self._bInitRightPromotionSuccess); //弄焦点
// }
// });
// }
// },
requestMediaList: function (cId) {
var self = this;
cc.find("rightBg", this.node).active = false;
cc.find("Promotion", this.node).active = false;
cc.find("CategoryList", this.node).active = true;
cc.find("DataPosition", this.node).active = true;
if (cId) {
//把之前的东西删掉
let nodeCategoryList = this.node.getChildByName('CategoryList');
// nodeCategoryList.getChildByName('DataContainerMask').getChildByName('DataContainer').removeAllChildren();
nodeCategoryList.getChildByName('DataContainerMask').getChildByName('DataContainer').destroyAllChildren();
let strAppId = this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId;
switch (strAppId) {
case BusinessParameter.CARTOON_APPID:
// this._oSceneContext.focusPath = this._oSceneContext.focusPath || "SongList/DataContainerMask/DataContainer/ListCell0/SongTitleContainer";
this._strSongListCellComponentName = "CategoryCartoonListCell";
this._iBeginPositionX = -291;
this._iBeginPositionY = 109;
this._iShowCellRows = 2;
this._iAlphaCellRows = 0;
this._iHiddenCellRows = 2;
this._iCellCountEachRow = 4;
this._fCellMarginTop = 3;
break;
default:
// this._oSceneContext.focusPath = this._oSceneContext.focusPath || "SongList/DataContainerMask/DataContainer/ListCell0/ImageBlock";
this._strSongListCellComponentName = "CategoryOtherListCell";
this._iBeginPositionX = -271;
this._iBeginPositionY = 166;
this._iShowCellRows = 3;
this._iAlphaCellRows = 0;
this._iHiddenCellRows = 3;
this._iCellCountEachRow = 3;
this._fCellMarginTop = 3;
break;
}
//重新开始
let lvCategoryList = nodeCategoryList.getComponent(ListView);
if (!lvCategoryList) {
lvCategoryList = nodeCategoryList.addComponent(ListView);
}
lvCategoryList.init(this, this._iShowCellRows, this._iAlphaCellRows, this._iHiddenCellRows, this._iCellCountEachRow, this._strSongListCellComponentName,
this._iBeginPositionX, this._iBeginPositionY,//起始位置
this._fCellMarginTop, this._fCellMarginRight, this._fCellMarginBottom, this._fCellMarginLeft,
1, 1, //0-横向 1-纵向
function () {
this.renderCategoryList(cId);
}
);
this._strAppId = this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId;
lvCategoryList.setDataDecorator(
function (oData, onDecorate, oScope) {
let aData = oData.refData;
// //造一个跳转tvlink
// for (let i = 0; i < aData.length; i++) {
// //造一个跳转界面
// let tvlink = '{"click": [{"action": "ChangeScene","parameters": {"sceneName":"sceneProgram",\
// "appId":"' + self._strAppId + '","id":"' + aData[i].id + '"}}]}';
// aData[i].tvlink = tvlink;
// }
if (onDecorate) {
if (null != oScope) {
onDecorate.call(oScope, aData);
} else {
onDecorate(aData);
}
}
}
);
lvCategoryList.setDataPositionRender(function (iPosition, iCount) {
//这里是ListView的this 执行时作用域
let nodeDataPosition = self.node.getChildByName('DataPosition');
if (null == iCount) {
iCount = parseInt(nodeDataPosition.getComponent(cc.Label).string.split('/')[1]);
// cc.log(iCount);
}
nodeDataPosition.getComponent(cc.Label).string = Math.ceil(Math.min((iPosition + self._iShowCellRows * self._iCellCountEachRow - 1), iCount) / self._iShowCellRows / self._iCellCountEachRow) + " / " + Math.ceil(iCount / self._iShowCellRows / self._iCellCountEachRow);
nodeDataPosition.x = Common.SCREEN_WIDTH / 2 - 70 - nodeDataPosition.width / 2;
// this._compSceneCanvas.checkCountAndDisplayTopBtns(iCount);
});
}
},
renderCategoryList: function (cId) {
// let strAppId = this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId;
let nodeCategoryList = this.node.getChildByName('CategoryList');
//请求列表
let oMediaParas = {};
oMediaParas.categoryId = cId;//
oMediaParas.appId = "";
let iStart1 = 0;
if (null != this._oSceneContext.categoryRecordIndexOfFirstCell) {
iStart1 = this._oSceneContext.categoryRecordIndexOfFirstCell;
}
let lvCategoryList = nodeCategoryList.getComponent(ListView);
//函数默认取一页数据,但是第一次显示需要加上Alpha的部分
lvCategoryList.setDataSource(
"GET",
Common.TOPDRAW_API_SERVER_EDU + "Media/List",
oMediaParas,
iStart1, (lvCategoryList.getShowCellRows() + lvCategoryList.getAlphaCellRows()) * lvCategoryList.getCellCountEachRow(),
null, null
);
lvCategoryList.loadData(
function (strResponse) {
lvCategoryList.renderInitData(strResponse, function () {
// cc.log("InitCategoryList-------------------->");
var oJSONResult = JSON.parse(strResponse);
if (oJSONResult.resultSet.length <= 0) { //没有数据就显示占位图
cc.find('BlankIcon', this.node).opacity = 255;
} else {
cc.find('BlankIcon', this.node).opacity = 0;
}
this._bInitCategoryListSuccess = true;
this._oSceneContext.categoryRecordIndexOfFirstCell = lvCategoryList.getRecordIndexOfFirstCellInPage();
this.checkDataReadyAndInitFocus(this._bInitCategoryListSuccess);
});
},
null,
this
);
},
/**
*
* @param {} bInitSuccess 这里可能初始化右侧推荐位或者categoryList列表
*/
checkDataReadyAndInitFocus: function (bInitSuccess) {
if (bInitSuccess) this._bInitSuccess = bInitSuccess; //全局保存缓存值
// cc.log(this._bInitSuccess + "-----" + this._bInitTypeSuccess);
if (!this._bIsFocusInit && this._bInitNavSuccess && this._bInitTypeSuccess && this._bInitSuccess) {
this.scheduleOnce(() => { //指定0让回调函数在下一帧立即执行
this.initFocus();
}, 0);
this._bIsFocusInit = true;
}
},
initFocus: function () {
// this._oSceneContext.focusPath = "NaviList/NaviCell0"; //---------------------先写死
var nodeInitFocus = cc.find(this._oSceneContext.focusPath, this.node);
// cc.log("回退界面:" + this._oSceneContext.focusPath);
var nodeFocus = new cc.Node('nodeFocus');
this.node.addChild(nodeFocus, 0);
this._cFocus = this.node.getChildByName('nodeFocus').addComponent(CCTVFocus);
this._cFocus.init('focusContainer', this,
nodeInitFocus.getComponent(FocusInfo),
Common.SCREEN_WIDTH, Common.SCREEN_HEIGHT, 0, 0, 1.0, true);//暂且认定这几个参数控制焦点大小
//处理焦点位于下方问题
if (this._oSceneContext.typeListY) {
this._nodeTypeList.y = this._oSceneContext.typeListY;
}
},
keyDownDirection: function (Direct) {
var fiFocusTarget = null;
var fiCurrentFocus = this._fiCurrentFocus;
var oScrollParameter = null;
let aCheckResult;
fiFocusTarget = this._cFocus.findTarget(fiCurrentFocus, this._aFocusTargets, 0, Direct);
if (!fiFocusTarget) { return; }
aCheckResult = this.checkFocusTarget(fiFocusTarget, oScrollParameter);
fiFocusTarget = aCheckResult[0];
oScrollParameter = aCheckResult[1];
// if (0 == this._fiCurrentFocus.node.name.indexOf("NaviCell") && 0 != fiFocusTarget.node.name.indexOf("NaviCell")) {
// if (this._bInitTypeSuccess != undefined && !this._bInitTypeSuccess) return; //type和promotion未初始完成不允许跳转(回退界面不会初始化this._bInitRighjtPromotionSuccess)
// if (this._bInitRightPromotionSuccess != undefined && !this._bInitRightPromotionSuccess) return;
// if (this._bInitCategoryListSuccess != undefined && !this._bInitCategoryListSuccess) return;
// }
cc.log("flyFocus.....");
this.scheduleOnce(() => { //指定0让回调函数在下一帧立即执行(推荐位初始化图片后,需等待下一帧操作)
this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Direct, null, oScrollParameter);
}, 0);
},
checkFocusTarget: function (fiFocusTarget, oScrollParameter) {
if (fiFocusTarget && 0 == fiFocusTarget.node.name.indexOf("NaviCell") && 0 != this._fiCurrentFocus.node.name.indexOf("NaviCell")) {
fiFocusTarget = cc.find("NaviCell" + this._oSceneContext.iNaviIndex, this._nodeNaviList).getComponent(FocusInfo);
}
if (fiFocusTarget && 0 == fiFocusTarget.node.name.indexOf("TypeListCell")) {
if (0 != this._fiCurrentFocus.node.name.indexOf("TypeListCell")) {//如果不是TypeList之间跳转,则哪里来回哪里去
fiFocusTarget = cc.find("TypeListCell_" + this._oSceneContext.iTypeId + "_" + this._oSceneContext.iTypeIndex, this._nodeTypeList).getComponent(FocusInfo);
} else {
let iDirRate = null;
if (-fiFocusTarget.node.y + fiFocusTarget.node.height / 2 - this._nodeTypeList.y >= this._nodeTypeListWrapper.height) {
oScrollParameter = this._nodeTypeList.getComponent(TVScrollParameter);
oScrollParameter.setHasRelation(true);
oScrollParameter.setStep(-(-fiFocusTarget.node.y + fiFocusTarget.node.height / 2 + 1 - this._nodeTypeList.y) + this._nodeTypeListWrapper.height);
oScrollParameter.setTargetPosition(this._nodeTypeList.y - oScrollParameter.getStep());
this._oSceneContext.typeListY = this._nodeTypeList.y - oScrollParameter.getStep();
iDirRate = 1;
}
if (-fiFocusTarget.node.y - this._nodeTypeList.y < 0) {
oScrollParameter = this._nodeTypeList.getComponent(TVScrollParameter);
oScrollParameter.setHasRelation(true);
oScrollParameter.setStep(-fiFocusTarget.node.y - fiFocusTarget.node.height / 2 - this._nodeTypeList.y);
oScrollParameter.setTargetPosition(this._nodeTypeList.y + oScrollParameter.getStep());
this._oSceneContext.typeListY = this._nodeTypeList.y + oScrollParameter.getStep();
iDirRate = -1;
}
}
}
return [fiFocusTarget, oScrollParameter];
},
onKeyDown: function (event) {
this._super(event);
//TODO:给ListView传值,使其可以让滑块跟随滚动
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList) {
lvCategoryList.setCurrentFocus(this._fiCurrentFocus);
}
switch (event.keyCode) {
case cc.macro.KEY.up:
case Common.ANDROID_KEY.up:
if (this._bIsCategoryItemMoving || this._bIsSongListMoving) {
return;
}
if (0 == this._fiCurrentFocus.node.getName().indexOf('ScrollBarBlock')) { //如果滚动条
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollAPageUp()) {
}
return;
}
if (0 == this._fiCurrentFocus.node.getName().indexOf('CategoryCartoonListCell')) {
var index = parseInt(this._fiCurrentFocus.node.getName().replace('CategoryCartoonListCell', ''));
// cc.log("当前时多少条目:"+index);
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollARowUp(index)) {
return;
}
}
if (0 == this._fiCurrentFocus.node.getName().indexOf('CategoryOtherListCell')) {
var index = parseInt(this._fiCurrentFocus.node.getName().replace('CategoryOtherListCell', ''));
// cc.log("当前时多少条目:"+index);
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollARowUp(index)) {
return;
}
}
this.keyDownDirection(Common.MOVE_DIRECTION_UP);
break;
case cc.macro.KEY.right:
case Common.ANDROID_KEY.right:
// this.scheduleOnce(() => { //指定0让回调函数在下一帧立即执行
// this.initFocus();
// }, 0);
this.keyDownDirection(Common.MOVE_DIRECTION_RIGHT);
break;
case cc.macro.KEY.down:
case Common.ANDROID_KEY.down:
if (this._bIsCategoryItemMoving || this._bIsSongListMoving) {
return;
}
if (0 == this._fiCurrentFocus.node.getName().indexOf('ScrollBarBlock')) { //如果是滚动条
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollAPageDown()) {
}
return;
}
if (0 == this._fiCurrentFocus.node.getName().indexOf('CategoryCartoonListCell')) {
var index = parseInt(this._fiCurrentFocus.node.getName().replace('CategoryCartoonListCell', ''));
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollARowDown(null, index)) {
return;
}
}
if (0 == this._fiCurrentFocus.node.getName().indexOf('CategoryOtherListCell')) {
var index = parseInt(this._fiCurrentFocus.node.getName().replace('CategoryOtherListCell', ''));
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollARowDown(null, index)) {
return;
}
}
this.keyDownDirection(Common.MOVE_DIRECTION_DOWN);
break;
case cc.macro.KEY.left:
case Common.ANDROID_KEY.left:
this.keyDownDirection(Common.MOVE_DIRECTION_LEFT);
break;
case cc.macro.KEY.enter:
case cc.macro.KEY.space:
case Common.ANDROID_KEY.enter:
this._oSceneContext.appId = this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId;
this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
break;
case cc.macro.KEY.backspace:
case Common.ANDROID_KEY.back:
this.backAScene();
break;
}
//记录CategoryList滚动位置
if (lvCategoryList) {
this._oSceneContext.categoryRecordIndexOfFirstCell = lvCategoryList.getRecordIndexOfFirstCellInPage();
}
},
onBeforeFocusChange: function (event) {
this._super(event);
var self = this;
let fiFrom = event.detail.from;
let fiTo = event.detail.to;
if (0 == fiFrom.node.getName().indexOf('NaviCell') && 0 == fiTo.node.getName().indexOf('NaviCell')) {
let iIndex = fiFrom.node.name.replace("NaviCell", '');
// if (this._oInit.aNavTextureList[iIndex].commonSrc) { //使用缓存
// fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(self._oInit.aNavTextureList[iIndex].commonSrc);
// }
Network.loadImageInNativeRuntime(
this._oInit.aNavTextureList[iIndex].commonSrc,
function (texture) {
fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, fiFrom.node.width, fiFrom.node.height));
}, null, this
);
}
if (0 == fiTo.node.getName().indexOf('NaviCell')) {
this._oSceneContext.iNaviIndex = fiTo.node.name.replace("NaviCell", '');
// if (this._oInit.aNavTextureList[this._oSceneContext.iNaviIndex].commonSrc) { //使用缓存
// fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(self._oInit.aNavTextureList[self._oSceneContext.iNaviIndex].focusSrc);
// cc.find("NaviList", this.node).getComponent(cc.Layout).updateLayout();
// }
Network.loadImageInNativeRuntime(
this._oInit.aNavTextureList[this._oSceneContext.iNaviIndex].commonSrc,
function (texture) {
fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, fiTo.node.height, fiTo.node.width, fiTo.node.height));
}, null, this
);
if (0 == fiFrom.node.getName().indexOf('NaviCell')) {
this._bInitTypeSuccess = false;
this._bInitRightPromotionSuccess = false;
this._oSceneContext.iTypeIndex = 0;//将下面的Type位置恢复到0
this._oSceneContext.iTypeId = -1; //id也初始化
this.scheduleOnce(this.getTypeList, 0.3);
}
}
if (0 == fiFrom.node.getName().indexOf('TypeListCell') && 0 == fiTo.node.getName().indexOf('TypeListCell')) { //TODO:
fiFrom.node.getChildByName("Bg").getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, fiFrom.node.width, fiFrom.node.height));
if (this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][this._oSceneContext.iTypeIndex].imgSrc) {
// Network.loadImageInNativeRuntime(
// Common.TOPDRAW_IMAGE_SERVER + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId][this._oSceneContext.iTypeIndex].imgSrc,
// function (texture) {
// fiFrom.node.getChildByName("Bg").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, fiFrom.node.width, fiFrom.node.height));
// }, null, this
// );
cc.loader.load(Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][this._oSceneContext.iTypeIndex].imgSrc, function (err, texture) {
fiFrom.node.getChildByName("Bg").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, fiFrom.node.width, fiFrom.node.height));
});
}
}
if (0 == fiFrom.node.getName().indexOf('CategoryCartoonListCell') || 0 == fiFrom.node.getName().indexOf('CategoryOtherListCell')) {
fiFrom.node.getComponent(ListCell).setUIWithoutFocus();
}
if (0 == fiFrom.node.getName().indexOf('promotion')) {
fiFrom.node.getComponent('pfbRecommendCell').setUIWithoutFocus();
}
},
onAfterFocusChange: function (event) {
this._super(event);
var self = this;
let fiFrom = event.detail.from;
let fiTo = event.detail.to;
if (0 == fiTo.node.getName().indexOf('promotion')) {
fiTo.node.getComponent('pfbRecommendCell').setUIWithFocus();
}
if (0 == fiTo.node.getName().indexOf('TypeListCell')) { //TODO:
// this._oSceneContext.iTypeIndex = fiTo.node.name.replace("TypeListCell", '');
let arr = fiTo.node.getName().split("_");
if (arr[1] && arr[2]) {
this._oSceneContext.iTypeId = arr[1];
this._oSceneContext.iTypeIndex = arr[2];
}
if (this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][this._oSceneContext.iTypeIndex].imgSrc) {
// Network.loadImageInNativeRuntime(
// Common.TOPDRAW_IMAGE_SERVER + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId][this._oSceneContext.iTypeIndex].imgSrc,
// function (texture) {
// cc.log("///////////"+(Common.TOPDRAW_IMAGE_SERVER + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].appId][this._oSceneContext.iTypeIndex].imgSrc));
// fiTo.node.getChildByName("Bg").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, fiTo.node.height, fiTo.node.width, fiTo.node.height));
// }, null, this
// );
// cc.log("切换后加载图片:"+(Common.TOPDRAW_IMAGE_SERVER + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][this._oSceneContext.iTypeIndex].imgSrc));
cc.loader.load(Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][this._oSceneContext.iTypeIndex].imgSrc, function (err, texture) {
fiTo.node.getChildByName("Bg").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, fiTo.node.height, fiTo.node.width, fiTo.node.height));
});
}
if (0 == fiFrom.node.getName().indexOf('TypeListCell')) {
this._oSceneContext.categoryRecordIndexOfFirstCell = 0; //将列表记录置空
let tvlink = this._oInit.oCatList[this._oInit.aNavList[this._oSceneContext.iNaviIndex].id][this._oSceneContext.iTypeIndex].tvlink;
eval(tvlink);
function requestPromotion(strName) {
self.requestPromotion(strName);
};
function requestMediaList(cId) {
self.requestMediaList(cId);
};
}
}
if (0 == fiTo.node.getName().indexOf('CategoryCartoonListCell') || 0 == fiTo.node.getName().indexOf('CategoryOtherListCell')) {
fiTo.node.getComponent(ListCell).setUIWithFocus();
}
},
doCurrentFocusTVLinkAction: function (strAction) {
let strTVLink = this._fiCurrentFocus.getTVLink();
var joTVLink = null;
try {
joTVLink = JSON.parse(strTVLink);
let jaOperationList = joTVLink.click;
for (let i = 0; i < jaOperationList.length; i++) {
switch (jaOperationList[i].action) {
default:
this.doTVLinkAction(jaOperationList[i]);
break;
}
}
} catch (error) {
cc.log("runTVLinkAction Exception..." + error);
}
},
onListScrollStart: function () {
this._bIsSongListMoving = true;
// cc.log("scroll start");
},
onListScrollEnd: function () {
this._bIsSongListMoving = false;
// cc.log("scroll completed");
},
onDestroy: function () {
cc.director.emit('stop_render'); //分发事件
// var deps = cc.loader.getDependsRecursively(this.PFB_RECOMMEND);
// cc.loader.release(deps);
// this.node.destroyAllChildren();
// this._nodeTypeList.destroyAllChildren();
// cc.find("Promotion", this.node).destroyAllChildren();
// let nodeCategoryList = this.node.getChildByName('CategoryList');
// nodeCategoryList.getChildByName('DataContainerMask').getChildByName('DataContainer').destroyAllChildren();
},
});