DiaryListCell.js
4.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
var Common = require('Common');
var FocusInfo = require('FocusInfo');
var ListCell = require('ListCell');
var Network = require('Network');
cc.Class({
extends: ListCell,
properties: {
id: 0,
pic: cc.Sprite,
activeName1: cc.Label,
activeName2: cc.Label,
normalName: cc.Label,
textPlayTimes: cc.Label, //观看次数
textScore: cc.Label, //分数
deleteButtonImg: cc.Sprite, //删除图标
},
statics: {
PFB_NAME: 'prefab/pfbDiaryListCell',
CELL_NAME: 'DiaryListCell',
},
init: function (iCellIndex, bIsFocusEnable, compSceneCanvas) {
//准备焦点坐标
let fiCategoryBlock = this.node.addComponent(FocusInfo);
fiCategoryBlock.init(
null, false, null, null, 1.15
);
compSceneCanvas.addNodeToFocusTarget(0, this.node.name, this.node);
},
render(oData, iRecordIndex) {
this.id = oData.id;
this.activeName1.string = oData.name;
this.activeName2.string = oData.name;
this.normalName.string = oData.name;
this.activeName1._updateRenderData(true);
this.activeName2._updateRenderData(true);
this.normalName._updateRenderData(true);
if (oData.score) {
this.textScore.string = parseInt(oData.score * 10) / 10 + "分";
}
if (oData.play_times) {
let value = parseInt(oData.play_times);
if (value > 10000) {
this.textPlayTimes.string = parseInt(value / 10000) + "万+";
} else {
this.textPlayTimes.string = value;
}
}
// this.deleteButtonImg.spriteFrame.setRect(cc.rect(0, 0, 122, 122));
if (oData.image[0]) {
var self = this;
Network.loadImageInNativeRuntime(
Common.TOPDRAW_IMAGE_SERVER_EDU_RIGHT + oData.image[0].fileUrl,
function (texture) {
self.pic.spriteFrame = new cc.SpriteFrame(texture);
}, null, this
);
}
},
enableFocusInfo: function () {
this.node.getComponent(FocusInfo).setEnable(true);
},
disableFocusInfo: function () {
this.node.getComponent(FocusInfo).setEnable(false);
},
setUIWithFocus: function () {
let nodeCellName = this.node.getChildByName('Name');
cc.find("NormalName", nodeCellName).opacity = 255;
cc.find("ActiveName/ActiveNameBg", nodeCellName).opacity = 255;
//超出滚动
let nodeScreenTitleText = cc.find('ActiveName/NameContainer/NameText', nodeCellName);
let fOriginalX = nodeScreenTitleText.x;
let fOriginalY = nodeScreenTitleText.y;
let nodeScreenTitleText1 = nodeScreenTitleText.getChildByName('NameText1');
let nodeScreenTitleText2 = nodeScreenTitleText.getChildByName('NameText2');
nodeScreenTitleText2.x = nodeScreenTitleText1.x + nodeScreenTitleText1.width + 10;//TODO:补丁,解决滚动重叠
if (nodeScreenTitleText1.width > nodeScreenTitleText.width) {
cc.find("ActiveName/NameContainer", nodeCellName).opacity = 255;
cc.find("NormalName", nodeCellName).opacity = 0;
let fEndPositionDelta = (nodeScreenTitleText1.width + 30);
//下方时长和字有关系,才能速度一样
var ftaScreenTitleMoveToTarget = cc.moveTo(10 * (nodeScreenTitleText1.width / nodeScreenTitleText.width), fOriginalX - fEndPositionDelta, fOriginalY);
var ftaScreenTitleMoveToBack = cc.moveTo(0, fOriginalX, fOriginalY);
var sequenceMediaTitle = cc.sequence(ftaScreenTitleMoveToTarget, ftaScreenTitleMoveToBack);
var repeatScreenTitle = cc.repeat(sequenceMediaTitle, 10);
repeatScreenTitle.setTag(Common.OVERLENGTH_MOVING);
nodeScreenTitleText.runAction(repeatScreenTitle);
nodeScreenTitleText2.active = true;
}
},
setUIWithoutFocus: function () {
let nodeCellName = this.node.getChildByName('Name');
cc.find("NormalName", nodeCellName).opacity = 255;
cc.find("ActiveName/ActiveNameBg", nodeCellName).opacity = 0;
//如有滚动停止滚动
let nodeScreenTitleText = cc.find('ActiveName/NameContainer/NameText', nodeCellName);
if (null != nodeScreenTitleText.getActionByTag(Common.OVERLENGTH_MOVING)) {
nodeScreenTitleText.stopActionByTag(Common.OVERLENGTH_MOVING);
nodeScreenTitleText.getChildByName('NameText2').active = false;
cc.find("ActiveName/NameContainer", nodeCellName).opacity = 0;
}
nodeScreenTitleText.x = 0;
},
});