| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- // Learn cc.Class:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
- // Learn Attribute:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
- window.userData = {
- httpData : {
- data: {
- avatarUrl: "https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83eohXLEIOV99ic2JosrQDgIgL4cU4ZlmmvkWzGpygkNV9aEJ6nCC2mVf4kYBDHogNOHgXo2wZhv85jA/132",
- city: "Harbin",
- gender: 1,
- nickName: "汪汪Husky",
- openid: "oGxOa5SQ1ltBWWsVRirUvXUBGRRY",
- province: "Heilongjiang",
- id : 0
- },
- },
- // oGxOa5bd61v9jI_indIdQtI2T5P8 大佬
- // oGxOa5bjKLaCSbkPev09yVze0WSA 晓明
- // oGxOa5del9BkzJ3e8fLVzI4mlvEI 小狐仙
- // oGxOa5eZUuWCNCoEUQIjtu2uN9BM 9527
- // oGxOa5SQ1ltBWWsVRirUvXUBGRRY 汪汪
- openId: "oGxOa5SQ1ltBWWsVRirUvXUBGRRY"
- }
- cc.Class({
- extends: cc.Component,
- properties: {
- // foo: {
- // // ATTRIBUTES:
- // default: null, // The default value will be used only when the component attaching
- // // to a node for the first time
- // type: cc.SpriteFrame, // optional, default is typeof default
- // serializable: true, // optional, default is true
- // },
- // bar: {
- // get () {
- // return this._bar;
- // },
- // set (value) {
- // this._bar = value;
- // }
- // },
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- 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;
- // userData.httpData.data.id = parseInt(message.id);
- this.getRankingchao();
- break;
- case "Whoareme":
- userData.openId = message.openId;
- // userData.httpData.data.id = parseInt(message.id);
- this.getRanking();
- break;
- }
- }
- }.bind(this));
- }else{
- this.showFriend();
- // this.getRanking();
- }
- },
- 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();
- },
- getIndex : function (openId) {
- },
- 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 (this.myCurr == null) {
- // this.myCurr = i;oGxOa5SQ1ltBWWsVRirUvXUBGRRY
- // }else{
- // // console.log("原来名次",this.myCurr);
- // // console.log("当前名次",i);
- // //当前名次 无变动
- // if (i-this.myCurr == 0) {
- // // console.log("当前名次",i,"排名无变动",this.myCurr);
- // }else if (i-this.myCurr < 0 ) {
- // // console.log("当前名次",i,"排名超越","被超越的索引是",this.myCurr);
- // // console.log("当前名次数据是",list[i],"排名超越","被超越的索引是",list[this.myCurr]);
- //
- // this.Display.getComponent("launch").Transcendfun(list[i],list[this.myCurr]);
- // }else if (i-this.myCurr > 0 ) {
- // // console.log("当前名次",i,"排名下降");
- // }
- // //播放动画
- //
- //
- // this.myCurr = i;
- // }
- // console.log("超越4",this.ischao,list[i],i - 1);
- if (i - 1 >= 0) {
- // console.log("我前面的数据",list[i-1],"我的数据",list[i]);
- // if (list[i - 1].id - list[i].id <= 15000) {
- this.Display.getComponent("launch").curr(list[i-1]);
- // }
- }
- },
- getCurr : function (i,list) {
- this.Display.getComponent("launch").getCurrs(i,list);
- },
- // update (dt) {},
- });
|