From 73022c1d8cabeccfa4860eb5a60d42b0943996e3 Mon Sep 17 00:00:00 2001 From: "guoqing.zhu" <1521292690@qq.com> Date: Mon, 30 May 2022 17:33:30 +0800 Subject: [PATCH] add second rank --- assets/res/prefabs/NUI/UIrankinglist.prefab | 29 +++++--- assets/scripts/BaseNet.js | 13 ++-- assets/scripts/UI/UIRank/UIRank.js | 75 ++++++++++++++++----- assets/scripts/manages/NetManage.js | 10 +++ 4 files changed, 98 insertions(+), 29 deletions(-) diff --git a/assets/res/prefabs/NUI/UIrankinglist.prefab b/assets/res/prefabs/NUI/UIrankinglist.prefab index cb434343..bdbed265 100644 --- a/assets/res/prefabs/NUI/UIrankinglist.prefab +++ b/assets/res/prefabs/NUI/UIrankinglist.prefab @@ -1731,7 +1731,7 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 41, + "width": 110, "height": 28 }, "_anchorPoint": { @@ -2459,10 +2459,12 @@ }, { "__type__": "cc.ClickEvent", - "target": null, + "target": { + "__id__": 1 + }, "component": "", - "_componentId": "55dadiCkx9MBJ4P07bCUnLB", - "handler": "onclicktype", + "_componentId": "edcc4x5mGVLhpXyDw8n3EfX", + "handler": "onClickFirstRank", "customEventData": "0" }, { @@ -2511,7 +2513,7 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 41, + "width": 110, "height": 28 }, "_anchorPoint": { @@ -3239,10 +3241,12 @@ }, { "__type__": "cc.ClickEvent", - "target": null, + "target": { + "__id__": 1 + }, "component": "", - "_componentId": "55dadiCkx9MBJ4P07bCUnLB", - "handler": "onclicktype", + "_componentId": "edcc4x5mGVLhpXyDw8n3EfX", + "handler": "onClickSecondRank", "customEventData": "1" }, { @@ -8759,6 +8763,15 @@ "spine_hero": { "__id__": 247 }, + "nd_btn1": { + "__id__": 48 + }, + "nd_btn2": { + "__id__": 70 + }, + "tableContent": { + "__id__": 165 + }, "_id": "" }, { diff --git a/assets/scripts/BaseNet.js b/assets/scripts/BaseNet.js index e325c8ed..113f5ddb 100644 --- a/assets/scripts/BaseNet.js +++ b/assets/scripts/BaseNet.js @@ -19,11 +19,12 @@ export var allBaseNet = { isDevEnv(); function isDevEnv() { - var toreturn = false - if(cc.debug){ - return true; - } - return toreturn + return true + // var toreturn = false + // if(cc.debug){ + // return true; + // } + // return false } if (isDevEnv()) { @@ -33,6 +34,8 @@ if (isDevEnv()) { singapore: '-test.kingsome.cn', turkey: '-test-kingsome.cn', }; +}else{ + console.log("正式服") } const netIdHash = (function () { diff --git a/assets/scripts/UI/UIRank/UIRank.js b/assets/scripts/UI/UIRank/UIRank.js index aac5a93b..6b9a1394 100644 --- a/assets/scripts/UI/UIRank/UIRank.js +++ b/assets/scripts/UI/UIRank/UIRank.js @@ -1,4 +1,5 @@ const jcgamelog = require('../../jcfw/service/jcgamelog'); +const NetManage = require('../../manages/NetManage'); const { operation, OperationType } = require('../../Operation/Operation'); cc.Class({ @@ -17,6 +18,24 @@ cc.Class({ default: null, type: sp.Skeleton, }, + + nd_btn1:{ + default: null, + type: cc.Node, + }, + + nd_btn2:{ + default: null, + type: cc.Node, + }, + + tableContent:{ + default:null, + type:cc.Node + } + + + }, // LIFE-CYCLE CALLBACKS: @@ -26,9 +45,48 @@ cc.Class({ }, onLoad() { + // set can open + NetManage.getRankOpenList((res)=>{ + var rankList = res.list; + if(rankList.includes(2) && this.nd_btn2) this.nd_btn2.active = true; + }); + jcgamelog.addOperation(OperationType.BUTTON, 'get into rank'); cc.Notifier.on('clickrankhero', this, this.clickrankhero.bind(this)); }, + + onClickFirstRank(){ + NetManage.getactivityRankingList(1, (data) => { + this.initTable(JSON.stringify(data)); + }); + }, + + onClickSecondRank(){ + NetManage.getactivityRankingList(2, (data) => { + this.initTable(JSON.stringify(data)); + }); + }, + + initTable(rankData){ + this.tableContent.destroyAllChildren(); + var data = JSON.parse(rankData); + this.nd_my.getComponent('cellRank').initdata(data.my_ranked); + setTimeout(() => { + this.tableView + .getComponent('tableView') + .initTableView(data.rows.length, { + array: data.rows, + target: this, + }); + if (data.rows.length > 0) { + cc.Notifier.emit('clickrankhero', { + account_id: data.rows[0].user.account_id, + hero_id: data.rows[0].user.hero_id, + }); + } + }, 100); + }, + onDestroy() { cc.Notifier.off('clickrankhero', this); }, @@ -45,22 +103,7 @@ cc.Class({ ); }, start() { - var data = JSON.parse(this.rankData); - - this.nd_my.getComponent('cellRank').initdata(data.my_ranked); - - this.tableView - .getComponent('tableView') - .initTableView(data.rows.length, { - array: data.rows, - target: this, - }); - if (data.rows.length > 0) { - cc.Notifier.emit('clickrankhero', { - account_id: data.rows[0].user.account_id, - hero_id: data.rows[0].user.hero_id, - }); - } + this.initTable(this.rankData); }, onclose() { this.node.destroy(); diff --git a/assets/scripts/manages/NetManage.js b/assets/scripts/manages/NetManage.js index c70c09c9..825e677f 100644 --- a/assets/scripts/manages/NetManage.js +++ b/assets/scripts/manages/NetManage.js @@ -635,4 +635,14 @@ module.exports = { .addKV("name", name); this.getResponce(cb, this.urlbd); }, + + getRankOpenList(cb) { + this.urlbd.clear(); + this.urlbd + .addKV("c", "Ranking") + .addKV("a", "getOpenList") + .addKV("account_id", this.account_id) + .addKV("session_id", this.session_id) + this.getResponce(cb, this.urlbd); + }, };