7
0

2 Commits 0fde7cde87 ... 6069438fad

Autor SHA1 Nachricht Datum
  Roy 6069438fad Merge branch 'qqplay-1.0' of http://svn.ouj.com:3000/DWG/budingGame into qqplay-1.0 vor 6 Jahren
  Roy 95f2e3dbbb 真实数据 vor 6 Jahren

+ 2 - 2
assets/Scene/GameSence.fire

@@ -8246,7 +8246,7 @@
       }
     ],
     "_tag": -1,
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 351
@@ -13360,7 +13360,7 @@
     "node": {
       "__id__": 219
     },
-    "_enabled": true,
+    "_enabled": false,
     "friendRankNode": {
       "__id__": 227
     },

+ 50 - 39
assets/Script/Rank/FriendRank.js

@@ -13,55 +13,66 @@ cc.Class({
 
     onLoad() {
         this.listAdapter = new ListViewAdapter(this.scrollView);
-        this.users = [];
 
         //-------------------------------------test--------------------------------------------------------------------------//
-        this.mineScore = {
-            nick: "user" + i,
-            url: "http://www.psahz.com/uploads/allimg/181006/094Q62X3-2.jpg",
-            score: (100 - i * 2)
-        };
+        // this.mineScore = {
+        //     nick: "user" + i,
+        //     url: "http://www.psahz.com/uploads/allimg/181006/094Q62X3-2.jpg",
+        //     score: (100 - i * 2)
+        // };
 
-        this.prefabRankItem.getComponent('RankItem').updateItem(this.mineScore, 0);
+        // this.prefabRankItem.getComponent('RankItem').updateItem(this.mineScore, 0);
 
-        for (i = 0; i < 30; i++) {
-            this.user = {
-                nick: "user" + i,
-                url: "http://www.psahz.com/uploads/allimg/181006/094Q62X3-2.jpg",
-                score: (100 - i * 2)
-            };
+        // for (i = 0; i < 30; i++) {
+        //     this.user = {
+        //         nick: "user" + i,
+        //         url: "http://www.psahz.com/uploads/allimg/181006/094Q62X3-2.jpg",
+        //         score: (100 - i * 2)
+        //     };
 
-            this.users.push(this.user);
-        }
-
-        this.listAdapter.updateItems(this.users, this.prefabRankItem, this.itemScriptName);
+        //     this.users.push(this.user);
+        // }
 
 
         //-------------------------------------test--------------------------------------------------------------------------//
 
+    },
 
-        // BK.QQ.getRankListWithoutRoom(attr, order, rankType, function (errCode, cmd, data) {
-        //     BK.Script.log(1, 1, "getRankListWithoutRoom callback  cmd" + cmd + " errCode:" + errCode + "  data:" + JSON.stringify(data));
-        //     // 返回错误码信息
-        //     if (errCode !== 0) {
-        //         BK.Script.log(1, 1, '获取排行榜数据失败!错误码:' + errCode);
-        //         return;
-        //     }
-        //     // 解析数据
-        //     if (data) {
-        //         for (var i = 0; i < data.data.ranking_list.length; ++i) {
-        //             var rd = data.data.ranking_list[i];
-        //             // rd 的字段如下:
-        //             //var rd = {
-        //             //    url: '',            // 头像的 url
-        //             //    nick: '',           // 昵称
-        //             //    score: 1,           // 分数
-        //             //    selfFlag: false,    // 是否是自己
-        //             //};
-        //         }
-        //     }
-        // });
-
+    onEnable() {
+        if (CC_QQPLAY) {
+            var attr = "score";//使用哪一种上报数据做排行,可传入score,a1,a2等
+            var order = 1;     //排序的方法:[ 1: 从大到小(单局),2: 从小到大(单局),3: 由大到小(累积)]
+            var rankType = 0; //要查询的排行榜类型,0: 好友排行榜
+            let self = this;
+            BK.QQ.getRankListWithoutRoom(attr, order, rankType, function (errCode, cmd, data) {
+                BK.Script.log(1, 1, "getRankListWithoutRoom callback  cmd" + cmd + " errCode:" + errCode + "  data:" + JSON.stringify(data));
+                // 返回错误码信息
+                if (errCode !== 0) {
+                    BK.Script.log(1, 1, '获取排行榜数据失败!错误码:' + errCode);
+                    return;
+                }
+                // 解析数据
+                if (data) {
+                    for (var i = 0; i < data.data.ranking_list.length; ++i) {
+                        var rd = data.data.ranking_list[i];
+                        // rd 的字段如下:
+                        //var rd = {
+                        //    url: '',            // 头像的 url
+                        //    nick: '',           // 昵称
+                        //    score: 1,           // 分数
+                        //    selfFlag: false,    // 是否是自己
+                        //};
+                        if (rd.selfFlag) {
+                            self.prefabRankItem.getComponent('RankItem').updateItem(rd, i);
+                        }
+                        self.listAdapter.updateItems(data.data.ranking_list, self.prefabRankItem, self.itemScriptName);
+                    }
+                }
+            });
+        } else {
+            let reponse = { "errCode": 0, "cmd": "apollo_router_game.apollo_user_rankinglist_linkcmd_custom_ranking", "data": { "data": { "ranking_list": [{ "nick": "石达开", "url": "http://img0.imgtn.bdimg.com/it/u=789186820,4034808660&fm=27&gp=0.jpg", "score": 1234, "a1": 121, "a2": 22, "selfFlag": true }, { "nick": "绝世佳人", "url": "http://a.hiphotos.baidu.com/zhidao/pic/item/21a4462309f79052782f28490ff3d7ca7bcbd591.jpg", "score": 924, "a1": 101, "a2": 20, "selfFlag": false }, { "nick": "千山万水", "url": "http://img5.imgtn.bdimg.com/it/u=1443063381,2025721196&fm=27&gp=0.jpg", "score": 712, "a1": 134, "a2": 24, "selfFlag": false }, { "nick": "三年二班", "url": "http://img1.imgtn.bdimg.com/it/u=3463612537,3165214774&fm=27&gp=0.jpg", "score": 527, "a1": 167, "a2": 23, "selfFlag": false }, { "nick": "henry", "url": "http://img5.imgtn.bdimg.com/it/u=377014827,3751078472&fm=27&gp=0.jpg", "score": 327, "a1": 154, "a2": 32, "selfFlag": false }, { "nick": "图样图森破", "url": "http://img2.imgtn.bdimg.com/it/u=1269743249,2763282807&fm=27&gp=0.jpg", "score": 227, "a1": 125, "a2": 86, "selfFlag": false }, { "nick": "Mo_Bai", "url": "http://img3.imgtn.bdimg.com/it/u=3166078695,1890527236&fm=27&gp=0.jpg", "score": 167, "a1": 138, "a2": 39, "selfFlag": false }] } } }
+            this.listAdapter.updateItems(reponse.data.data.ranking_list, this.prefabRankItem, this.itemScriptName);
+        }
     },
 
     start() {

+ 0 - 2
assets/Script/Rank/ListViewAdapter.js

@@ -19,7 +19,6 @@ class ListViewAdapter {
     }
 
     initialize(itemTemplate) {
-        console.log(this.scriptName);
         let actualCount = this.dataList.length < this.spawnCount ? this.dataList.length : this.spawnCount;
         // let actualCount = this.dataList.length;
         if (this.itemHeight > 0) {
@@ -42,7 +41,6 @@ class ListViewAdapter {
             itemScript.updateItem(this.dataList[i], i);
             this.scriptItems.push(itemScript);
         }
-        console.log('bufferZone'+this.bufferZone);
     }
 
     getPositionInView(item) { // get item position in scrollview's node space

+ 8 - 4
assets/Script/Rank/RankItem.js

@@ -36,11 +36,15 @@ cc.Class({
         this.scoreLabel.string = data.score;
         this.nameLabel.string = data.nick;
 
-        cc.loader.loadRes(data.url, cc.SpriteFrame, (error, spriteFrame) => {
-            if (error) {
-
+        cc.loader.load({
+            url: data.url, type: 'jpg'
+        }, (err, texture) => {
+            if (err === undefined || err === null) {
+                success(new cc.SpriteFrame(texture));
             } else {
-                this.avatar.spriteFrame = spriteFrame;
+                cc.loader.loadRes('./textures/default_avatar', cc.SpriteFrame, (err, spriteFrame) => {
+                    success(spriteFrame);
+                })
             }
         });
     }