friendContent.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. // foo: {
  14. // // ATTRIBUTES:
  15. // default: null, // The default value will be used only when the component attaching
  16. // // to a node for the first time
  17. // type: cc.SpriteFrame, // optional, default is typeof default
  18. // serializable: true, // optional, default is true
  19. // },
  20. // bar: {
  21. // get () {
  22. // return this._bar;
  23. // },
  24. // set (value) {
  25. // this._bar = value;
  26. // }
  27. // },
  28. },
  29. // LIFE-CYCLE CALLBACKS:
  30. onLoad () {
  31. if (window.wx != undefined) {
  32. // window.wx.postMessage({
  33. // messageType: 1,
  34. // MAIN_MENU_NUM: "score",
  35. // });
  36. window.wx.onMessage(data => {
  37. console.log("主项目接收主域发来消息:", data)
  38. if (data.messageType == 0) {//移除排行榜
  39. this.removeChild();
  40. } else if (data.messageType == 1) {//获取好友排行榜
  41. this.fetchFriendData(data.MAIN_MENU_NUM);
  42. } else if (data.messageType == 3) {//提交得分
  43. this.submitScore(data.MAIN_MENU_NUM, data.score);
  44. } else if (data.messageType == 4) {//获取好友排行榜横向排列展示模式
  45. this.gameOverRank(data.MAIN_MENU_NUM);
  46. } else if (data.messageType == 5) {//获取群排行榜
  47. this.fetchGroupFriendData(data.MAIN_MENU_NUM, data.shareTicket);
  48. } else if (data.messageType == 6) {
  49. this.previousPage();
  50. } else if (data.messageType == 7) {
  51. this.nextPage();
  52. }
  53. });
  54. } else {
  55. // this.fetchFriendData(1000);
  56. // this.gameOverRank(1000);
  57. }
  58. },
  59. start () {
  60. },
  61. // update (dt) {},
  62. });