替换新UI

This commit is contained in:
COMPUTER\EDY 2025-11-12 18:05:07 +08:00
parent a2614fea9a
commit 33392dface
16 changed files with 11198 additions and 10552 deletions

File diff suppressed because it is too large Load Diff

View File

@ -118,7 +118,7 @@ export default class JiaZai extends cc.Component {
this.closeAvatar(); this.closeAvatar();
this.setShareInfo(); this.setShareInfo();
this.checkTasks(); this.checkTasks();
// this.getSRank(); this.getSRank();
this.checkAndSetPlayerPassLevel(); this.checkAndSetPlayerPassLevel();
// this.checkDailyQuests(); // this.checkDailyQuests();
//console.log("进入首页获取的share", cc.fx.GameConfig.GM_INFO.otherUid, cc.fx.GameConfig.GM_INFO.otherLevel); //console.log("进入首页获取的share", cc.fx.GameConfig.GM_INFO.otherUid, cc.fx.GameConfig.GM_INFO.otherLevel);
@ -2280,6 +2280,7 @@ export default class JiaZai extends cc.Component {
getSRank() { getSRank() {
this.LoadCareer(null); this.LoadCareer(null);
Utils.getSRank(res => { Utils.getSRank(res => {
let data = JSON.parse(res.data); let data = JSON.parse(res.data);
let role = data.role; let role = data.role;
let sortedArray = []; let sortedArray = [];
@ -2292,7 +2293,7 @@ export default class JiaZai extends cc.Component {
count: item[1] // 数值 count: item[1] // 数值
})); }));
// 排序后的结果 // 排序后的结果
// console.log(sortedArray); // console.log("sortedArray", sortedArray);
let city = JSON.parse(JSON.stringify(cc.fx.GameConfig.CITY)); let city = JSON.parse(JSON.stringify(cc.fx.GameConfig.CITY));
let rankData = []; let rankData = [];
for (let i = 0; i < sortedArray.length; i++) { for (let i = 0; i < sortedArray.length; i++) {
@ -2321,34 +2322,41 @@ export default class JiaZai extends cc.Component {
rankingData: [] rankingData: []
}); });
} }
let otherIndex = rankData.findIndex(item => item.name === "其他");
if (otherIndex !== -1) {
let otherItem = rankData.splice(otherIndex, 1)[0];
rankData.push(otherItem);
}
let topData = data.all ? data.all : [];
if (this.RankNode != null && this.RankNode != undefined) { if (this.RankNode != null && this.RankNode != undefined) {
this.node.addChild(this.RankNode); this.node.getChildByName("Career").addChild(this.RankNode);
this.RankNode.zIndex = 3; this.RankNode.zIndex = 3;
this.RankNode.getComponent("CareerManager").init(rankData); this.RankNode.getComponent("CareerManager").init(rankData, topData);
} else { } else {
this.LoadCareer(() => { this.LoadCareer(() => {
this.node.addChild(this.RankNode); this.node.getChildByName("Career").addChild(this.RankNode);
this.RankNode.zIndex = 3; this.RankNode.zIndex = 3;
this.RankNode.getComponent("CareerManager").init(rankData); this.RankNode.getComponent("CareerManager").init(rankData, topData);
}) })
} }
console.log(rankData); // console.log("rankData", rankData);
}); });
} }
LoadCareer(callback: () => void) { LoadCareer(callback: () => void) {
cc.assetManager.loadBundle('career', (err: Error, bundle: cc.AssetManager.Bundle) => { cc.assetManager.loadBundle('career', (err: Error, bundle: cc.AssetManager.Bundle) => {
if (err) { if (err) {
cc.error(err.message || err); cc.error(err.message || err);
return; return;
} }
console.log("入职排行已加载好预制体1");
bundle.load('prefab/rankGame', cc.Prefab, (err: Error, prefab: cc.Prefab) => { bundle.load('prefab/rankGame', cc.Prefab, (err: Error, prefab: cc.Prefab) => {
if (err) { if (err) {
cc.error(err.message || err); cc.error(err.message || err);
return; return;
} }
console.log("入职排行已加载好预制体2");
this.RankNode = cc.instantiate(prefab); this.RankNode = cc.instantiate(prefab);
if (callback) if (callback)
callback(); callback();

243
assets/UI/UI/newUI.plist Normal file
View File

@ -0,0 +1,243 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>beginBtn.png</key>
<dict>
<key>frame</key>
<string>{{2,191},{570,176}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{570,176}}</string>
<key>sourceSize</key>
<string>{570,176}</string>
</dict>
<key>customDi.png</key>
<dict>
<key>frame</key>
<string>{{2,2},{352,89}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{352,89}}</string>
<key>sourceSize</key>
<string>{352,89}</string>
</dict>
<key>customTitle.png</key>
<dict>
<key>frame</key>
<string>{{2,157},{230,32}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{230,32}}</string>
<key>sourceSize</key>
<string>{230,32}</string>
</dict>
<key>fenKuang.png</key>
<dict>
<key>frame</key>
<string>{{240,133},{236,62}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{236,62}}</string>
<key>sourceSize</key>
<string>{236,62}</string>
</dict>
<key>jia.png</key>
<dict>
<key>frame</key>
<string>{{316,93},{38,38}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{38,38}}</string>
<key>sourceSize</key>
<string>{38,38}</string>
</dict>
<key>man.png</key>
<dict>
<key>frame</key>
<string>{{240,93},{74,38}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{74,38}}</string>
<key>sourceSize</key>
<string>{74,38}</string>
</dict>
<key>manKuang.png</key>
<dict>
<key>frame</key>
<string>{{2,93},{236,62}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{236,62}}</string>
<key>sourceSize</key>
<string>{236,62}</string>
</dict>
<key>tu01.png</key>
<dict>
<key>frame</key>
<string>{{2,763},{159,172}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{159,172}}</string>
<key>sourceSize</key>
<string>{159,172}</string>
</dict>
<key>tu02.png</key>
<dict>
<key>frame</key>
<string>{{315,698},{140,146}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{140,146}}</string>
<key>sourceSize</key>
<string>{140,146}</string>
</dict>
<key>tu03.png</key>
<dict>
<key>frame</key>
<string>{{315,556},{140,146}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{140,146}}</string>
<key>sourceSize</key>
<string>{140,146}</string>
</dict>
<key>tu04.png</key>
<dict>
<key>frame</key>
<string>{{304,331},{223,194}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{223,194}}</string>
<key>sourceSize</key>
<string>{223,194}</string>
</dict>
<key>tu05.png</key>
<dict>
<key>frame</key>
<string>{{163,763},{160,131}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{160,131}}</string>
<key>sourceSize</key>
<string>{160,131}</string>
</dict>
<key>tu06.png</key>
<dict>
<key>frame</key>
<string>{{180,556},{148,133}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{148,133}}</string>
<key>sourceSize</key>
<string>{148,133}</string>
</dict>
<key>tu07.png</key>
<dict>
<key>frame</key>
<string>{{356,2},{153,161}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{153,161}}</string>
<key>sourceSize</key>
<string>{153,161}</string>
</dict>
<key>tutut.png</key>
<dict>
<key>frame</key>
<string>{{304,133},{155,46}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{155,46}}</string>
<key>sourceSize</key>
<string>{155,46}</string>
</dict>
<key>tututt.png</key>
<dict>
<key>frame</key>
<string>{{352,165},{151,164}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{151,164}}</string>
<key>sourceSize</key>
<string>{151,164}</string>
</dict>
<key>tutututu.png</key>
<dict>
<key>frame</key>
<string>{{296,840},{139,145}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{139,145}}</string>
<key>sourceSize</key>
<string>{139,145}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>newUI.png</string>
<key>size</key>
<string>{512,1024}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:385489b072a7268f1a230ea1bfa3bfe0$</string>
<key>textureFileName</key>
<string>newUI.png</string>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,404 @@
{
"ver": "1.2.6",
"uuid": "87a22385-255f-4b25-8aef-a30045d22be4",
"importer": "asset",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"size": {
"width": 512,
"height": 1024
},
"type": "Texture Packer",
"subMetas": {
"beginBtn.png": {
"ver": "1.0.6",
"uuid": "184317fe-63c9-4852-9ebb-5eb4223b3f8c",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": true,
"offsetX": 0,
"offsetY": 0,
"trimX": 2,
"trimY": 191,
"width": 570,
"height": 176,
"rawWidth": 570,
"rawHeight": 176,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"customDi.png": {
"ver": "1.0.6",
"uuid": "6f471cbe-8aad-48d8-a386-814e7e00f3da",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 2,
"trimY": 2,
"width": 352,
"height": 89,
"rawWidth": 352,
"rawHeight": 89,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"customTitle.png": {
"ver": "1.0.6",
"uuid": "ae9f3408-79c8-4e78-9ef3-7b496c9f627c",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 2,
"trimY": 157,
"width": 230,
"height": 32,
"rawWidth": 230,
"rawHeight": 32,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"fenKuang.png": {
"ver": "1.0.6",
"uuid": "27e4e784-2bb1-40b2-9726-a3d160165c43",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": true,
"offsetX": 0,
"offsetY": 0,
"trimX": 240,
"trimY": 133,
"width": 236,
"height": 62,
"rawWidth": 236,
"rawHeight": 62,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"jia.png": {
"ver": "1.0.6",
"uuid": "ea27cfca-1cb3-4df0-92d9-5c62bca5d634",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 316,
"trimY": 93,
"width": 38,
"height": 38,
"rawWidth": 38,
"rawHeight": 38,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"man.png": {
"ver": "1.0.6",
"uuid": "1eabaff0-07cb-4de7-a55d-75a068061ea2",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 240,
"trimY": 93,
"width": 74,
"height": 38,
"rawWidth": 74,
"rawHeight": 38,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"manKuang.png": {
"ver": "1.0.6",
"uuid": "21ec0fc2-b090-4eb7-bb39-83b6de6b2f87",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 2,
"trimY": 93,
"width": 236,
"height": 62,
"rawWidth": 236,
"rawHeight": 62,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tu01.png": {
"ver": "1.0.6",
"uuid": "8303a52f-c22b-4aa8-a375-b836bdc27bc4",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 2,
"trimY": 763,
"width": 159,
"height": 172,
"rawWidth": 159,
"rawHeight": 172,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tu02.png": {
"ver": "1.0.6",
"uuid": "53d03fae-62ba-4ae6-8234-6ef8c1f2dad6",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": true,
"offsetX": 0,
"offsetY": 0,
"trimX": 315,
"trimY": 698,
"width": 140,
"height": 146,
"rawWidth": 140,
"rawHeight": 146,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tu03.png": {
"ver": "1.0.6",
"uuid": "3d3d6083-0d4b-49df-9a1c-227b6183a929",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": true,
"offsetX": 0,
"offsetY": 0,
"trimX": 315,
"trimY": 556,
"width": 140,
"height": 146,
"rawWidth": 140,
"rawHeight": 146,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tu04.png": {
"ver": "1.0.6",
"uuid": "1810e6cf-6842-4ea2-9ed5-658c052b9641",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": true,
"offsetX": 0,
"offsetY": 0,
"trimX": 304,
"trimY": 331,
"width": 223,
"height": 194,
"rawWidth": 223,
"rawHeight": 194,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tu05.png": {
"ver": "1.0.6",
"uuid": "464dec72-5388-4099-ab6b-96870aa11c86",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": true,
"offsetX": 0,
"offsetY": 0,
"trimX": 163,
"trimY": 763,
"width": 160,
"height": 131,
"rawWidth": 160,
"rawHeight": 131,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tu06.png": {
"ver": "1.0.6",
"uuid": "6ba08e87-25b2-4f6f-a185-ab80bf71c871",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": true,
"offsetX": 0,
"offsetY": 0,
"trimX": 180,
"trimY": 556,
"width": 148,
"height": 133,
"rawWidth": 148,
"rawHeight": 133,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tu07.png": {
"ver": "1.0.6",
"uuid": "6957871e-991a-40b7-8654-375c65019c4c",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 356,
"trimY": 2,
"width": 153,
"height": 161,
"rawWidth": 153,
"rawHeight": 161,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tutut.png": {
"ver": "1.0.6",
"uuid": "be0203aa-a191-4399-8744-6909f5b4c406",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": true,
"offsetX": 0,
"offsetY": 0,
"trimX": 304,
"trimY": 133,
"width": 155,
"height": 46,
"rawWidth": 155,
"rawHeight": 46,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tututt.png": {
"ver": "1.0.6",
"uuid": "02737ff5-2fea-430e-b4b5-971f3c492e15",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 352,
"trimY": 165,
"width": 151,
"height": 164,
"rawWidth": 151,
"rawHeight": 164,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
},
"tutututu.png": {
"ver": "1.0.6",
"uuid": "847cec02-e173-4cc2-8349-ffcd0336c770",
"importer": "sprite-frame",
"rawTextureUuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 296,
"trimY": 840,
"width": 139,
"height": 145,
"rawWidth": 139,
"rawHeight": 145,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"spriteType": "normal",
"subMetas": {}
}
}
}

BIN
assets/UI/UI/newUI.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View File

@ -0,0 +1,15 @@
{
"ver": "2.3.7",
"uuid": "a151e332-9c6e-46d8-818a-d3ed01b5ba61",
"importer": "texture",
"type": "raw",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 512,
"height": 1024,
"platformSettings": {},
"subMetas": {}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 575 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -1,6 +1,6 @@
{ {
"ver": "2.3.7", "ver": "2.3.7",
"uuid": "5446346a-3fb9-4f57-bd44-4858f8fd3af2", "uuid": "043a661e-1452-433f-b2f2-d270a7d8a6b9",
"importer": "texture", "importer": "texture",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
@ -12,11 +12,11 @@
"height": 2340, "height": 2340,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg": { "careerBg": {
"ver": "1.0.6", "ver": "1.0.6",
"uuid": "f79670d6-8e4a-4e61-b781-a48fe0de6044", "uuid": "2dece190-21a1-4502-9947-858be2b5d927",
"importer": "sprite-frame", "importer": "sprite-frame",
"rawTextureUuid": "5446346a-3fb9-4f57-bd44-4858f8fd3af2", "rawTextureUuid": "043a661e-1452-433f-b2f2-d270a7d8a6b9",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 124 KiB

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
import RoundBox from "../../Script/module/Tool/RoundBox";
import NumberToImage from "../../Script/NumberToImage"; import NumberToImage from "../../Script/NumberToImage";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ -13,76 +14,78 @@ export default class CareerItem extends cc.Component {
defaultsprite: cc.SpriteFrame = null; defaultsprite: cc.SpriteFrame = null;
@property(cc.SpriteAtlas) @property(cc.SpriteAtlas)
ui: cc.SpriteAtlas = null; UI: cc.SpriteAtlas = null;
randerChildren: any;
/**数据改变时调用 */ /**数据改变时调用 */
public dataChanged() { public dataChanged() {
this.randerChildren = [];
// if (this.data == undefined) {
// this.node.active = false;
// return;
// }
// let useravatarIcon = this.data.useravatarIcon; // let useravatarIcon = this.data.useravatarIcon;
// useravatarIcon = "kuang_" + (parseInt(useravatarIcon) + 1); // useravatarIcon = "kuang_" + (parseInt(useravatarIcon) + 1);
// this.node.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = // this.node.getChildByName("icon").getComponent(cc.Sprite).spriteFrame =
// this.ui.getSpriteFrame(useravatarIcon); // this.ui.getSpriteFrame(useravatarIcon);
// console.log("用户头像框:", this.data.useravatarIcon, useravatarIcon);
// this.data.username = cc.fx.GameTool.subName(this.data.username, 7); // this.data.username = cc.fx.GameTool.subName(this.data.username, 7);
// let name = this.data.username; // let name = this.data.username;
// if (name == "user") name = "匿名玩家"; // if (name == "user") name = "匿名玩家";
for (let i = 4; i < 12; i++) {
this.node.children[i].getChildByName("name").getComponent(cc.Label).string = "";
this.node.children[i].getChildByName("level").getComponent(cc.Label).string = "";
this.node.children[i].getChildByName("icon").getComponent(RoundBox).spriteFrame = null;
this.node.children[i].getChildByName("kong").active = true;
}
if (this.data != undefined) {
this.node.opacity = 255;
this.node.getChildByName("rank").getComponent(cc.Label).string = this.data.count + "";
this.node.getChildByName("cityName").getComponent(cc.Sprite).spriteFrame = this.UI.getSpriteFrame(this.data.name);
this.node.getChildByName("rank").getComponent(cc.Label).string = this.data.rank + ""; if (this.randerChildren.length == 0) {
// this.node.getChildByName("nameLab").getComponent(cc.Label).string = name + ""; this.randerChildren = [];
// // this.node.getChildByName("totalLab").getComponent(cc.Label).string = this.data.levelAmount; let length = this.data.rankingData.length + 4;
if (length > 12) length = 12;
for (let i = 4; i < length; i++) {
this.randerChildren.push(this.node.children[i]);
let username = cc.fx.GameTool.subName(this.data.rankingData[i - 4].username, 7);
if (username == "user") username = "匿名玩家";
this.node.children[i].getChildByName("kong").active = false;
this.node.children[i].getChildByName("name").getComponent(cc.Label).string = username + "";
this.node.children[i].getChildByName("level").getComponent(cc.Label).string = this.data.rankingData[i - 4].addLevel;
if (this.data.rankingData[i - 4].useravatar == "" || this.data.rankingData[i - 4].useravatar == null || this.data.rankingData[i - 4].useravatar == undefined
) {
// this.firstRender.children[i].getChildByName("icon").getComponent(cc.Sprite).spriteFrame = this.defaultsprite;
}
else if (this.data.rankingData[i - 4].useravatar == "0" || this.data.rankingData[i - 4].useravatar == "1" || this.data.rankingData[i - 4].useravatar == "2"
|| this.data.rankingData[i - 4].useravatar == "3") {
let useravatar = this.data.rankingData[i - 4].useravatar;
let useravatarTemp = "icon_" + useravatar;
this.node.children[i].getChildByName("icon").getComponent(RoundBox).spriteFrame = this.UI.getSpriteFrame(useravatarTemp);
}
else this.setPic(this.data.rankingData[i - 4].useravatar, this.node.children[i].getChildByName("icon"));
}
}
// NumberToImage.numberToImageNodes3((this.data.rank), 43, 15, "rank_", this.node.getChildByName("rankLab"), true); }
// NumberToImage.numberToImageNodes3(this.data.levelAmount, 43, 15, "level_", this.node.getChildByName("totalLab"), true); else {
this.node.opacity = 0;
// // this.node.getChildByName("timeLab").getComponent(cc.Label).string = timeTemp + ""; }
// this.node.getChildByName("rank").getChildByName("one").active = false;
// this.node.getChildByName("rank").getChildByName("two").active = false;
// this.node.getChildByName("rank").getChildByName("three").active = false;
// if (this.data.rank == 1) {
// this.node.getChildByName("rank").getChildByName("one").active = true;
// this.node.getChildByName("rankLab").active = false;
// }
// else if (this.data.rank == 2) {
// this.node.getChildByName("rank").getChildByName("two").active = true;
// this.node.getChildByName("rankLab").active = false;
// }
// else if (this.data.rank == 3) {
// this.node.getChildByName("rank").getChildByName("three").active = true;
// this.node.getChildByName("rankLab").active = false;
// } else {
// this.node.getChildByName("rankLab").active = true;
// }
// if (this.data.useravatar == "" || this.data.useravatar == null || this.data.useravatar == undefined
// ) {
// this.node.getChildByName("pic").getComponent(cc.Sprite).spriteFrame = this.defaultsprite;
// }
// else if (this.data.useravatar == "0" || this.data.useravatar == "1" || this.data.useravatar == "2"
// || this.data.useravatar == "3") {
// let useravatar = this.data.useravatar;
// let useravatarTemp = "icon_" + useravatar;
// console.log("用户头像:", useravatarTemp);
// this.node.getChildByName("pic").getComponent(cc.Sprite).spriteFrame = this.ui.getSpriteFrame(useravatarTemp);
// }
// else this.setPic();
} }
public setPic() { public setPic(url, node) {
// console.log("设置头像:", this.data.useravatar);
// this.node.getChildByName("pic").getChildByName("icon").active = false; // this.node.getChildByName("pic").getChildByName("icon").active = false;
this.node.getChildByName("pic").active = false; // this.node.getChildByName("pic").active = false;
var self = this; var self = this;
let url = this.data.useravatar; // let url = this.data.useravatar;
cc.assetManager.loadRemote(url, { ext: '.png' }, (err, texture: cc.Texture2D) => { cc.assetManager.loadRemote(url, { ext: '.png' }, (err, texture: cc.Texture2D) => {
if (texture) { if (texture) {
this.node.getChildByName("pic").active = true; // this.node.getChildByName("pic").active = true;
var sprite = this.node.getChildByName("pic").getComponent(cc.Sprite); var sprite = node.getComponent(RoundBox);
sprite.spriteFrame = new cc.SpriteFrame(texture); sprite.spriteFrame = new cc.SpriteFrame(texture);
// console.log(this.data.rank,"设置头像成功",err);
} }
else { else {
// console.log("设置头像失败",url);
// console.log(err, texture)
} }
}) })
} }

View File

@ -6,7 +6,9 @@
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import CareerItem from "./CareerItem" import RoundBox from "../../Script/module/Tool/RoundBox";
import CareerItem from "./CareerItem";
// import CareerItem from "./CareerItem"
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ -123,8 +125,14 @@ export default class CareerList extends cc.Component {
private bScrolling: boolean = false; private bScrolling: boolean = false;
/**刷新的函数 */ /**刷新的函数 */
private updateFun: Function = function () { }; private updateFun: Function = function () { };
randerChildren: any[];
topData: any;
@property(cc.SpriteAtlas)
UI: cc.SpriteAtlas = null;
onLoad() { onLoad() {
this.randerChildren = [];
this.itemHeight = this.itemRender.height; this.itemHeight = this.itemRender.height;
this.itemWidth = this.itemRender.width; this.itemWidth = this.itemRender.width;
this.scrollView = this.node.getComponent(cc.ScrollView); this.scrollView = this.node.getComponent(cc.ScrollView);
@ -136,7 +144,8 @@ export default class CareerList extends cc.Component {
// 初始化firstRender // 初始化firstRender
if (this.firstRender) { if (this.firstRender) {
this.firstRender.parent = this.content; this.firstRender.parent = this.content;
this.firstRender.active = true; // this.firstRender.active = true;
// this.firstRenderInit();
// 设置firstRender的位置在顶部 // 设置firstRender的位置在顶部
if (this.type == ListType.Vertical) { if (this.type == ListType.Vertical) {
this.firstRender.setPosition(535, 0); this.firstRender.setPosition(535, 0);
@ -152,9 +161,12 @@ export default class CareerList extends cc.Component {
* (使) * (使)
* @param itemDataList item数据列表 * @param itemDataList item数据列表
*/ */
public setData(itemDataList: Array<any>) { public setData(itemDataList: Array<any>, topData: any) {
// 检查 itemDataList 是否为有效数组,如果不是则初始化为空数组 // 检查 itemDataList 是否为有效数组,如果不是则初始化为空数组
this.itemDataList = itemDataList.slice(); this.itemDataList = itemDataList.slice();
this.topData = topData;
console.log(this.topData);
this.firstRenderInit();
this.updateContent(); this.updateContent();
} }
@ -163,7 +175,7 @@ export default class CareerList extends cc.Component {
let dataLen = this.itemDataList.length; let dataLen = this.itemDataList.length;
let firstRenderHeight = this.firstRender ? this.firstRender.height : 0; let firstRenderHeight = this.firstRender ? this.firstRender.height : 0;
let firstRenderWidth = this.firstRender ? this.firstRender.width : 0; let firstRenderWidth = this.firstRender ? this.firstRender.width : 0;
debugger;
if (this.type == ListType.Vertical) { if (this.type == ListType.Vertical) {
this.scrollView.horizontal = false; this.scrollView.horizontal = false;
this.scrollView.vertical = true; this.scrollView.vertical = true;
@ -171,7 +183,7 @@ export default class CareerList extends cc.Component {
// 计算高度时考虑firstRender的高度和间距 // 计算高度时考虑firstRender的高度和间距
this.content.height = firstRenderHeight + (firstRenderHeight > 0 ? this.spaceY : 0) + this.content.height = firstRenderHeight + (firstRenderHeight > 0 ? this.spaceY : 0) +
dataLen * this.itemHeight + (dataLen - 3) * this.spaceY + this.padding_top + this.padding_buttom; dataLen * this.itemHeight + (dataLen - 3) * this.spaceY + this.padding_top + this.padding_buttom;
this.spawnCount = Math.round(this.scrollView.node.height / (this.itemHeight + this.spaceY)) + 10; //计算创建的item实例数量比当前scrollView容器能放下的item数量再加上2个 this.spawnCount = Math.round(this.scrollView.node.height / (this.itemHeight + this.spaceY)) + 2; //计算创建的item实例数量比当前scrollView容器能放下的item数量再加上2个
this.halfScrollView = this.scrollView.node.height / 2 + this.itemHeight / 2 + this.spaceY; //计算bufferZoneitem的显示范围 this.halfScrollView = this.scrollView.node.height / 2 + this.itemHeight / 2 + this.spaceY; //计算bufferZoneitem的显示范围
this.updateFun = this.updateV; this.updateFun = this.updateV;
} }
@ -183,11 +195,11 @@ export default class CareerList extends cc.Component {
* @param offset scrollView偏移量 * @param offset scrollView偏移量
*/ */
private createList(startIndex: number, offset: cc.Vec2) { private createList(startIndex: number, offset: cc.Vec2) {
//当需要显示的数据长度 > 虚拟列表长度, 删除最末尾几个数据时列表需要重置位置到scrollView最底端 //当需要显示的数据长度 > 虚拟列表长度, 删除最末尾几个数据时列表需要重置位置到scrollView最底端
if (this.itemDataList.length > this.spawnCount && (startIndex + this.spawnCount - 1) >= this.itemDataList.length) { if (this.itemDataList.length > this.spawnCount && (startIndex + this.spawnCount - 1) >= this.itemDataList.length) {
startIndex = this.itemDataList.length - this.spawnCount; startIndex = this.itemDataList.length - this.spawnCount;
offset = this.scrollView.getMaxScrollOffset(); offset = this.scrollView.getMaxScrollOffset();
//当需要显示的数据长度 <= 虚拟列表长度, 隐藏多余的虚拟列表项 //当需要显示的数据长度 <= 虚拟列表长度, 隐藏多余的虚拟列表项
} else if (this.itemDataList.length <= this.spawnCount) { } else if (this.itemDataList.length <= this.spawnCount) {
startIndex = 0; startIndex = 0;
@ -277,116 +289,28 @@ export default class CareerList extends cc.Component {
item = items[i]; item = items[i];
let viewPos = this.getPositionInView(item); let viewPos = this.getPositionInView(item);
if (isUp) { if (isUp) {
//item上滑时超出了scrollView上边界将item移动到下方复用item移动到下方的位置必须不超过content的下边界 if (viewPos) {
if (viewPos.y > bufferZone && item.y - offset - this.padding_buttom > -this.content.height + firstRenderOffsetY) { //item上滑时超出了scrollView上边界将item移动到下方复用item移动到下方的位置必须不超过content的下边界
let itemRender: CareerItem = item.getComponent(CareerItem); if (viewPos.y > bufferZone && item.y - offset - this.padding_buttom > -this.content.height - firstRenderOffsetY) {
let itemIndex = itemRender.itemIndex + items.length; let itemRender: CareerItem = item.getComponent(CareerItem);
itemRender.itemIndex = itemIndex; let itemIndex = itemRender.itemIndex + items.length;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.y = item.y - offset;
}
} else {
//item下滑时超出了scrollView下边界将item移动到上方复用item移动到上方的位置必须不超过content的上边界
if (viewPos.y < -bufferZone && item.y + offset + this.padding_top < -firstRenderOffsetY) {
let itemRender: CareerItem = item.getComponent(CareerItem);
let itemIndex = itemRender.itemIndex - items.length;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.y = item.y + offset;
}
}
}
this.lastContentPosY = this.scrollView.content.y;
}
/**水平排列 */
private udpateH() {
let items = this.itemList;
let item;
let bufferZone = this.halfScrollView;
let isRight = this.scrollView.content.x > this.lastContentPosX;
let offset = (this.itemWidth + this.spaceX) * items.length;
// 计算firstRender的宽度偏移
let firstRenderWidth = this.firstRender ? this.firstRender.width : 0;
let firstRenderOffsetX = firstRenderWidth > 0 ? firstRenderWidth + this.spaceX : 0;
for (let i = 0; i < items.length; i++) {
item = items[i];
let viewPos = this.getPositionInView(item);
if (isRight) {
//item右滑时超出了scrollView右边界将item移动到左方复用item移动到左方的位置必须不超过content的左边界
if (viewPos.x > bufferZone && item.x - offset - this.padding_left > firstRenderOffsetX) {
let itemRender: CareerItem = item.getComponent(CareerItem);
let itemIndex = itemRender.itemIndex - items.length;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.x = item.x - offset;
}
} else {
//item左滑时超出了scrollView左边界将item移动到右方复用item移动到右方的位置必须不超过content的右边界
if (viewPos.x < -bufferZone && item.x + offset + this.padding_right < this.content.width) {
let itemRender: CareerItem = item.getComponent(CareerItem);
let itemIndex = itemRender.itemIndex + items.length;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.x = item.x + offset;
}
}
}
this.lastContentPosX = this.scrollView.content.x;
}
/**网格垂直排列 */
private updateGrid_V() {
let items = this.itemList;
let item: cc.Node;
let bufferZone = this.halfScrollView;
let isUp = this.scrollView.content.y > this.lastContentPosY;
let offset = (this.itemHeight + this.spaceY) * (this.spawnCount / this.gridCol);
// 计算firstRender的高度偏移
let firstRenderHeight = this.firstRender ? this.firstRender.height : 0;
let firstRenderOffsetY = firstRenderHeight > 0 ? firstRenderHeight + this.spaceY : 0;
for (let i = 0; i < items.length; i++) {
item = items[i];
let viewPos = this.getPositionInView(item);
if (isUp) {
//item上滑时超出了scrollView上边界将item移动到下方复用item移动到下方的位置必须不超过content的下边界
if (viewPos.y > bufferZone && item.y - offset - this.padding_buttom > -this.content.height + firstRenderOffsetY) {
let itemRender: CareerItem = item.getComponent(CareerItem);
let itemIndex = itemRender.itemIndex + (this.spawnCount / this.gridCol) * this.gridCol;
if (this.itemDataList[itemIndex] != null) {
item.y = item.y - offset;
itemRender.itemIndex = itemIndex; itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex]; itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged(); itemRender.dataChanged();
item.opacity = 255;
} else {
item.y = item.y - offset; item.y = item.y - offset;
itemRender.itemIndex = itemIndex;
item.opacity = 0;
} }
} }
} else {//item下滑时超出了scrollView下边界将item移动到上方复用item移动到上方的位置必须不超过content的上边界
if (viewPos.y < -bufferZone && item.y + offset + this.padding_top < -firstRenderOffsetY) { } else {
let itemRender: CareerItem = item.getComponent(CareerItem); if (viewPos) {
let itemIndex = itemRender.itemIndex - (this.spawnCount / this.gridCol) * this.gridCol; //item下滑时超出了scrollView下边界将item移动到上方复用item移动到上方的位置必须不超过content的上边界
if (this.itemDataList[itemIndex] != null) { if (viewPos.y < -bufferZone && item.y + offset + this.padding_top < -firstRenderOffsetY) {
item.y = item.y + offset; let itemRender: CareerItem = item.getComponent(CareerItem);
let itemIndex = itemRender.itemIndex - items.length;
itemRender.itemIndex = itemIndex; itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex]; itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged(); itemRender.dataChanged();
item.opacity = 255;
} else {
item.y = item.y + offset; item.y = item.y + offset;
itemRender.itemIndex = itemIndex;
item.opacity = 0;
} }
} }
} }
@ -394,66 +318,15 @@ export default class CareerList extends cc.Component {
this.lastContentPosY = this.scrollView.content.y; this.lastContentPosY = this.scrollView.content.y;
} }
/**网格水平排列 */
private updateGrid_H() {
let items = this.itemList;
let item;
let bufferZone = this.halfScrollView;
let isRight = this.scrollView.content.x > this.lastContentPosX;
let offset = (this.itemWidth + this.spaceX) * (this.spawnCount / this.gridRow);
// 计算firstRender的宽度偏移
let firstRenderWidth = this.firstRender ? this.firstRender.width : 0;
let firstRenderOffsetX = firstRenderWidth > 0 ? firstRenderWidth + this.spaceX : 0;
for (let i = 0; i < items.length; i++) {
item = items[i];
let viewPos = this.getPositionInView(item);
if (isRight) {
//item右滑时超出了scrollView右边界将item移动到左方复用item移动到左方的位置必须不超过content的左边界
if (viewPos.x > bufferZone && item.x - offset - this.padding_left > firstRenderOffsetX) {
let itemRender: CareerItem = item.getComponent(CareerItem);
let itemIndex = itemRender.itemIndex - (this.spawnCount / this.gridRow) * this.gridRow;
if (this.itemDataList[itemIndex] != null) {
item.x = item.x - offset;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.opacity = 255;
} else {
item.x = item.x - offset;
itemRender.itemIndex = itemIndex;
item.opacity = 0;
}
}
} else {
//item左滑时超出了scrollView左边界将item移动到右方复用item移动到右方的位置必须不超过content的右边界
if (viewPos.x < -bufferZone && item.x + offset + this.padding_right < this.content.width) {
let itemRender: CareerItem = item.getComponent(CareerItem);
let itemIndex = itemRender.itemIndex + (this.spawnCount / this.gridRow) * this.gridRow;
if (this.itemDataList[itemIndex] != null) {
item.x = item.x + offset;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.opacity = 255;
} else {
item.x = item.x + offset;
itemRender.itemIndex = itemIndex;
item.opacity = 0;
}
}
}
}
this.lastContentPosX = this.scrollView.content.x;
}
/**获取item在scrollView的局部坐标 */ /**获取item在scrollView的局部坐标 */
private getPositionInView(item) { private getPositionInView(item) {
// if (item.parent) {
let worldPos = item.parent.convertToWorldSpaceAR(item.position); let worldPos = item.parent.convertToWorldSpaceAR(item.position);
let viewPos = this.scrollView.node.convertToNodeSpaceAR(worldPos); let viewPos = this.scrollView.node.convertToNodeSpaceAR(worldPos);
return viewPos; return viewPos;
// }
} }
/**获取列表数据 */ /**获取列表数据 */
@ -559,6 +432,55 @@ export default class CareerList extends cc.Component {
} }
} }
public firstRenderInit() {
// let
this.firstRender.active = true;
if (this.randerChildren.length == 0) {
this.randerChildren = [];
let length = this.topData.length + 3;
if (length > this.firstRender.children.length)
length = this.firstRender.children.length;
for (let i = 3; i < length; i++) {
this.randerChildren.push(this.firstRender.children[i]);
let username = cc.fx.GameTool.subName(this.topData[i - 3].username, 7);
if (username == "user") username = "匿名玩家";
this.firstRender.children[i].getChildByName("name").getComponent(cc.Label).string = username + "";
this.firstRender.children[i].getChildByName("rank").getComponent(cc.Label).string = this.topData[i - 3].addLevel;
if (this.topData[i - 3].useravatar == "" || this.topData[i - 3].useravatar == null || this.topData[i - 3].useravatar == undefined
) {
// this.firstRender.children[i].getChildByName("icon").getComponent(cc.Sprite).spriteFrame = this.defaultsprite;
}
else if (this.topData[i - 3].useravatar == "0" || this.topData[i - 3].useravatar == "1" || this.topData[i - 3].useravatar == "2"
|| this.topData[i - 3].useravatar == "3") {
let useravatar = this.topData[i - 3].useravatar;
let useravatarTemp = "icon_" + useravatar;
this.firstRender.children[i].getChildByName("icon").getComponent(RoundBox).spriteFrame = this.UI.getSpriteFrame(useravatarTemp);
}
else this.setPic(this.topData[i - 3].useravatar, this.firstRender.children[i].getChildByName("icon"));
}
}
}
public setPic(url, node) {
// this.node.getChildByName("pic").getChildByName("icon").active = false;
this.node.getChildByName("pic").active = false;
var self = this;
// let url = this.data.useravatar;
cc.assetManager.loadRemote(url, { ext: '.png' }, (err, texture: cc.Texture2D) => {
if (texture) {
node.getChildByName("pic").active = true;
var sprite = node.getComponent(RoundBox);
sprite.spriteFrame = new cc.SpriteFrame(texture);
}
else {
}
})
}
/**销毁 */ /**销毁 */
public onDestroy() { public onDestroy() {
//清理列表项 //清理列表项

View File

@ -17,25 +17,18 @@ export default class CareerManager extends cc.Component {
// this.init(); // this.init();
} }
//初始化数据 //初始化数据
init(data) { init(data, topData) {
this.rankList = cc.find("ScrollView", this.node).getComponent(CareerList); this.rankList = cc.find("ScrollView", this.node).getComponent(CareerList);
this.listData = data; this.listData = data;
this.selfData = null; this.selfData = null;
this.rankNumber = 100; this.rankNumber = 100;
this.rankTotal = 100; this.rankTotal = 100;
this.rankList.setData(data); this.rankList.setData(data, topData);
this.getRank();
} }
start() { start() {
} }
//调用获取排行榜接口
public getRank() {
let dataFile = {
length: 100
}
cc.fx.GameTool.getRank(dataFile, data => this.getRankData(data));
}
//实际设置排行数据 //实际设置排行数据
public getRankData(data) { public getRankData(data) {
if (data) { if (data) {
@ -78,16 +71,13 @@ export default class CareerManager extends cc.Component {
}) })
} }
public setData(data) { public setData(data, topData) {
this.selfData = data; this.selfData = data;
this.rankList.setData(this.listData); this.rankList.setData(this.listData, topData);
if (data.length > 0) { if (data.length > 0) {
this.rankNumber = data[0].rank; this.rankNumber = data[0].rank;
this.rankTotal = data.length; this.rankTotal = data.length;
} }
} }
} }