Commit 9323a571 9323a57192e45438baff940c9e46a359c44045cd by 金学艇

1.视频详情页开发完成

1 parent db8a8b11
......@@ -15,6 +15,7 @@ cc.Class({
properties: {
_iCurrentNaviNumLoc: 1,
_bIsNaviDataInit: false, //是否初始化Navi
PFB_NAVI: {
default: null,
type: cc.Prefab,
......@@ -65,6 +66,7 @@ cc.Class({
//剧集分类
this._nodeEpisodeListWrapper = cc.find("EpisodeArea/EpisodeListWrapper", this.node);
this._nodeEpisodeList = cc.find("EpisodeList", this._nodeEpisodeListWrapper);
this._nodeEpisodeList.addComponent(TVScrollParameter);
// this.initPrefab();
this.checkPfbReadyAndInitPage();
......@@ -95,10 +97,14 @@ cc.Class({
var oJSONResult = JSON.parse(strResponse);
this._oEpisode = oJSONResult;
if (oJSONResult.businessCode == 'success') {
for (let i = 0; i < 4; i++) {
let nodeEpisodeListCell = cc.instantiate(this.PFB_EPISODE);
for (let i = 0; i < 20; i++) {
if (i >= oJSONResult.resultSet.length) {//数据较少时
continue;
}
let nodeEpisodeCell = cc.instantiate(this.PFB_EPISODE);
nodeEpisodeCell.x = nodeEpisodeCell.width / 2 + (i) * (nodeEpisodeCell.width + 20);
cc.find("EpisodeNum/Text", nodeEpisodeListCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name;
cc.find("EpisodeNum/Text", nodeEpisodeCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name;
this._nodeEpisodeList.addChild(nodeEpisodeCell, 10, "EpisodeListCell" + i);
let fiEpisodeBlock = nodeEpisodeCell.addComponent(FocusInfo);
fiEpisodeBlock.init('', true, null, null, 1.0);
......@@ -301,6 +307,23 @@ cc.Class({
}
}
if (fiFocusTarget && 0 == fiFocusTarget.node.name.indexOf("EpisodeListCell")) {
if (fiFocusTarget.node.x - fiFocusTarget.node.width / 2 + this._nodeEpisodeList.x >= this._nodeEpisodeListWrapper.width) {
oScrollParameter = this._nodeEpisodeList.getComponent(TVScrollParameter);
oScrollParameter.setHasRelation(true);
oScrollParameter.setStep((fiFocusTarget.node.x + fiFocusTarget.node.width / 2 + this._nodeEpisodeList.x) - this._nodeEpisodeListWrapper.width+20);
oScrollParameter.setTargetPosition(this._nodeEpisodeList.x - oScrollParameter.getStep());
// this._oSceneContext._nodeNaviListX = this._nodeEpisodeList.x - oScrollParameter.getStep();
}
if (fiFocusTarget.node.x + this._nodeEpisodeList.x < 0) {
oScrollParameter = this._nodeEpisodeList.getComponent(TVScrollParameter);
oScrollParameter.setHasRelation(true);
oScrollParameter.setStep(-fiFocusTarget.node.x + fiFocusTarget.node.width / 2 - this._nodeEpisodeList.x+16);
oScrollParameter.setTargetPosition(this._nodeEpisodeList.x + oScrollParameter.getStep())
// this._oSceneContext._nodeNaviListX = this._nodeEpisodeList.x + oScrollParameter.getStep();
}
}
return [fiFocusTarget, oScrollParameter];
},
......@@ -317,11 +340,6 @@ cc.Class({
break;
case cc.macro.KEY.right:
case Common.ANDROID_KEY.right:
let index = this._fiCurrentFocus.node.name.replace('EpisodeListCell', '');
if (0 == this._fiCurrentFocus.node.name.indexOf('EpisodeListCell') && index == 3 && this._oSceneContext.currentPage * 4 < this._oEpisode.resultSet.length) {
this._oSceneContext.currentPage++;
this.moveEpisode();
}
this.keyDownDirection(Common.MOVE_DIRECTION_RIGHT);
break;
case cc.macro.KEY.down:
......@@ -330,11 +348,6 @@ cc.Class({
break;
case cc.macro.KEY.left:
case Common.ANDROID_KEY.left:
let index2 = this._fiCurrentFocus.node.name.replace('EpisodeListCell', '');
if (0 == this._fiCurrentFocus.node.name.indexOf('EpisodeListCell') && index2 == 0 && this._oSceneContext.currentPage > 1) {
this._oSceneContext.currentPage--;
this.moveEpisode();
}
this.keyDownDirection(Common.MOVE_DIRECTION_LEFT);
break;
case cc.macro.KEY.enter:
......@@ -381,51 +394,6 @@ cc.Class({
}
},
//移动剧集
moveEpisode: function () {
let index = (this._oSceneContext.currentPage - 1) * 4;
for (let i = index; i < index + 4; i++) {
let nodeEpisodeListCell = this._nodeEpisodeList.getChildByName("EpisodeListCell" + i % 4);
// if (i >= this._oEpisode.resultSet.length) {//数据较少时隐藏其他多余预制体
// nodeEpisodeListCell.active = false; //
// continue;
// }
nodeEpisodeListCell.active = true; //恢复预制可见及可点击
if (this._oEpisode.resultSet[i]) {
cc.find("EpisodeNum/Text", nodeEpisodeListCell).getComponent(cc.Label).string = this._oEpisode.resultSet[i].name;
if (this._strEpisodeImg) {
Network.loadImageInNativeRuntime(
Common.TOPDRAW_IMAGE_SERVER + this._strEpisodeImg,
function (texture) {
nodeEpisodeListCell.getChildByName("Bg").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}, null, this
);
}
} else {
nodeEpisodeListCell.active = false;
}
this._cFocus.hide();
this.scheduleOnce(() => { //指定0让回调函数在下一帧立即执行
this._cFocus.flyFocus(this._fiCurrentFocus, this._nodeEpisodeList.getChildByName("EpisodeListCell0").getComponent(FocusInfo), Common.MOVE_DIRECTION_LEFT, 1.0, null);
}, 0);
setTimeout(function () { //在隐藏1.2秒焦点,
this._cFocus.show();
}.bind(this), 400);
// cc.find("TopArea/Name/NormalName/MidName", nodeGatherDetailListCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name;
// cc.find("TopArea/Name/ActiveName/NameContainer/NameText/NameText1", nodeGatherDetailListCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name;
// cc.find("TopArea/Name/ActiveName/NameContainer/NameText/NameText2", nodeGatherDetailListCell).getComponent(cc.Label).string = oJSONResult.resultSet[i].name;
// cc.find("TopArea/Name/ActiveName/NameContainer/NameText/NameText1", nodeGatherDetailListCell).getComponent(cc.Label)._updateRenderData(true);
// cc.find("TopArea/Name/ActiveName/NameContainer/NameText/NameText2", nodeGatherDetailListCell).getComponent(cc.Label)._updateRenderData(true);
// let fiBlock = nodeEpisodeListCell.getComponent(FocusInfo);
// fiBlock.setTVLink(
// '{"click":[{"action":"ChangeScene","parameters":{"sceneName":"scenePlayerFullScreen",\
// "appId":"' + this._strAppId + '","id":"' + this._iMediaId + '","episodeNum":"'+oJSONResult.resultSet[i].index+'",\
// "mediaCode":"'+oJSONResult.resultSet[i].code+'","name":"'+oJSONResult.resultSet[i].name+'"}}]}'
// );
}
},
doCurrentFocusTVLinkAction: function (strAction) {
let strTVLink = this._fiCurrentFocus.getTVLink();
cc.log("tvlink===============" + strTVLink);
......