window.userData = { httpData: { data: { avatarUrl: "", city: "Harbin", gender: 1, nickName: "", openid: "oGxOa5SQ1ltBWWsVRirUvXUBGRRY", province: "Heilongjiang", id: 0 }, }, // oGxOa5bd61v9jI_indIdQtI2T5P8 大佬 // oGxOa5bjKLaCSbkPev09yVze0WSA 晓明 // oGxOa5del9BkzJ3e8fLVzI4mlvEI 小狐仙 // oGxOa5eZUuWCNCoEUQIjtu2uN9BM 9527 // oGxOa5SQ1ltBWWsVRirUvXUBGRRY 汪汪 openId: "oGxOa5SQ1ltBWWsVRirUvXUBGRRY", ranking: 0, } cc.Class({ extends: cc.Component, properties: { }, start() { this.Display = UtilsPrefabs.getNode("layout", this.node); // this.Display = UtilsPrefabs.getNode("Display",this.node); if (cc.sys.platform === cc.sys.WECHAT_GAME) { wx.onMessage(function (data) { if (data.message != null) { var message = data.message; // console.log("主域 过来的数据",data.message); switch (message.name) { case "showFriend": this.showFriend(); break; case "hideFriend": this.hideFriend(); break; case "Whoareyou": userData.openId = message.openId; this.getRankingchao(); break; case "Whoareme": userData.openId = message.openId; this.getRanking(); break; } } }.bind(this)); } else { this.showFriend(); } }, showFriend: function () { this.Display.getChildByName("Display").active = true; this.Display.getComponent("launch").getFriend(); }, hideFriend: function () { this.Display.getChildByName("Display").active = false; this.Display.getComponent("launch").removeAll(); }, getRanking: function () { this.Display.getComponent("launch").getRanking(function (list) { //添加排行榜为 自己的条目在下面 // console.log("我在统计数组1",list,userData.openId); for (var i = 0; i < list.length; i++) { // console.log("我在统计数组2",list,userData.openId); if (list[i].openId == userData.openId) { // console.log("我在统计数组3",list,userData.openId); //超越 // this.curr(i,list); //找排名前后的两人 this.getCurr(i, list); } } }.bind(this)); }, getRankingchao: function () { this.ischao = true; this.Display.getComponent("launch").getRanking(function (list) { //添加排行榜为 自己的条目在下面 // console.log("超越1",this.ischao,list); if (this.ischao) { this.ischao = false; // console.log("超越2",this.ischao,list); for (var i = 0; i < list.length; i++) { if (list[i].openId == userData.openId) { // console.log("超越3",this.ischao,list); //超越 this.curr(i, list); } } } }.bind(this)); }, curr: function (i, list) { if (i - 1 >= 0) { this.Display.getComponent("launch").curr(list[i - 1]); } }, getCurr: function (i, list) { this.Display.getComponent("launch").getCurrs(i, list); }, });