PersonRoleInstallCategoryListCell.js
5.54 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
//明星列表ListCell
var Common = require('Common');
var FocusInfo = require('FocusInfo');
var ListView = require('ListView');
var ListCell = require('ListCell');
var Network = require('Network');
cc.Class({
extends: ListCell,
properties: {
},
statics: {
PFB_NAME: 'prefab/pfbPersonRoleInstallCategoryListCell',
CELL_NAME: 'RoleInstallListCell',
},
init: function (iCellIndex, bIsFocusEnable, compSceneCanvas) {
this._compSceneCanvas = compSceneCanvas;
this._iCellIndex = iCellIndex;
this.node.zIndex=20; //TODO:提升权值,显示在背景框上层
var self=this;
// cc.loader.loadRes('texture/ui/personal_cell_focus', cc.SpriteFrame, function (err, spriteFrame) {
// cc.find('Bg', self.node).getComponent(cc.Sprite).spriteFrame = spriteFrame;
// });
let nodeExplainText = cc.find('Explain/Text', this.node);
nodeExplainText.getComponent(cc.Label).string = "载入中...";
//准备焦点坐标
let fiCategoryBlock = this.node.addComponent(FocusInfo);
fiCategoryBlock.init(
'{"click":[{\
"action":"ChangeScene",\
"parameters":{\
"sceneName":"sceneStarList",\
"categoryId":"",\
"elderLevel":"1",\
"appId":""\
}\
}]}',
false, null, null, 1.0
);
compSceneCanvas.addNodeToFocusTarget(0, this.node.name, this.node);
},
render(oData, iRecordIndex) {
let nodePic = this.node.getChildByName('Pic');
let nodeExplainText=cc.find('Explain/Text',this.node);
let nodeInstallIcon=cc.find('InstallIcon',this.node); //是否安装
// oData.in_use==1?nodeInstallIcon.opacity=255:nodeInstallIcon.opacity=0;
if(oData.in_use){
nodeInstallIcon.opacity=255;
nodeExplainText.getComponent(cc.Label).string="按【确定】卸载";
}else{
nodeInstallIcon.opacity=0;
nodeExplainText.getComponent(cc.Label).string="按【确定】使用";
}
var fileURL = '';
if (typeof (oData.images) != 'undefined' && oData.images.map.thumbnail != null) {
var index = oData.images.map.thumbnail[0];
fileURL = oData.images.list[index].fileUrl;
}
Network.loadImageInNativeRuntime(
Common.TOPDRAW_IMAGE_SERVER + fileURL,
function (texture) {
nodePic.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}, null, this
);
//准备焦点坐标
let fiCategoryBlock = this.node.getComponent(FocusInfo);
fiCategoryBlock.setTVLink('{"click": [{"action": "ChangeScene",' +
'"parameters": {' +
'"sceneName":"sceneClassifyDetail",' +
'"categoryId": "' + oData.id + '",' +
'"elderLevel":"1",' +
'"appId":"' + this._compSceneCanvas._strAppId + '"' +
'}}]}');
},
enableFocusInfo: function () {
this.node.getComponent(FocusInfo).setEnable(true);
},
disableFocusInfo: function () {
this.node.getComponent(FocusInfo).setEnable(false);
},
setUIWithFocus: function () {
//let nodeSongListCell=;
let nodeCollection = this.node.getChildByName('Collection');
nodeCollection.opacity = 255;
//nodeCollection.getComponent(FocusInfo).setEnable(true);
//转起来 这部分以后要尽量放到Cell里去
let nodeTitleMask = this.node.getChildByName('ImageBlock').getChildByName('TitleMask');
let nodeTitleContainer = nodeTitleMask.getChildByName('TitleContainer');
let nodeTitleText1 = nodeTitleContainer.getChildByName("TitleText1");
let nodeTitleText2 = nodeTitleContainer.getChildByName("TitleText2");
let fOriginalX = nodeTitleContainer.x;
let fOriginalY = nodeTitleContainer.y;
if (nodeTitleText1.width > nodeTitleMask.width) { //字超出长度才滚动
let fEndPositionDelta = nodeTitleText1.width / 2 + 50 + nodeTitleText2.width / 2;
//下方时长和字有关系,才能速度一样
var ftaTitleMoveToTarget = cc.moveTo(10, fOriginalX - fEndPositionDelta, fOriginalY);
var ftaTitleMoveToBack = cc.moveTo(0, fOriginalX, fOriginalY);
var sequenceTitle = cc.sequence(ftaTitleMoveToTarget, ftaTitleMoveToBack);
var repeatTitle = cc.repeat(sequenceTitle, 10);
repeatTitle.setTag(Common.OVERLENGTH_MOVING);
nodeTitleContainer.stopAction(nodeTitleContainer.getActionByTag(Common.OVERLENGTH_MOVING));
nodeTitleContainer.runAction(repeatTitle);
}
},
setUIWithoutFocus: function () {
let nodeImageBlock = this.node.getChildByName('ImageBlock')
let nodeTitleMask = nodeImageBlock.getChildByName('TitleMask');
let nodeTitleContainer = nodeTitleMask.getChildByName('TitleContainer');
let nodeCollection = this.node.getChildByName('Collection');
//if (nodeTo!=nodeCollectionFrom){ //离开图片并且去的不是图片所在的Collection区
// nodeCollectionFrom.opacity=0;
// nodeCollectionFrom.getComponent(FocusInfo).setEnable(false);
//}
//let nodeTitleContainer=this.node.getChildByName('ImageBlock').getChildByName('TitleMask').getChildByName('TitleContainer');
nodeTitleContainer.stopAction(nodeTitleContainer.getActionByTag(Common.OVERLENGTH_MOVING));
nodeTitleContainer.x = 0;
},
});