1
0

Init.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const weChat = require('./net/WeChat');
  2. const DWTool = require('./utils/DWTool');
  3. const Api = require('./net/Api');
  4. // const Ws = require('./net/Ws');
  5. cc.Class({
  6. extends: cc.Component,
  7. properties: {
  8. game: cc.Node,
  9. },
  10. // LIFE-CYCLE CALLBACKS:
  11. onLoad() {
  12. // Ws.open();
  13. // setTimeout(() => {
  14. // Ws.emit('fuck', 111)
  15. // }, 2000)
  16. // Ws.on('getFuck', data => {
  17. // console.log(data);
  18. // })
  19. if (!CC_WECHATGAME) {
  20. Global.showLoginPage = false;
  21. Global.channel = 'LuciferChannel';
  22. Global.os = 1;
  23. Global.ver = 1;
  24. let uid = DWTool.getUrlParam('uid');
  25. let token = DWTool.getUrlParam('token');
  26. if(!uid && !token) {
  27. Global.user = {
  28. uid: 1,
  29. token: 'lucifer_test_token',
  30. nick: 'lucifer',
  31. avatar: "",
  32. gender: 1
  33. }
  34. } else {
  35. Global.user = {
  36. uid: uid,
  37. token: token,
  38. nick: "游客",
  39. avatar: "",
  40. gender: 1
  41. }
  42. }
  43. } else {
  44. switch (cc.sys.platform) {
  45. case cc.sys.WECHAT_GAME:
  46. Global.channel = 'weixin';
  47. break;
  48. case cc.sys.QQ_PLAY:
  49. Global.channel = 'qq';
  50. break;
  51. }
  52. }
  53. this.game.active = true;
  54. if(CC_WECHATGAME) {
  55. cc.game.setFrameRate(40); // 微信环境下强制游戏改为40帧的方法
  56. }
  57. console.log("Global: " + Global.channel);
  58. },
  59. start() {
  60. },
  61. // update (dt) {},
  62. });