1.视频详情页开发完成
Showing
2 changed files
with
26 additions
and
58 deletions
This diff is collapsed.
Click to expand it.
... | @@ -15,6 +15,7 @@ cc.Class({ | ... | @@ -15,6 +15,7 @@ cc.Class({ |
15 | 15 | ||
16 | properties: { | 16 | properties: { |
17 | _iCurrentNaviNumLoc: 1, | 17 | _iCurrentNaviNumLoc: 1, |
18 | _bIsNaviDataInit: false, //是否初始化Navi | ||
18 | PFB_NAVI: { | 19 | PFB_NAVI: { |
19 | default: null, | 20 | default: null, |
20 | type: cc.Prefab, | 21 | type: cc.Prefab, |
... | @@ -65,6 +66,7 @@ cc.Class({ | ... | @@ -65,6 +66,7 @@ cc.Class({ |
65 | //剧集分类 | 66 | //剧集分类 |
66 | this._nodeEpisodeListWrapper = cc.find("EpisodeArea/EpisodeListWrapper", this.node); | 67 | this._nodeEpisodeListWrapper = cc.find("EpisodeArea/EpisodeListWrapper", this.node); |
67 | this._nodeEpisodeList = cc.find("EpisodeList", this._nodeEpisodeListWrapper); | 68 | this._nodeEpisodeList = cc.find("EpisodeList", this._nodeEpisodeListWrapper); |
69 | this._nodeEpisodeList.addComponent(TVScrollParameter); | ||
68 | 70 | ||
69 | // this.initPrefab(); | 71 | // this.initPrefab(); |
70 | this.checkPfbReadyAndInitPage(); | 72 | this.checkPfbReadyAndInitPage(); |
... | @@ -95,10 +97,14 @@ cc.Class({ | ... | @@ -95,10 +97,14 @@ cc.Class({ |
95 | var oJSONResult = JSON.parse(strResponse); | 97 | var oJSONResult = JSON.parse(strResponse); |
96 | this._oEpisode = oJSONResult; | 98 | this._oEpisode = oJSONResult; |
97 | if (oJSONResult.businessCode == 'success') { | 99 | if (oJSONResult.businessCode == 'success') { |
98 | for (let i = 0; i < 4; i++) { | 100 | for (let i = 0; i < 20; i++) { |
99 | let nodeEpisodeListCell = cc.instantiate(this.PFB_EPISODE); | 101 | if (i >= oJSONResult.resultSet.length) {//数据较少时 |
102 | continue; | ||
103 | } | ||
104 | let nodeEpisodeCell = cc.instantiate(this.PFB_EPISODE); | ||
100 | nodeEpisodeCell.x = nodeEpisodeCell.width / 2 + (i) * (nodeEpisodeCell.width + 20); | 105 | nodeEpisodeCell.x = nodeEpisodeCell.width / 2 + (i) * (nodeEpisodeCell.width + 20); |
101 | cc.find("EpisodeNum/Text", nodeEpisodeListCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name; | 106 | cc.find("EpisodeNum/Text", nodeEpisodeCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name; |
107 | this._nodeEpisodeList.addChild(nodeEpisodeCell, 10, "EpisodeListCell" + i); | ||
102 | 108 | ||
103 | let fiEpisodeBlock = nodeEpisodeCell.addComponent(FocusInfo); | 109 | let fiEpisodeBlock = nodeEpisodeCell.addComponent(FocusInfo); |
104 | fiEpisodeBlock.init('', true, null, null, 1.0); | 110 | fiEpisodeBlock.init('', true, null, null, 1.0); |
... | @@ -301,6 +307,23 @@ cc.Class({ | ... | @@ -301,6 +307,23 @@ cc.Class({ |
301 | } | 307 | } |
302 | } | 308 | } |
303 | 309 | ||
310 | if (fiFocusTarget && 0 == fiFocusTarget.node.name.indexOf("EpisodeListCell")) { | ||
311 | if (fiFocusTarget.node.x - fiFocusTarget.node.width / 2 + this._nodeEpisodeList.x >= this._nodeEpisodeListWrapper.width) { | ||
312 | oScrollParameter = this._nodeEpisodeList.getComponent(TVScrollParameter); | ||
313 | oScrollParameter.setHasRelation(true); | ||
314 | oScrollParameter.setStep((fiFocusTarget.node.x + fiFocusTarget.node.width / 2 + this._nodeEpisodeList.x) - this._nodeEpisodeListWrapper.width+20); | ||
315 | oScrollParameter.setTargetPosition(this._nodeEpisodeList.x - oScrollParameter.getStep()); | ||
316 | // this._oSceneContext._nodeNaviListX = this._nodeEpisodeList.x - oScrollParameter.getStep(); | ||
317 | } | ||
318 | if (fiFocusTarget.node.x + this._nodeEpisodeList.x < 0) { | ||
319 | oScrollParameter = this._nodeEpisodeList.getComponent(TVScrollParameter); | ||
320 | oScrollParameter.setHasRelation(true); | ||
321 | oScrollParameter.setStep(-fiFocusTarget.node.x + fiFocusTarget.node.width / 2 - this._nodeEpisodeList.x+16); | ||
322 | oScrollParameter.setTargetPosition(this._nodeEpisodeList.x + oScrollParameter.getStep()) | ||
323 | // this._oSceneContext._nodeNaviListX = this._nodeEpisodeList.x + oScrollParameter.getStep(); | ||
324 | } | ||
325 | } | ||
326 | |||
304 | return [fiFocusTarget, oScrollParameter]; | 327 | return [fiFocusTarget, oScrollParameter]; |
305 | }, | 328 | }, |
306 | 329 | ||
... | @@ -317,11 +340,6 @@ cc.Class({ | ... | @@ -317,11 +340,6 @@ cc.Class({ |
317 | break; | 340 | break; |
318 | case cc.macro.KEY.right: | 341 | case cc.macro.KEY.right: |
319 | case Common.ANDROID_KEY.right: | 342 | case Common.ANDROID_KEY.right: |
320 | let index = this._fiCurrentFocus.node.name.replace('EpisodeListCell', ''); | ||
321 | if (0 == this._fiCurrentFocus.node.name.indexOf('EpisodeListCell') && index == 3 && this._oSceneContext.currentPage * 4 < this._oEpisode.resultSet.length) { | ||
322 | this._oSceneContext.currentPage++; | ||
323 | this.moveEpisode(); | ||
324 | } | ||
325 | this.keyDownDirection(Common.MOVE_DIRECTION_RIGHT); | 343 | this.keyDownDirection(Common.MOVE_DIRECTION_RIGHT); |
326 | break; | 344 | break; |
327 | case cc.macro.KEY.down: | 345 | case cc.macro.KEY.down: |
... | @@ -330,11 +348,6 @@ cc.Class({ | ... | @@ -330,11 +348,6 @@ cc.Class({ |
330 | break; | 348 | break; |
331 | case cc.macro.KEY.left: | 349 | case cc.macro.KEY.left: |
332 | case Common.ANDROID_KEY.left: | 350 | case Common.ANDROID_KEY.left: |
333 | let index2 = this._fiCurrentFocus.node.name.replace('EpisodeListCell', ''); | ||
334 | if (0 == this._fiCurrentFocus.node.name.indexOf('EpisodeListCell') && index2 == 0 && this._oSceneContext.currentPage > 1) { | ||
335 | this._oSceneContext.currentPage--; | ||
336 | this.moveEpisode(); | ||
337 | } | ||
338 | this.keyDownDirection(Common.MOVE_DIRECTION_LEFT); | 351 | this.keyDownDirection(Common.MOVE_DIRECTION_LEFT); |
339 | break; | 352 | break; |
340 | case cc.macro.KEY.enter: | 353 | case cc.macro.KEY.enter: |
... | @@ -381,51 +394,6 @@ cc.Class({ | ... | @@ -381,51 +394,6 @@ cc.Class({ |
381 | } | 394 | } |
382 | }, | 395 | }, |
383 | 396 | ||
384 | //移动剧集 | ||
385 | moveEpisode: function () { | ||
386 | let index = (this._oSceneContext.currentPage - 1) * 4; | ||
387 | for (let i = index; i < index + 4; i++) { | ||
388 | let nodeEpisodeListCell = this._nodeEpisodeList.getChildByName("EpisodeListCell" + i % 4); | ||
389 | // if (i >= this._oEpisode.resultSet.length) {//数据较少时隐藏其他多余预制体 | ||
390 | // nodeEpisodeListCell.active = false; // | ||
391 | // continue; | ||
392 | // } | ||
393 | nodeEpisodeListCell.active = true; //恢复预制可见及可点击 | ||
394 | if (this._oEpisode.resultSet[i]) { | ||
395 | cc.find("EpisodeNum/Text", nodeEpisodeListCell).getComponent(cc.Label).string = this._oEpisode.resultSet[i].name; | ||
396 | if (this._strEpisodeImg) { | ||
397 | Network.loadImageInNativeRuntime( | ||
398 | Common.TOPDRAW_IMAGE_SERVER + this._strEpisodeImg, | ||
399 | function (texture) { | ||
400 | nodeEpisodeListCell.getChildByName("Bg").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture); | ||
401 | }, null, this | ||
402 | ); | ||
403 | } | ||
404 | } else { | ||
405 | nodeEpisodeListCell.active = false; | ||
406 | } | ||
407 | this._cFocus.hide(); | ||
408 | this.scheduleOnce(() => { //指定0让回调函数在下一帧立即执行 | ||
409 | this._cFocus.flyFocus(this._fiCurrentFocus, this._nodeEpisodeList.getChildByName("EpisodeListCell0").getComponent(FocusInfo), Common.MOVE_DIRECTION_LEFT, 1.0, null); | ||
410 | }, 0); | ||
411 | setTimeout(function () { //在隐藏1.2秒焦点, | ||
412 | this._cFocus.show(); | ||
413 | }.bind(this), 400); | ||
414 | |||
415 | // cc.find("TopArea/Name/NormalName/MidName", nodeGatherDetailListCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name; | ||
416 | // cc.find("TopArea/Name/ActiveName/NameContainer/NameText/NameText1", nodeGatherDetailListCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name; | ||
417 | // cc.find("TopArea/Name/ActiveName/NameContainer/NameText/NameText2", nodeGatherDetailListCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name; | ||
418 | // cc.find("TopArea/Name/ActiveName/NameContainer/NameText/NameText1", nodeGatherDetailListCell).getComponent(cc.Label)._updateRenderData(true); | ||
419 | // cc.find("TopArea/Name/ActiveName/NameContainer/NameText/NameText2", nodeGatherDetailListCell).getComponent(cc.Label)._updateRenderData(true); | ||
420 | // let fiBlock = nodeEpisodeListCell.getComponent(FocusInfo); | ||
421 | // fiBlock.setTVLink( | ||
422 | // '{"click":[{"action":"ChangeScene","parameters":{"sceneName":"scenePlayerFullScreen",\ | ||
423 | // "appId":"' + this._strAppId + '","id":"' + this._iMediaId + '","episodeNum":"'+oJSONResult.resultSet[i].index+'",\ | ||
424 | // "mediaCode":"'+oJSONResult.resultSet[i].code+'","name":"'+oJSONResult.resultSet[i].name+'"}}]}' | ||
425 | // ); | ||
426 | } | ||
427 | }, | ||
428 | |||
429 | doCurrentFocusTVLinkAction: function (strAction) { | 397 | doCurrentFocusTVLinkAction: function (strAction) { |
430 | let strTVLink = this._fiCurrentFocus.getTVLink(); | 398 | let strTVLink = this._fiCurrentFocus.getTVLink(); |
431 | cc.log("tvlink===============" + strTVLink); | 399 | cc.log("tvlink===============" + strTVLink); | ... | ... |
-
Please register or sign in to post a comment