GameConst.ts 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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/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_common: any = null;
  56. /**打开配置 */
  57. public static config_clockIn: any = null;
  58. /**关卡配置 */
  59. public static config_level: any = null;
  60. /**提现配置 */
  61. public static config_cashOut: any = null;
  62. /**方块的icon index */
  63. public static iconIndex: number = 6;
  64. public static maxIconIndex: number = 2;
  65. //缓存数据-----------------------------------------------------------------
  66. //游戏数据------------------------------------------------------------------
  67. /**纵列 */
  68. public static col_num: number = 8;
  69. /**横列 */
  70. public static row_num: number = 8;
  71. /**加载配置 */
  72. public static loadConfig(): Promise<any> {
  73. return new Promise((resolve, reject) => {
  74. GameConst.res_dirArr.forEach(element => {
  75. cc.resources.loadDir(element, function (completedCount, totalCount, item) {
  76. // Loading.curloadedNum++;
  77. }, () => {
  78. GameConst.config_common = (cc.resources.get(`game/config/common`) as cc.JsonAsset).json;
  79. GameConst.config_clockIn = (cc.resources.get(`game/config/clockIn`) as cc.JsonAsset).json;
  80. GameConst.config_level = (cc.resources.get(`game/config/level`) as cc.JsonAsset).json;
  81. GameConst.config_cashOut = (cc.resources.get(`game/config/cashOut`) as cc.JsonAsset).json;
  82. // console.log("GameConst.config_common", GameConst.config_common);
  83. resolve(null);
  84. });
  85. });
  86. })
  87. // GameConst.clockInConfig = cc.loader.getRes("config/clockInConfig.json").json;
  88. // LogUtil.log("GameConst.clockInConfig", GameConst.clockInConfig);
  89. }
  90. /**解析配置 */
  91. public static getConfig() {
  92. }
  93. /**获取appid */
  94. public static getAppid() {
  95. if (cc.sys.platform == cc.sys.WECHAT_GAME) {
  96. GameConst.appid = GameConst.miniGame_wx_appid;
  97. }
  98. else {
  99. if (cc.sys.os == cc.sys.OS_ANDROID) {
  100. GameConst.appid = GameConst.app_wx_appid;
  101. }
  102. else if (cc.sys.os == cc.sys.OS_IOS) {
  103. }
  104. }
  105. }
  106. //安卓设备数据------------------------------------------------------------------
  107. /** 投放渠道 1 巨量 2 快手 3 广点通 */
  108. public static advertisingChannel = 1;
  109. /**NADROID id */
  110. public static android_id = "";
  111. /**idfa */
  112. public static idfa = "";
  113. /**imei */
  114. public static imei = "";
  115. /**mac */
  116. public static mac = "";
  117. /**oaid */
  118. public static oaid = "";
  119. /**umid */
  120. public static umid = "";
  121. /** 友盟渠道 */
  122. public static umengChannel = 'ttaxx_juliang';
  123. /** 设备型号 */
  124. public static deviceType = 'Android';
  125. /** 安卓版本号 */
  126. public static androidVersion = '';
  127. /** app版本号 */
  128. public static appVersion = '';
  129. /** 投放渠道号 */
  130. public static tf_channel = 'juliang';
  131. /** 设备信息字段 */
  132. public static deviceInfo = null
  133. /**更新设备信息(根据AS) */
  134. public static updateDeviceInfo(info: any) {
  135. let arr = info.split('#')
  136. GameConst.android_id = arr[0]
  137. GameConst.idfa = arr[1]
  138. GameConst.imei = arr[2]
  139. GameConst.mac = arr[3]
  140. GameConst.oaid = arr[4]
  141. GameConst.umid = arr[5]
  142. GameConst.tf_channel = arr[6]
  143. GameConst.appVersion = arr[7]
  144. /** 友盟渠道 */
  145. GameConst.umengChannel = arr[8]
  146. /** 设备型号 */
  147. GameConst.deviceType = arr[9]
  148. /** 安卓版本号 */
  149. GameConst.androidVersion = arr[10]
  150. mk.console.log(`updateDeviceInf:
  151. android_id=${GameConst.android_id}; idf=${GameConst.idfa}; imei=${GameConst.imei};mac=${GameConst.mac};oaid=${GameConst.oaid};
  152. umid=${GameConst.umid};tf_channel=${this.tf_channel};appVersion=${this.appVersion};umengChannel=${this.umengChannel};
  153. deviceType=${this.deviceType};androidVersion=${this.androidVersion}`);
  154. GameConst.deviceInfo = {
  155. "android_id": GameConst.android_id,
  156. "idfa": GameConst.idfa,
  157. "imei": GameConst.imei,
  158. "mac": GameConst.mac,
  159. "oaid": GameConst.oaid,
  160. "umid": GameConst.umid
  161. }
  162. // HttpMgr.Inst.updateGameVersion(GameConst.appVersion);
  163. // HttpMgr.Inst.updateDeviceInfo(GameConst.deviceInfo)
  164. }
  165. }