gameDetail.js
31.2 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
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: {
PFB_CATEGORY: {
default: null,
type: cc.Prefab
},
PFB_RECOMMEN_CATEGORY: {
default: null,
type: cc.Prefab
},
},
onLoad: function () {
this._super();
this._oInit = {};
this._bCollected = false;
this._bInitExistApk = false;
this._bIsExistApk = false;
this._iSceneStatus = 0;
this._oSceneContext._packageName = "";
this._oSceneContext._className = "";
this._oSceneContext._downloadUrl = "";
this._oSceneContext._cellData = "";
this._oSceneContext._iCurrentLeftIndex = 1;
this._oSceneContext.focusPath = "ButtonOpen";
if (this._cApplication.getBackStatus()) {
//恢复上下文 包括
//光标位置 focusPath
let oSceneContext = this._cApplication.popSceneContext();
if (oSceneContext) {
this._oSceneContext = oSceneContext;
cc.log(this._oSceneContext);
}
this._cApplication.setBackStatus(false);
}
let aSceneContext = this._cApplication.getSceneContext();
let aSceneParameter = this._cApplication.getSceneParameter();
cc.log("gameDetail->aSceneParameter..." + JSON.stringify(aSceneParameter));
if (aSceneParameter.length) {
this._oSceneContext._packageName = aSceneParameter[aSceneParameter.length - 1].packageName;
this._oSceneContext._className = aSceneParameter[aSceneParameter.length - 1].activityName;
this._oSceneContext._downloadUrl = aSceneParameter[aSceneParameter.length - 1].downloadUrl;
this._oSceneContext._cellData = aSceneParameter[aSceneParameter.length - 1].cellData;
} else if (aSceneParameter) {
this._oSceneContext._packageName = aSceneParameter.packageName;
this._oSceneContext._className = aSceneParameter.activityName;
this._oSceneContext._downloadUrl = aSceneParameter.downloadUrl;
this._oSceneContext._cellData = aSceneParameter.cellData;
}
cc.log("类名:" + this._oSceneContext._packageName);
cc.log("下载链接:" + this._oSceneContext._downloadUrl);
//Type分类框框
this._nodeTypeListWrapper = cc.find("TypeListArea/TypeListWrapper", this.node);
this._nodeTypeList = cc.find("TypeList", this._nodeTypeListWrapper);
this._nodeTypeList.addComponent(TVScrollParameter);
// cc.find("Desc/Collect", this.node).getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, 172, 56));
cc.find("ButtonOpen", this.node).getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, 264, 100));
// cc.find("ButtonVip", this.node).getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, 572, 72));
cc.find("FullView", this.node).zIndex = 100;
cc.find("FullDesc", this.node).zIndex = 100;
this._nodeTypeListWrapper = cc.find("TypeListArea/TypeListWrapper", this.node);
this._nodeTypeList = cc.find("TypeList", this._nodeTypeListWrapper);
this._nodeTypeList.addComponent(TVScrollParameter);
this.isExistApk();
this.checkDataReadyAndInitFocus();
this.initPrefab(); //获取导航栏信息
// this.getTypeList();
this.checkPfbReadyAndInitPage();
this.saveHistory();
},
saveHistory: function () {
var oDataCell = JSON.parse(this._oSceneContext._cellData);
var gameHistory = JSON.parse(cc.sys.localStorage.getItem("gameHistoryList"));
if (gameHistory != null) {
if (-1 == JSON.stringify(gameHistory.resultSet).indexOf(JSON.stringify(oDataCell))) {
gameHistory.resultSet.push(oDataCell);
gameHistory.count++;
cc.sys.localStorage.setItem("gameHistoryList", JSON.stringify(gameHistory));
}
} else {
let oData = {};
oData.businessCode = "success";
oData.count = 1;
oData.resultSet = [];
oData.resultSet.push(oDataCell);
cc.sys.localStorage.setItem("gameHistoryList", JSON.stringify(oData));
}
cc.log("检查存储的数据:" + cc.sys.localStorage.getItem("gameHistoryList"));
},
initPrefab: function () {
for (let i = 0; i < 6; i++) { //默认先加载一页数量的预制
// cc.log("加载预制...");
let nodeCategoryListCell = cc.instantiate(this.PFB_RECOMMEN_CATEGORY);
nodeCategoryListCell.x = nodeCategoryListCell.width / 2 + i * (nodeCategoryListCell.width + 25);
this._nodeTypeList.addChild(nodeCategoryListCell, 10, "good_cell_" + i);
//准备焦点坐标
let fiCategoryBlock = nodeCategoryListCell.addComponent(FocusInfo);
cc.loader.loadRes('GameDetail/icon' + i, cc.Texture2D, function (err, texture) { //背景框
nodeCategoryListCell.getChildByName('Pic').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
// spriteFrame._calculateUV();
});
fiCategoryBlock.init(
'',
true, null, null, 1.0
);
nodeCategoryListCell.active = false; //在初始化时已经实现,这里只是为了避免一闪而过的背景
// nodeCategoryListCell.getComponent(FocusInfo).setEnable(false);
this._aFocusTargets[0]['category_list_cell_' + i] = nodeCategoryListCell;
}
},
getTypeList: function () {
this._nodeTypeList.y = 0;
// var oNavParas = {
// 'view': 'json',
// "start": 0,
// "limit": 10,
// "dictionaryCode": "categoryNav",
// "sortField": "sequence",
// "sortDirection": 'asc',
// 'token': Common.TEST_API_TOKEN,
// };
// Network.ajax("GET", Common.TOPDRAW_API_SERVER + "Dictionary/ListItem", null, oNavParas,
// function (strResponse) {
try {
// var oJSONResult = JSON.parse(strResponse);
// var oJSONResult = this.test_detail_type_json.json;
// if (oJSONResult.businessCode == 'success') {
for (let i = 0; i < this._oInit.aListImage.length; i++) {
let oProgram = this._oInit.aListImage[i];
let node = cc.instantiate(this.PFB_CATEGORY);
if (oProgram && oProgram.fileUrl) {
node.width = oProgram.width;
node.height = oProgram.height;
node.getChildByName("Pic").width = oProgram.width;
node.getChildByName("Pic").height = oProgram.height;
// cc.loader.loadRes(oProgram.image[0].fileUrl, cc.Texture2D, function (err, texture) {
// node.getChildByName("Pic").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
// });
Network.loadImageInNativeRuntime(
Common.TOPDRAW_IMAGE_SERVER + oProgram.fileUrl, null,
function (texture, iRequestId) {
node.getChildByName("Pic").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}, function () { }, this
);
}
node.x = node.width / 2 + i * (node.width + 24);
this._nodeTypeList.addChild(node, 10, "TypeListCell" + i);
//准备焦点坐标
let fiNodeBlock = node.addComponent(FocusInfo);
fiNodeBlock.init(
'', true, null, null, 1.06 //最后一个参数决定要不要放大显示
);
this._aFocusTargets[0]["type_list_cell_" + i] = node;
}
// } else {
// cc.log("Business Error:get nav..." + oJSONResult.description);
// }
} catch (error) {
cc.log("Business Exception:get nav..." + error);
}
// },
// function (strResponse) {
// cc.log("Business Error:get nav..." + strResponse);
// }, this, "uuid");
},
/**
* 先去判断这个应用是被下载过
*/
isExistApk: function () {
cc.log("gameDetail->isExistApk start...");
if (!cc.sys.isNative) {
return;
}
if (this._oSceneContext._downloadUrl && this._oSceneContext._downloadUrl != "undefined") { //如果有下载地址就判断奥比游戏
jsb.reflection.callStaticMethod("com/topdraw/melody/TopdrawSDKWrapper", "isExistObiApk", "(Ljava/lang/String;Ljava/lang/String;)V", this._oSceneContext._packageName, "callBackExistApk");
} else {
jsb.reflection.callStaticMethod("com/topdraw/melody/TopdrawSDKWrapper", "isExistApk", "(Ljava/lang/String;Ljava/lang/String;)V", this._oSceneContext._packageName, "callBackExistApk");
}
},
callBackExistApk: function (flag) {
cc.log("callBackExistApk->flag..." + flag);
this._bInitExistApk = true;
this._bIsExistApk = flag;
},
//校验收藏
getAndCheckCollect: function () {
var oCheckParams = {
'view': 'json',
'token': Common.TEST_API_TOKEN_EDU,
// 'appId': this._strAppId
};
Network.ajax("GET", Common.TOPDRAW_API_SERVER_EDU + "User/GetDefaultCollection", null, oCheckParams,
function (strResponse) {
try {
var oJSONResult = JSON.parse(strResponse);
if (oJSONResult.businessCode == 'success') {
this._iFavId = oJSONResult.resultSet[0].id;
this.checkFav();
cc.log("Business Success:Get CheckCollect...");
} else {
cc.log("Business Error:Get CheckCollect..." + oJSONResult.description);
}
} catch (error) {
cc.log("Business Exception:Get CheckCollect..." + error);
}
},
function (strResponse) {
cc.log("Business Error:Get CheckCollect..." + strResponse);
}, this, "uuid");
},
//校验收藏
checkFav: function () {
var oCheckParams = {
'view': 'json',
'token': Common.TEST_API_TOKEN,
'appId': this._strAppId,
'collectionId': this._iFavId,
'mediaIds': this._iMediaId,
'start': 0,
'limit': 1,
};
Network.ajax("GET", Common.TOPDRAW_API_SERVER + "User/ListMediaByCollection", null, oCheckParams,
function (strResponse) {
try {
var oJSONResult = JSON.parse(strResponse);
var self = this;
if (oJSONResult.businessCode == 'success') {
if (1 == oJSONResult.resultSet.length) { //已收藏
this._bCollected = true;
cc.loader.loadRes('button/be_collected', cc.Texture2D, function (err, texture) {
self.spriteCollect.spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 114, 106));
});
} else { //未收藏
this._bCollected = false;
cc.loader.loadRes('button/not_collected', cc.Texture2D, function (err, texture) {
self.spriteCollect.spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 114, 106));
});
}
cc.log("Business Success:Get CheckCollect...");
} else {
cc.log("Business Error:Get CheckCollect..." + oJSONResult.description);
}
} catch (error) {
cc.log("Business Exception:Get CheckCollect..." + error);
}
},
function (strResponse) {
cc.log("Business Error:Get CheckCollect..." + strResponse);
}, this, "uuid");
},
//获取节目详情
checkPfbReadyAndInitPage: function () {
var self = this;
this._oInit.aListImage = [];
//根据Id获取详情
// let oGatherDetailRequestParameter = {
// "view": "json",
// "ids": this._iMediaId,
// "start": 0,
// "limit": 1,
// // "appId": this._strAppId,
// "token": Common.TEST_API_TOKEN_EDU
// };
Network.ajax("GET", Common.TOPDRAW_API_SERVER + "gameDetail/" + this._oSceneContext._packageName + ".json", null, null,
function (strResponse) {
try {
var oJSONResult = JSON.parse(strResponse);
// var oJSONResult = this.test_detail_json.json;
if (oJSONResult.businessCode == 'success') {
cc.find("Desc/Title", this.node).getComponent(cc.Label).string = oJSONResult.resultSet[0].name;//标题
cc.find("Desc/Title", this.node).getComponent(cc.Label)._forceUpdateRenderData();
cc.find("Desc/LabelVersion", this.node).getComponent(cc.Label).string = oJSONResult.resultSet[0].versions;
cc.find("Desc/LabelSize", this.node).getComponent(cc.Label).string = oJSONResult.resultSet[0].size;
cc.find("Desc/LabelTime", this.node).getComponent(cc.Label).string = oJSONResult.resultSet[0].updateTime;
//==========放到大屏显示问题
cc.find("FullDesc/Title", this.node).getComponent(cc.Label).string = oJSONResult.resultSet[0].name;
cc.find("FullDesc/Desc", this.node).getComponent(cc.Label).string = oJSONResult.resultSet[0].description;
//==========end
//这里给描述做拦截,防止字数多超出栏目
var description = oJSONResult.resultSet[0].description;
if (description.length > 80) {
description = description.substring(0, 80) + "...";
}
cc.find("Desc/LabelDesc", this.node).getComponent(cc.Label).string = description;
//搞标签
let iTitleWidth = cc.find("Desc/Title", this.node).width;
let aTag = oJSONResult.resultSet[0].tag.split(")");
// cc.log("tag数量:" + aTag.length);
for (let i = 0; i < aTag.length; i++) {
if (!aTag[i]) continue;
let nodeShadow = cc.find("Desc/Title/Shadow" + i, this.node);
nodeShadow.active = true;
nodeShadow.getChildByName("Label").getComponent(cc.Label).string = aTag[i];
// cc.log("字体宽度:" + (856 + iTitleWidth + 16 + i * 108));
nodeShadow.getComponent(cc.Widget).left = 652 + iTitleWidth + 16 + i * 108;
}
this._strEpisodeImg = oJSONResult.resultSet[0].images.list[0].fileUrl;
// cc.loader.loadRes(this._strEpisodeImg, cc.Texture2D, function (err, texture) {
// self.node.getChildByName("Pic").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
// });
this._oInit.aListImage = oJSONResult.resultSet[0].images.list;
cc.log("图片地址:" + (Common.TOPDRAW_IMAGE_SERVER + oJSONResult.resultSet[0].images.list[0].fileUrl));
Network.loadImageInNativeRuntime(
Common.TOPDRAW_IMAGE_SERVER + oJSONResult.resultSet[0].images.list[0].fileUrl, null,
function (texture, iRequestId) {
self.node.getChildByName("Pic").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}, function () { }, this
);
//全屏展示图片
// cc.loader.loadRes(this._strEpisodeImg, cc.Texture2D, function (err, texture) {
// self.node.getChildByName("FullView").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
// });
this.getTypeList();
} else {
cc.log("Business Error:Get checkPfbReadyAndInitPage..." + oJSONResult.description);
}
} catch (error) {
cc.log("Business Exception:Get checkPfbReadyAndInitPage..." + error);
}
},
function (error) {
cc.log("Business Exception:Get checkPfbReadyAndInitPage..." + error);
}, this, "uuid");
},
checkDataReadyAndInitFocus: function () {
if (!this._bIsFocusInit) {
this.scheduleOnce(() => { //指定0让回调函数在下一帧立即执行
this.initFocus();
}, 0);
this._bIsFocusInit = true;
}
},
//初始化焦点框
initFocus: function () {
this._aFocusTargets[1] = [];
let fiPic = cc.find('Pic', this.node).addComponent(FocusInfo); //
if (this._oSceneContext._downloadUrl && this._oSceneContext._downloadUrl != "undefined") {
fiPic.init("{\"click\":[{\"action\":\"ChangeScene\",\"parameters\":{\"sceneName\":\"sceneGameLoading\",\"packageName\":\"" + this._oSceneContext._packageName + "\",\"className\":\"" + this._oSceneContext._className + "\",\"downloadUrl\":\"" + Common.TOPDRAW_API_SERVER + this._oSceneContext._downloadUrl + "\"}}]}", true, null, null, 1.0);
} else {
fiPic.init("{\"click\":[{\"action\":\"ChangeScene\",\"parameters\":{\"sceneName\":\"sceneGameLoading\",\"packageName\":\"" + this._oSceneContext._packageName + "\",\"className\":\"" + this._oSceneContext._className + "\",\"downloadUrl\":\"" + this._oSceneContext._downloadUrl + "\"}}]}", true, null, null, 1.0);
}
this._aFocusTargets[0]['pic'] = cc.find('Pic', this.node);
let fiDesc = cc.find('Desc/LabelDesc', this.node).addComponent(FocusInfo); //
fiDesc.init('', true, null, null, 1.0);
this._aFocusTargets[0]['desc'] = cc.find('Desc/LabelDesc', this.node);
let fiOpen = cc.find('ButtonOpen', this.node).addComponent(FocusInfo); //
if (this._oSceneContext._downloadUrl && this._oSceneContext._downloadUrl != "undefined") {
fiOpen.init("{\"click\":[{\"action\":\"ChangeScene\",\"parameters\":{\"sceneName\":\"sceneGameLoading\",\"packageName\":\"" + this._oSceneContext._packageName + "\",\"className\":\"" + this._oSceneContext._className + "\",\"downloadUrl\":\"" + Common.TOPDRAW_API_SERVER + this._oSceneContext._downloadUrl + "\"}}]}", true, null, null, 1.06);
} else {
fiOpen.init("{\"click\":[{\"action\":\"ChangeScene\",\"parameters\":{\"sceneName\":\"sceneGameLoading\",\"packageName\":\"" + this._oSceneContext._packageName + "\",\"className\":\"" + this._oSceneContext._className + "\",\"downloadUrl\":\"" + this._oSceneContext._downloadUrl + "\"}}]}", true, null, null, 1.06);
}
this._aFocusTargets[0]['ButtonOpen'] = cc.find('ButtonOpen', this.node);
// let fiBanner = cc.find('ButtonVip', this.node).addComponent(FocusInfo); //
// fiBanner.init('', true, null, null, 1.06);
// this._aFocusTargets[0]['button_vip'] = cc.find('ButtonVip', this.node);
var nodeInitFocus = cc.find('ButtonOpen', this.node); //强制写死,不然会闪屏,找不到ButtonOpen
// cc.log("初始化 " + nodeInitFocus.name);
var nodeFocus = new cc.Node('nodeFocus');
this.node.addChild(nodeFocus, 10);
this._cFocus = this.node.getChildByName('nodeFocus').addComponent(CCTVFocus);
this._cFocus.init('focusContainer', this,
nodeInitFocus.getComponent(FocusInfo),
Common.SCREEN_WIDTH, Common.SCREEN_HEIGHT, 10, 6, 1.1, true);
if (0 == nodeInitFocus.name.indexOf('Button')) {
this._cFocus.hide();
cc.loader.loadRes("GameDetail/icon_button_open", cc.Texture2D, function (err, texture) {
nodeInitFocus.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 100, 264, 100));
});
}
},
keyDownDirection: function (Direct) {
var fiFocusTarget = null;
var fiCurrentFocus = this._fiCurrentFocus;
var oScrollParameter = null;
let aCheckResult;
fiFocusTarget = this._cFocus.findTarget(fiCurrentFocus, this._aFocusTargets, this._iSceneStatus, Direct);
if (!fiFocusTarget) { return; }
0 == fiFocusTarget.node.name.indexOf('Button') ? this._cFocus.hide() : this._cFocus.show();
aCheckResult = this.checkFocusTarget(fiFocusTarget, oScrollParameter);
fiFocusTarget = aCheckResult[0];
oScrollParameter = aCheckResult[1];
this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Direct, null, oScrollParameter);
},
checkFocusTarget: function (fiFocusTarget, oScrollParameter) {
if (fiFocusTarget && 0 == fiFocusTarget.node.name.indexOf("TypeListCell")) {
if (fiFocusTarget.node.x + this._nodeTypeList.x >= this._nodeTypeListWrapper.width) {
oScrollParameter = this._nodeTypeList.getComponent(TVScrollParameter);
oScrollParameter.setHasRelation(true);
oScrollParameter.setStep((fiFocusTarget.node.x + fiFocusTarget.node.width / 2 + this._nodeTypeList.x) - this._nodeTypeListWrapper.width + 50);//打补丁:20,解决放大时Rect遮挡问题
oScrollParameter.setTargetPosition(this._nodeTypeList.x - oScrollParameter.getStep());
this._oSceneContext.nodeTypeListX = this._nodeTypeList.x - oScrollParameter.getStep();
}
if (fiFocusTarget.node.x + this._nodeTypeList.x < 0) {
oScrollParameter = this._nodeTypeList.getComponent(TVScrollParameter);
oScrollParameter.setHasRelation(true);
oScrollParameter.setStep(-fiFocusTarget.node.x + fiFocusTarget.node.width / 2 - this._nodeTypeList.x + 20);//打补丁:20,解决放大时Rect遮挡问题
oScrollParameter.setTargetPosition(this._nodeTypeList.x + oScrollParameter.getStep());
this._oSceneContext.nodeTypeListX = this._nodeTypeList.x + oScrollParameter.getStep();
}
}
return [fiFocusTarget, oScrollParameter];
},
onKeyDown: function (event) {
this._super(event);
var self = this;
var fiFocusTarget = null;
var fiCurrentFocus = this._fiCurrentFocus;
cc.find("FullView", this.node).active = false;
cc.find("FullDesc", this.node).active = false;
switch (event.keyCode) {
case cc.macro.KEY.up:
case Common.ANDROID_KEY.up:
this.keyDownDirection(Common.MOVE_DIRECTION_UP);
break;
case cc.macro.KEY.right:
case Common.ANDROID_KEY.right:
this.keyDownDirection(Common.MOVE_DIRECTION_RIGHT);
break;
case cc.macro.KEY.down:
case Common.ANDROID_KEY.down:
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:
if (0 == this._fiCurrentFocus.node.name.indexOf('Collect')) {
this._bCollected = !this._bCollected;
if (this._bCollected) {
this.commonSimpleTip("恭喜您!收藏成功!", 3);
}
let icon = this._bCollected ? "GameDetail/be_collected" : "GameDetail/not_collected";
cc.loader.loadRes(icon, cc.Texture2D, function (err, texture) {
self._fiCurrentFocus.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 56, self._fiCurrentFocus.node.width, 56));
});
} else if (0 == this._fiCurrentFocus.node.name.indexOf('TypeListCell')) {
cc.find("FullView", this.node).active = true;
} else if (0 == this._fiCurrentFocus.node.name.indexOf('LabelDesc')) {
cc.find("FullDesc", this.node).active = true;
} else if (0 == this._fiCurrentFocus.node.name.indexOf('ButtonOpen') || 0 == this._fiCurrentFocus.node.name.indexOf('Pic')) {
// this.commonSimpleTip("是否拿到数据: " + this._bInitExistApk);
if (!this._bInitExistApk) { //还未拿到判断数据
return;
}
if (this._bIsExistApk == "true") {
if (this._oSceneContext._downloadUrl && this._oSceneContext._downloadUrl != "undefined") { //如果有下载地址就启动奥比游戏
jsb.reflection.callStaticMethod("com/topdraw/melody/TopdrawSDKWrapper", "startOBiGame", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", Common.TOPDRAW_API_SERVER + this._oSceneContext._downloadUrl, this._oSceneContext._packageName, this._oSceneContext._className, "");
} else {
//这里应该转圈圈等待加载游戏
// cc.find("LoadingLabel", this.node).opacity = 255;
// cc.find("Loading/LoadingIcon", this.node).opacity = 255;
// cc.find("Loading/LoadingIcon", this.node).getComponent(cc.Animation).play();
jsb.reflection.callStaticMethod("com/topdraw/melody/TopdrawSDKWrapper", "startGame", "(Ljava/lang/String;Ljava/lang/String;)V", this._oSceneContext._packageName, "");
}
} else {
this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
}
return;
} else {
this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
}
break;
case cc.macro.KEY.backspace:
case Common.ANDROID_KEY.back:
this.backAScene();
break;
}
},
hideLoadingIcon: function () {
cc.log("隐藏LoadingIcon...");
cc.find("LoadingLabel", this.node).opacity = 0;
cc.find("Loading/LoadingIcon", this.node).opacity = 0;
cc.find("Loading/LoadingIcon", this.node).getComponent(cc.Animation).pause();
},
doCurrentFocusTVLinkAction: function (strAction) {
let strTVLink = this._fiCurrentFocus.getTVLink();
cc.log("tvlink===============" + strTVLink);
try {
let oTVLink = JSON.parse(strTVLink);
let aOperationList = oTVLink.click;
for (let i = 0; i < aOperationList.length; i++) {
switch (aOperationList[i].action) {
case "changeLayout":
default:
this.doTVLinkAction(aOperationList[i]);
break;
}
}
} catch (error) {
cc.log("runTVLinkAction Exception..." + error);
}
},
onBeforeFocusChange: function (event) {
let fiFrom = event.detail.from;
let fiTo = event.detail.to;
if (0 == fiFrom.node.getName().indexOf('ButtonOpen')) {
cc.loader.loadRes("GameDetail/icon_button_open", cc.Texture2D, function (err, texture) {
fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 264, 100));
});
}
if (0 == fiFrom.node.getName().indexOf('ButtonVip')) {
cc.loader.loadRes("GameDetail/icon_banner", cc.Texture2D, function (err, texture) {
fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 572, 72));
});
}
// if (0 == this._fiCurrentFocus.node.getName().indexOf('Collect')) {
// // fiFrom.node.getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, fiFrom.node.width, 106));
// let icon = this._bCollected ? "GameDetail/be_collected" : "GameDetail/not_collected";
// cc.loader.loadRes(icon, cc.Texture2D, function (err, texture) {
// fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, fiFrom.node.width, 56));
// });
// }
},
onAfterFocusChange: function (event) {
var self = this;
let fiTo = event.detail.to;
let fiFrom = event.detail.from;
// if (0 == fiTo.node.getName().indexOf('Collect')) {
// // fiTo.node.getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 106, fiTo.node.width, 106));
// let icon = this._bCollected ? "GameDetail/be_collected" : "GameDetail/not_collected";
// cc.loader.loadRes(icon, cc.Texture2D, function (err, texture) {
// fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 56, fiTo.node.width, 56));
// });
// }
if (0 == fiTo.node.getName().indexOf('ButtonOpen')) {
// fiTo.node.getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, fiTo.node.height, fiTo.node.width, fiTo.node.height));
cc.loader.loadRes("GameDetail/icon_button_open", cc.Texture2D, function (err, texture) {
fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 100, 264, 100));
});
}
if (0 == fiTo.node.getName().indexOf('ButtonVip')) {
// fiTo.node.getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, fiTo.node.height, fiTo.node.width, fiTo.node.height));
cc.loader.loadRes("GameDetail/icon_banner", cc.Texture2D, function (err, texture) {
fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 72, 572, 72));
});
}
if (0 == fiTo.node.getName().indexOf('TypeListCell')) {
let iIndex = fiTo.node.name.replace("TypeListCell", '');
if (this._oInit.aListImage[iIndex]) {
Network.loadImageInNativeRuntime(Common.TOPDRAW_IMAGE_SERVER + this._oInit.aListImage[iIndex].fileUrl, null,
function (texture) {
cc.find("FullView", self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}, function () { }, this
);
}
}
},
});