UNPKG

yg-tools

Version:

some convenient APIs and Methods for Youngon

177 lines (176 loc) 4.22 kB
export interface HttpRequestOption extends Record<string, any> { url: string; data?: Record<string, any> | string | ArrayBuffer; header?: Record<string, any>; method: 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT'; dataType?: 'json' | '其他'; responseType?: 'text' | 'arraybuffer'; success?: (res: any) => void; fail?: (res: any) => void; complete?: (res: any) => void; } export interface HttpResponseOption extends Record<string, any> { status: string | boolean; resdata?: any; openid?: string; error?: string; title?: string; message?: string; msg?: string; Rcode?: string; count?: number; imgurl?: string; head?: string; } export interface HttpResponseOptionWrapper<T> extends Record<string, any> { data: T; } export interface APIContext<R extends HttpResponseOptionWrapper<HttpResponseOption> = HttpResponseOptionWrapper<HttpResponseOption>> extends Record<string, any> { request: (options: HttpRequestOption) => Promise<R>; showToast: Function; login: Function; switchTab: Function; getStorageSync: Function; setStorageSync: Function; removeStorageSync: Function; clearStorageSync: Function; } export interface IGlobalConfig<R extends HttpResponseOptionWrapper<HttpResponseOption> = HttpResponseOptionWrapper<HttpResponseOption>> { /** * 上下文环境 * 小程序中可以是 wx | my | qq | dd | tt | swan | Taro | uni */ context: APIContext<R>; /** * api 域名 */ baseUrl: string; /** * 接口 token */ authToken: string; /** * 小程序首页地址 */ mpIndexPath: string; /** * 小程序帐号设置页面地址 */ mpAccountPath: string; /** * 全局接口错误处理 */ globalAPIErrorHandle: (msg: string, err?: any) => void; /** * 处理 request 请求响应 */ handleResponse: (rs: HttpResponseOptionWrapper<HttpResponseOption> | HttpResponseOption) => HttpResponseOption; } export declare type DutyInfo = { stuid: string | number; name: string; week: number[]; class: number[]; dutydate: string[]; head: string[]; duty?: { week: number; class: number; }[]; }; export interface OrgInfo { id: string; desc: string; logo: string; splogo: string; name: string; title: string; enName: string; process: { desc: string; title: string; status: { id: string; content: string; }[]; }[]; bannerImg: string[]; accessTime: { day: { end: number; start: number; }; month: number; }[]; department: { desc: string; icon: string; name: string; tags: string[]; extra: string; title: string; enName: string; }[]; contactType: { email: string; weChat: string; qqGroup: string; qqGroupNum: string; }; contactExtra: { img: string; text: string; subtext: string; }[]; videoIntroduce: { aid: number; cid: number; bvid?: string; page: number; title: string; }[]; historyTimeLine: string[]; mobileBannerImg: string[]; /** * 海报 地址 */ posterImage: string[]; /** * iYou 小程序 Primary Banner */ iYouMPPBImg: string[]; /** * 社团文化 */ organizationCulture: string; } export interface OrgNeedInfo { field: string; value: any; disabled?: boolean; fieldDesc: string; valueType: string; isRequired: boolean; row?: boolean; options?: { text: any; value: any; }[] | { text: { field: string; fieldText: string; }[]; textarea: { field: string; fieldText: string; }[]; }; mode?: string; maxTagCount?: number; notFoundContent?: string; } export interface Window extends Record<string, any> { } export interface ClassType<T> { new (...args: any[]): T; }