import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; /** * 封装HttpClient,主要解决: * + 优化HttpClient在参数上便利性 * + 统一实现 loading * + 统一处理时间格式问题 */ export declare class BaseHttpService { protected _httpClient: HttpClient; protected _loading: boolean; constructor(httpClient: HttpClient); setHttpClient(httpClient: HttpClient): void; /** 是否正在加载中 */ readonly loading: boolean; parseParams(params: any): HttpParams; appliedUrl(url: string, params?: any): string; begin(): void; end(): void; /** * GET:返回一个 `T` 类型 */ get(url: string, params?: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body'; reportProgress?: boolean; responseType: 'json'; withCredentials?: boolean; }): Observable; /** * GET:返回一个 `string` 类型 */ get(url: string, params: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable; /** * GET:返回一个 `JSON` 类型 */ get(url: string, params: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable>; /** * GET:返回一个 `JSON` 类型 */ get(url: string, params: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable>; /** * GET:返回一个 `any` 类型 */ get(url: string, params?: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * POST:返回一个 `string` 类型 */ post(url: string, body: any, params: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable; /** * POST:返回一个 `JSON` 类型 */ post(url: string, body: any, params: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable>; /** * POST:返回一个 `JSON` 类型 */ post(url: string, body?: any, params?: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable; /** * POST:返回一个 `any` 类型 */ post(url: string, body?: any, params?: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * DELETE:返回一个 `string` 类型 */ delete(url: string, params: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable; /** * POST:返回一个 `JSON` 类型 */ delete(url: string, params: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable>; /** * POST:返回一个 `any` 类型 */ delete(url: string, params?: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * `jsonp` 请求 * * @param {string} url URL地址 * @param {*} [params] 请求参数 * @param {string} [callbackParam] CALLBACK值,默认:JSONP_CALLBACK */ jsonp(url: string, params?: any, callbackParam?: string): Observable; /** * `patch` 请求 * * @param {string} url URL地址 * @param {*} [body] 请求参数 */ patch(url: string, body?: any, params?: any): Observable; /** * `put` 请求 * * @param {string} url URL地址 * @param {*} [body] 请求参数 */ put(url: string, body?: any, params?: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * `request` 请求 * * @param {string} method 请求方法类型 * @param {string} url URL地址 * @param {*} [options] 参数 */ request(method: string, url: string, options?: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body' | 'events' | 'response'; params?: HttpParams | { [param: string]: string | string[]; }; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; reportProgress?: boolean; withCredentials?: boolean; }): Observable; }