GameConst.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. const { ccclass, property } = cc._decorator;
  2. @ccclass
  3. export default class GameConst extends cc.Component {
  4. //游戏开关------------------------------------------------------------------
  5. /**是否显示广告 (上线前记得打开)*/
  6. public static ifShowAd: boolean = true;
  7. /**是否连接服务器(上线前记得打开) */
  8. public static ifConnectService: boolean = true;
  9. /**是否推送日志 (上线前记得打开) */
  10. public static ifSendEvent: boolean = true;
  11. /**是否显示日志 (上线前记得关闭) */
  12. public static ifShowLog: boolean = true;
  13. //基础数据------------------------------------------------------------------
  14. /**当前的appid */
  15. public static appid: string = "wx28356dc7c541ea76";
  16. /**微信开放平台的appid */
  17. public static app_wx_appid: string = "wx28356dc7c541ea76";
  18. /**小游戏appid */
  19. public static miniGame_wx_appid: string = "";
  20. /**微信的code */
  21. public static wxCode: string = "";
  22. /**服务器地址
  23. * @static 正式地址 https://xx-test.duiweize.com
  24. * @static 测试地址 https://xx-test.duiweize.com
  25. * @static 服务器测试地址 http://172.16.13.93:8952 "http://172.16.13.36:8952"; http://172.16.13.135:8952 172.16.15.85:8952
  26. */
  27. public static url_service: string = " https://xx.duiweize.com";
  28. public static url_sharePic: string = "";
  29. /**资源文件夹 */
  30. public static res_dirArr = ["game/otherGame/config"];
  31. public static url_resOss: string = "";
  32. //其他数据--------------------------------------------------------------
  33. /**是否登陆结束 */
  34. public static ifLoginFinished: boolean = false;
  35. /**是否是新玩家 */
  36. public static isNew: boolean = true;
  37. /**是否授权 */
  38. public static isAuth: boolean = false;
  39. /**本地加密key值 */
  40. public static localEncryptKey: string = "mzmNr2s358irB3WQC3AmGaWMFkMx2HQs";
  41. /**随机Key值 */
  42. public static randomKey: string = "abcdefghijklopqrstuvwxyzabcdefgh";
  43. /**随机Key值(新) */
  44. public static randomKey_new: string = "";
  45. /**玩家的uin Id */
  46. public static uin: string = "";
  47. /**玩家临时的uin Id */
  48. public static tmp_uin: string = "";
  49. /**玩家的session key */
  50. public static session_key: string = "";
  51. /**玩家的login_ticket */
  52. public static login_ticket: string = "";
  53. //OSS配置数据----------------------------------------------------------------
  54. /**关卡配置 */
  55. public static config_level: any = null;
  56. public static configCount: number = 100;
  57. /** 当前关卡配置 100关后开始随机 */
  58. public static curLevelCfg: any = null;
  59. /**方块的icon index */
  60. public static iconIndex: number = 6;
  61. public static maxIconIndex: number = 2;
  62. //缓存数据-----------------------------------------------------------------
  63. //游戏数据------------------------------------------------------------------
  64. /**纵列 */
  65. public static col_num: number = 8;
  66. /**横列 */
  67. public static row_num: number = 8;
  68. /**加载配置 */
  69. public static loadConfig(): Promise<any> {
  70. return new Promise((resolve, reject) => {
  71. GameConst.res_dirArr.forEach(element => {
  72. cc.resources.loadDir(element, function (completedCount, totalCount, item) {
  73. // Loading.curloadedNum++;
  74. }, () => {
  75. GameConst.config_level = (cc.resources.get(`game/otherGame/config/level`) as cc.JsonAsset).json;
  76. resolve(null);
  77. });
  78. });
  79. })
  80. // GameConst.clockInConfig = cc.loader.getRes("config/clockInConfig.json").json;
  81. // LogUtil.log("GameConst.clockInConfig", GameConst.clockInConfig);
  82. }
  83. /**解析配置 */
  84. public static getConfig() {
  85. }
  86. /**获取appid */
  87. public static getAppid() {
  88. if (cc.sys.platform == cc.sys.WECHAT_GAME) {
  89. GameConst.appid = GameConst.miniGame_wx_appid;
  90. }
  91. else {
  92. if (cc.sys.os == cc.sys.OS_ANDROID) {
  93. GameConst.appid = GameConst.app_wx_appid;
  94. }
  95. else if (cc.sys.os == cc.sys.OS_IOS) {
  96. }
  97. }
  98. }
  99. //安卓设备数据------------------------------------------------------------------
  100. /** 投放渠道 1 巨量 2 快手 3 广点通 */
  101. public static advertisingChannel = 1;
  102. /**NADROID id */
  103. public static android_id = "";
  104. /**idfa */
  105. public static idfa = "";
  106. /**imei */
  107. public static imei = "";
  108. /**mac */
  109. public static mac = "";
  110. /**oaid */
  111. public static oaid = "";
  112. /**umid */
  113. public static umid = "";
  114. /** 友盟渠道 */
  115. public static umengChannel = 'ttaxx_juliang';
  116. /** 设备型号 */
  117. public static deviceType = 'Android';
  118. /** 安卓版本号 */
  119. public static androidVersion = '';
  120. /** app版本号 */
  121. public static appVersion = '';
  122. /** 投放渠道号 */
  123. public static tf_channel = 'juliang';
  124. /** 设备信息字段 */
  125. public static deviceInfo = null
  126. /**更新设备信息(根据AS) */
  127. public static updateDeviceInfo(info: any) {
  128. let arr = info.split('#')
  129. GameConst.android_id = arr[0]
  130. GameConst.idfa = arr[1]
  131. GameConst.imei = arr[2]
  132. GameConst.mac = arr[3]
  133. GameConst.oaid = arr[4]
  134. GameConst.umid = arr[5]
  135. GameConst.tf_channel = arr[6]
  136. GameConst.appVersion = arr[7]
  137. /** 友盟渠道 */
  138. GameConst.umengChannel = arr[8]
  139. /** 设备型号 */
  140. GameConst.deviceType = arr[9]
  141. /** 安卓版本号 */
  142. GameConst.androidVersion = arr[10]
  143. mk.console.log(`updateDeviceInf:
  144. android_id=${GameConst.android_id}; idf=${GameConst.idfa}; imei=${GameConst.imei};mac=${GameConst.mac};oaid=${GameConst.oaid};
  145. umid=${GameConst.umid};tf_channel=${this.tf_channel};appVersion=${this.appVersion};umengChannel=${this.umengChannel};
  146. deviceType=${this.deviceType};androidVersion=${this.androidVersion}`);
  147. GameConst.deviceInfo = {
  148. "android_id": GameConst.android_id,
  149. "idfa": GameConst.idfa,
  150. "imei": GameConst.imei,
  151. "mac": GameConst.mac,
  152. "oaid": GameConst.oaid,
  153. "umid": GameConst.umid
  154. }
  155. // HttpMgr.Inst.updateGameVersion(GameConst.appVersion);
  156. // HttpMgr.Inst.updateDeviceInfo(GameConst.deviceInfo)
  157. }
  158. }