GameConst.ts 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. public static url_sharePic: string = "";
  23. /**资源文件夹 */
  24. public static res_dirArr = ["game/config"];
  25. public static url_resOss: string = "";
  26. //其他数据--------------------------------------------------------------
  27. /**是否登陆结束 */
  28. public static ifLoginFinished: boolean = false;
  29. /**是否是新玩家 */
  30. public static isNew: boolean = true;
  31. /**是否授权 */
  32. public static isAuth: boolean = false;
  33. //OSS配置数据----------------------------------------------------------------
  34. /**通用配置 */
  35. public static config_common: any = null;
  36. /**打开配置 */
  37. public static config_clockIn: any = null;
  38. /**关卡配置 */
  39. public static config_level: any = null;
  40. /**提现配置 */
  41. public static config_cashOut: any = null;
  42. /**方块的icon index */
  43. public static iconIndex: number = 6;
  44. public static maxIconIndex: number = 2;
  45. //缓存数据-----------------------------------------------------------------
  46. //游戏数据------------------------------------------------------------------
  47. /**纵列 */
  48. public static col_num: number = 8;
  49. /**横列 */
  50. public static row_num: number = 8;
  51. /**加载配置 */
  52. public static loadConfig(): Promise<any> {
  53. return new Promise((resolve, reject) => {
  54. GameConst.res_dirArr.forEach(element => {
  55. cc.resources.loadDir(element, function (completedCount, totalCount, item) {
  56. // Loading.curloadedNum++;
  57. }, () => {
  58. GameConst.config_common = (cc.resources.get(`game/config/common`) as cc.JsonAsset).json;
  59. GameConst.config_clockIn = (cc.resources.get(`game/config/clockIn`) as cc.JsonAsset).json;
  60. GameConst.config_level = (cc.resources.get(`game/config/level`) as cc.JsonAsset).json;
  61. GameConst.config_cashOut = (cc.resources.get(`game/config/cashOut`) as cc.JsonAsset).json;
  62. console.log("GameConst.config_common", GameConst.config_common);
  63. resolve(null);
  64. });
  65. });
  66. })
  67. // GameConst.clockInConfig = cc.loader.getRes("config/clockInConfig.json").json;
  68. // LogUtil.log("GameConst.clockInConfig", GameConst.clockInConfig);
  69. }
  70. /**解析配置 */
  71. public static getConfig() {
  72. }
  73. /**获取appid */
  74. public static getAppid() {
  75. if (cc.sys.platform == cc.sys.WECHAT_GAME) {
  76. GameConst.appid = GameConst.miniGame_wx_appid;
  77. }
  78. else {
  79. if (cc.sys.os == cc.sys.OS_ANDROID) {
  80. GameConst.appid = GameConst.app_wx_appid;
  81. }
  82. else if (cc.sys.os == cc.sys.OS_IOS) {
  83. }
  84. }
  85. }
  86. //安卓设备数据------------------------------------------------------------------
  87. /** 投放渠道 1 巨量 2 快手 3 广点通 */
  88. public static advertisingChannel = 1;
  89. /**NADROID id */
  90. public static android_id = "";
  91. /**idfa */
  92. public static idfa = "";
  93. /**imei */
  94. public static imei = "";
  95. /**mac */
  96. public static mac = "";
  97. /**oaid */
  98. public static oaid = "";
  99. /**umid */
  100. public static umid = "";
  101. /** 友盟渠道 */
  102. public static umengChannel = 'ttaxx_juliang';
  103. /** 设备型号 */
  104. public static deviceType = 'Android';
  105. /** 安卓版本号 */
  106. public static androidVersion = '';
  107. /** app版本号 */
  108. public static appVersion = '';
  109. /** 投放渠道号 */
  110. public static tf_channel = 'juliang';
  111. /** 设备信息字段 */
  112. public static deviceInfo = null
  113. /**更新设备信息(根据AS) */
  114. public static updateDeviceInfo(info: any) {
  115. let arr = info.split('#')
  116. GameConst.android_id = arr[0]
  117. GameConst.idfa = arr[1]
  118. GameConst.imei = arr[2]
  119. GameConst.mac = arr[3]
  120. GameConst.oaid = arr[4]
  121. GameConst.umid = arr[5]
  122. GameConst.tf_channel = arr[6]
  123. GameConst.appVersion = arr[7]
  124. /** 友盟渠道 */
  125. GameConst.umengChannel = arr[8]
  126. /** 设备型号 */
  127. GameConst.deviceType = arr[9]
  128. /** 安卓版本号 */
  129. GameConst.androidVersion = arr[10]
  130. mk.console.log(`updateDeviceInf:
  131. android_id=${GameConst.android_id}; idf=${GameConst.idfa}; imei=${GameConst.imei};mac=${GameConst.mac};oaid=${GameConst.oaid};
  132. umid=${GameConst.umid};tf_channel=${this.tf_channel};appVersion=${this.appVersion};umengChannel=${this.umengChannel};
  133. deviceType=${this.deviceType};androidVersion=${this.androidVersion}`);
  134. GameConst.deviceInfo = {
  135. "android_id": GameConst.android_id,
  136. "idfa": GameConst.idfa,
  137. "imei": GameConst.imei,
  138. "mac": GameConst.mac,
  139. "oaid": GameConst.oaid,
  140. "umid": GameConst.umid
  141. }
  142. // HttpMgr.Inst.updateGameVersion(GameConst.appVersion);
  143. // HttpMgr.Inst.updateDeviceInfo(GameConst.deviceInfo)
  144. }
  145. }