Global.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. if (CC_WECHATGAME) {
  11. window.Global = {
  12. //Urls
  13. loginUrl: 'https://test-api-pudding.duowan.com/auth/loginByGame.do',//登录
  14. getUserRecordUrl: 'https://test-api-pudding.duowan.com/user/getUserRecord.do',//获取用户信息
  15. reportUrl: 'http://test-api-pudding.duowan.com/user/report.do',//上报分数
  16. getAllRankListUrl: 'https://test-api-pudding.duowan.com/user/getAllRankList.do',//获取全服排行榜
  17. useReviveUrl: 'https://test-api-pudding.duowan.com/user/useRevive.do',//使用复活
  18. addReviveUrl: 'https://test-api-pudding.duowan.com/user/addRevive.do',//添加复活
  19. validateUrl: 'https://test-api-pudding.duowan.com/user/validate.do',//校验分数、复活卡
  20. //SystemInfo
  21. ver: 100,
  22. os: 1,
  23. channel: "wexin",
  24. //userInfo
  25. user: null,
  26. // user = {
  27. // token:data.token,
  28. // uid:user.id,
  29. // openId:user.openId,
  30. // nick:userInfo.nickName,
  31. // avatarUrl:userInfo.avatarUrl,
  32. // gender:userInfo.gender,
  33. // gold:user.coin,
  34. // score:user.score,
  35. // revivedCount:0
  36. // };
  37. showLoginPage: true
  38. };
  39. wx.onShow(res => {
  40. wx.checkSession({
  41. success: function () {
  42. //session_key 未过期,并且在本生命周期一直有效
  43. },
  44. fail: function () {
  45. // session_key 已经失效,需要重新执行登录流程
  46. Global.showLoginPage = true;
  47. cc.director.loadScene("GameScene");
  48. }
  49. })
  50. });
  51. }