123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- import Http from "../utils/Http";
- export interface PogResp {
- protocolId: number;
- requestId: number;
- code: number;
- success: boolean;
- data: any;
- msg: string;
- }
- export interface PogLoginResp {
- token: string;
- expire: number;
- wsUrl: string;
- }
- export class ConfigGood {
- id: number;
- name: string;
- desc: string;
- type: number;
- param1: any;
- param2: any;
- param3: any;
- param4: any;
- }
- export class ConfigShopItem {
- id: number;
- goodId: number;
- num: number;
- storeId: number;
- usdPrice: number;
- diamondPrice: number;
- adPrice: number;
- total: number;
- dailyUserLimit: number;
- userLimit: number;
- userAdLimit: number;
- dailyUserAdLimit: number;
- sort: number;
- expireTime: number | null;
- }
- export class ConfigStore {
- id: number;
- name: string;
- shopList: ConfigShopItem[];
- }
- export class ConfigRecharge {
- id: number;
- usd: number;
- diamonds: number;
- extraDiamonds: number;
- tgStars: number;
- goodList: number[];
- numList: number[];
- bonusList: number[];
- bonusNumList: number[];
- firstRechargeList: number[];
- firstRechargeNumList: number[];
- }
- export class Config {
- goodList: ConfigGood[];
- storeList: ConfigStore[];
- rechargeList: ConfigRecharge[];
- }
- export default class PogHttp {
- getPogBoosterList() {
- let a = [];
- for (let i = 1; i <= 10; i++) {
- a.push({
- id: i,
- usdt: 9.9 * i,
- times: i * 3,
- });
- }
- return a;
- }
- private static readonly client = "YbVHPrXS";
- private static readonly HTTP_HEAD = "https://zombies.telgather.com/platform";
- private static _ins: PogHttp;
- private _protocolId: number;
- public static get ins(): PogHttp {
- return this._ins || new PogHttp();
- }
- public async _apiRequest(path: string, params: any): Promise<any> {
- const headers = {
- client: PogHttp.client,
- };
- const resp = await Http.get(PogHttp.HTTP_HEAD + path, params, headers);
- const pogResp = resp as PogResp;
- if (pogResp.code !== 200) {
- return null;
- }
- if (pogResp.protocolId > 0) {
- this._protocolId = pogResp.protocolId;
- }
- return pogResp.data;
- }
- public async loginByWalletAddress(address: string): Promise<PogLoginResp> {
- const path = "/pog-service/login/wallet";
- const res = await this._apiRequest(path, { address });
- return res;
- }
- async loginByTgParams(
- initDataRaw: string,
- tgWebAppStartParam: string
- ): Promise<PogLoginResp> {
- const path = "/pog-service/login/wallet";
- const res = await this._apiRequest(path, {
- params: initDataRaw,
- inviteCode: tgWebAppStartParam,
- });
- return res;
- }
- async allConfig(): Promise<Config> {
- const path = "/pog-service/login/config";
- const res = await this._apiRequest(path, {});
- return res;
- }
- }
|