import { HttpMethod } from "@/enum/HttpMethod" export class RequestHeaders { isToken : boolean = false isEncrypt : boolean = false repeatSubmit : boolean = false constructor() { } } export class RequestConfig { // 请求地址(API URL) url : string = "" // HTTP 请求方法 method ?: HttpMethod = HttpMethod.GET // 请求参数 data ?: any = null // 请求头 headers ?: RequestHeaders = new RequestHeaders() // Query参数(GET) params ?: any = null // 请求超时时间(毫秒) timeout ?: number = 15000 // 是否显示加载提示 loading ?: boolean = true // 请求失败时是否显示错误提示 showError ?: boolean = true constructor() { } } export class ApiResponse { code : number = 0 msg : string = "" data : T | null = null constructor() { } } export class HttpException { code : number message : string constructor( code : number, message : string ) { this.code = code this.message = message } } export class LoadingManager { private static count : number = 0 static show() { this.count++ if (this.count == 1) { uni.showLoading({ title: "加载中", mask: true }) } } static hide() { if (this.count <= 0) { return } this.count-- if (this.count == 0) { uni.hideLoading() } } static getCount() : number { return this.count } static reset() { this.count = 0 uni.hideLoading() } }