Commit 21afd251 21afd2514c36084625911424680279ae53fd344b by 金学艇

1.新增历史和收藏界面

1 parent 31fc8e35
......@@ -469,7 +469,8 @@ cc.Class({
doCurrentFocusTVLinkAction: function (strAction) {
let strTVLink = this._fiCurrentFocus.getTVLink();
cc.log("tvlink===============" + strTVLink);
let cellData = JSON.stringify(this._fiCurrentFocus.node.getComponent(ListCell)._cellData);
// cc.log("tvlink===============" + JSON.stringify(this._fiCurrentFocus.node.getComponent(ListCell)._cellData));
try {
let oTVLink = JSON.parse(strTVLink);
let aOperationList = oTVLink.click;
......@@ -478,6 +479,7 @@ cc.Class({
switch (aOperationList[i].action) {
case "changeLayout":
default:
aOperationList[i]['parameters']["cellData"] = cellData;
this.doTVLinkAction(aOperationList[i]);
break;
}
......
......@@ -34,6 +34,7 @@ cc.Class({
this._oSceneContext._packageName = "";
this._oSceneContext._className = "";
this._oSceneContext._downloadUrl = "";
this._oSceneContext._cellData = "";
this._oSceneContext._iCurrentLeftIndex = 1;
this._oSceneContext.focusPath = "ButtonOpen";
......@@ -55,10 +56,12 @@ cc.Class({
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);
......@@ -84,6 +87,28 @@ cc.Class({
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 () {
......
......@@ -15,6 +15,7 @@ cc.Class({
normalName: cc.Label,
Name: cc.Label,
textScore: cc.Label, //分数
_cellData: null,
},
statics: {
......@@ -32,6 +33,7 @@ cc.Class({
},
render(oData, iRecordIndex) {
this._cellData = oData;
// this.id = oData.id;
// cc.log("categoryList-->name: "+JSON.stringify(oData));
this.activeName1.string = oData.name;
......@@ -65,7 +67,7 @@ cc.Class({
// cc.loader.loadRes(oData.image[0].fileUrl, cc.Texture2D, function (err, texture) {
// self.pic.spriteFrame = new cc.SpriteFrame(texture);
// });
cc.log("pfbCategoryListCell.."+self.pic);
cc.log("pfbCategoryListCell.." + self.pic);
if (self.pic) {
Network.loadImageInNativeRuntime(
Common.TOPDRAW_IMAGE_SERVER + oData.image[0].fileUrl, null,
......
cc.Class({
extends: cc.Component,
properties: {
},
start () {
},
});
......@@ -68,28 +68,10 @@ cc.Class({
this._nodeEpisodeList = cc.find("EpisodeList", this._nodeEpisodeListWrapper);
this._nodeEpisodeList.addComponent(TVScrollParameter);
// this.initPrefab();
this.checkPfbReadyAndInitPage();
this.checkDataReadyAndInitFocus();
},
// initPrefab: function () {
// for (let i = 0; i < 4; i++) {
// let nodeEpisodeCell = cc.instantiate(this.PFB_EPISODE);
// nodeEpisodeCell.x = nodeEpisodeCell.width / 2 + (i) * (nodeEpisodeCell.width + 20);
// this._nodeEpisodeList.addChild(nodeEpisodeCell, 10, "EpisodeListCell" + i);
// let fiEpisodeBlock = nodeEpisodeCell.addComponent(FocusInfo);
// fiEpisodeBlock.init('{"click": [{"action": "ChangeScene","parameters": {"sceneName":"sceneProgramPlayerFullScreen"}}]}'
// , true, null, null, 1.0);
// this._aFocusTargets[0]['episode_list_cell_' + i] = nodeEpisodeCell;
// // let borderX = nodeEpisodeCell.x - nodeEpisodeCell.width / 2; //搞边框
// // let borderY = nodeEpisodeCell.y - nodeEpisodeCell.height / 2;
// // this._graphicsLine.roundRect(borderX, borderY, 278, 175, 20);//圆角矩形路径
// // this._graphicsLine.stroke(); //绘制路径
// }
// },
getGatherDetailList: function () {
Network.ajax("GET", Common.TOPDRAW_API_SERVER + "videoDetail/movie_detail_list_by_media.json", null, null,
function (strResponse) {
......@@ -199,6 +181,7 @@ cc.Class({
// this.getTypeList();
this.checkCollect();
this.getGatherDetailList(); //获取剧集列表
this.getPlayURLAndPlay();
} else {
......@@ -213,6 +196,25 @@ cc.Class({
}, this, "uuid");
},
checkCollect: function () {
var collectList = JSON.parse(cc.sys.localStorage.getItem("collectList"));
if (collectList != null) {
if (-1 != JSON.stringify(collectList.resultSet).indexOf(this._strResponse)) {
this._bCollected = true;
// collectList.resultSet.push(JSON.parse(strResponse));
// collectList.count++;
// cc.sys.localStorage.setItem("collectList", JSON.stringify(collectList));
}
} else {
let oData = {};
oData.businessCode = "success";
oData.count = 0;
oData.resultSet = [];
// oData.resultSet.push(JSON.parse(strResponse));
cc.sys.localStorage.setItem("collectList", JSON.stringify(oData));
}
},
getPlayURLAndPlay: function () {
try {
this._ComOperation.initPlayer(64, 56, 564, 317, true, true); //这里采用左右边距对应android坐标 fix jerry
......@@ -358,15 +360,15 @@ cc.Class({
case cc.macro.KEY.enter:
case cc.macro.KEY.space:
case Common.ANDROID_KEY.enter:
if (0 == this._fiCurrentFocus.node.name.indexOf('Collect')) {
if (0 == this._fiCurrentFocus.node.name.indexOf('ButtonCollect')) {
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));
});
this.collectMovie();
return;
// 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('LabelDesc')) {
cc.find("FullDesc", this.node).active = true;
} else if (0 == this._fiCurrentFocus.node.name.indexOf('ButtonOpen') || 0 == this._fiCurrentFocus.node.name.indexOf('Pic')) {
......@@ -383,6 +385,29 @@ cc.Class({
}
},
collectMovie: function () {
var collectList = JSON.parse(cc.sys.localStorage.getItem("collectList"));
// cc.log("//////" + JSON.stringify(this._oInit));
if (this._bCollected && -1 == JSON.stringify(collectList.resultSet).indexOf(JSON.stringify(this._oInit))) {
this.commonSimpleTip("恭喜您!收藏成功!", 3);
collectList.resultSet.push(this._oInit);
collectList.count++;
cc.sys.localStorage.setItem("collectList", JSON.stringify(collectList));
} else if (-1 != (JSON.stringify(collectList.resultSet).indexOf(JSON.stringify(this._oInit)))) {
this.commonSimpleTip("取消收藏!", 3);
for (let i = 0; i < collectList.resultSet.length; i++) {
if (JSON.stringify(collectList.resultSet[i]) == JSON.stringify(this._oInit)) {
collectList.resultSet.splice(i, 1);
collectList.count <= 0 ? collectList.count = 0 : collectList.count--;
cc.sys.localStorage.setItem("collectList", JSON.stringify(collectList));
}
}
}
cc.log("检查存储:" + cc.sys.localStorage.getItem("collectList"));
},
doCurrentFocusTVLinkAction: function (strAction) {
let strTVLink = this._fiCurrentFocus.getTVLink();
cc.log("tvlink===============" + strTVLink);
......
......@@ -18,7 +18,17 @@
"height": 168
}
]
},
"image": [
{
"extension": ".png",
"size": 100405,
"enable": true,
"fileUrl": "upload/image/games/o宝脑力训练270-167.jpg",
"width": 270,
"height": 167
}
]
}
]
}
\ No newline at end of file
......
{
"//": "upload/image/category/",
"businessCode": "success",
"count": 7,
"currentTime": 1581664965116,
"description": "",
"resultSet": [
{
"name": "游戏历史",
"image": [
{
"extension": ".png",
"code": "image_e9fea105-0412-4600-a0f1-f606a003c63f",
"size": 74263,
"enable": true,
"name": "b2b1bb5f-a956-4930-9273-eb72920a9faa.png",
"fileUrl": "upload/image/historyAndCollect/icon_history.png",
"id": 7509,
"type": 2,
"width": 202,
"height": 94
}
]
},
{
"name": "我的收藏",
"image": [
{
"extension": ".png",
"code": "image_e9fea105-0412-4600-a0f1-f606a003c63f",
"size": 74263,
"enable": true,
"name": "b2b1bb5f-a956-4930-9273-eb72920a9faa.png",
"fileUrl": "upload/image/historyAndCollect/icon_collect.png",
"id": 7509,
"type": 2,
"width": 202,
"height": 94
}
]
}
]
}
\ No newline at end of file