GameConst.ts 7.7 KB

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