PogHttp.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import Http from "../utils/Http";
  2. export interface PogResp {
  3. protocolId: number;
  4. requestId: number;
  5. code: number;
  6. success: boolean;
  7. data: any;
  8. msg: string;
  9. }
  10. export interface PogLoginResp {
  11. token: string;
  12. expire: number;
  13. wsUrl: string;
  14. }
  15. export class ConfigGood {
  16. id: number;
  17. name: string;
  18. desc: string;
  19. type: number;
  20. param1: any;
  21. param2: any;
  22. param3: any;
  23. param4: any;
  24. }
  25. export class ConfigShopItem {
  26. id: number;
  27. goodId: number;
  28. num: number;
  29. storeId: number;
  30. usdPrice: number;
  31. diamondPrice: number;
  32. adPrice: number;
  33. total: number;
  34. dailyUserLimit: number;
  35. userLimit: number;
  36. userAdLimit: number;
  37. dailyUserAdLimit: number;
  38. sort: number;
  39. expireTime: number | null;
  40. }
  41. export class ConfigStore {
  42. id: number;
  43. name: string;
  44. shopList: ConfigShopItem[];
  45. }
  46. export class ConfigRecharge {
  47. id: number;
  48. usd: number;
  49. diamonds: number;
  50. extraDiamonds: number;
  51. tgStars: number;
  52. goodList: number[];
  53. numList: number[];
  54. bonusList: number[];
  55. bonusNumList: number[];
  56. firstRechargeList: number[];
  57. firstRechargeNumList: number[];
  58. }
  59. export class Config {
  60. goodList: ConfigGood[];
  61. storeList: ConfigStore[];
  62. rechargeList: ConfigRecharge[];
  63. }
  64. export default class PogHttp {
  65. getPogBoosterList() {
  66. let a = [];
  67. for (let i = 1; i <= 10; i++) {
  68. a.push({
  69. id: i,
  70. usdt: 9.9 * i,
  71. times: i * 3,
  72. });
  73. }
  74. return a;
  75. }
  76. private static readonly client = "YbVHPrXS";
  77. private static readonly HTTP_HEAD = "https://zombies.telgather.com/platform";
  78. private static _ins: PogHttp;
  79. private _protocolId: number;
  80. public static get ins(): PogHttp {
  81. return this._ins || new PogHttp();
  82. }
  83. public async _apiRequest(path: string, params: any): Promise<any> {
  84. const headers = {
  85. client: PogHttp.client,
  86. };
  87. const resp = await Http.get(PogHttp.HTTP_HEAD + path, params, headers);
  88. const pogResp = resp as PogResp;
  89. if (pogResp.code !== 200) {
  90. return null;
  91. }
  92. if (pogResp.protocolId > 0) {
  93. this._protocolId = pogResp.protocolId;
  94. }
  95. return pogResp.data;
  96. }
  97. public async loginByWalletAddress(address: string): Promise<PogLoginResp> {
  98. const path = "/pog-service/login/wallet";
  99. const res = await this._apiRequest(path, { address });
  100. return res;
  101. }
  102. async loginByTgParams(
  103. initDataRaw: string,
  104. tgWebAppStartParam: string
  105. ): Promise<PogLoginResp> {
  106. const path = "/pog-service/login/wallet";
  107. const res = await this._apiRequest(path, {
  108. params: initDataRaw,
  109. inviteCode: tgWebAppStartParam,
  110. });
  111. return res;
  112. }
  113. async allConfig(): Promise<Config> {
  114. const path = "/pog-service/login/config";
  115. const res = await this._apiRequest(path, {});
  116. return res;
  117. }
  118. }