| | |
| | | import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; |
| | | import { IRequest, BlLifeRechargeServicesOptions } from './types'; |
| | | import { BlLifeRechargeServicesOptions } from './types'; |
| | | import { LifeRechargeConstants } from './lifeRechargeConstants'; |
| | | import { Request, IRequest } from 'senior-request'; |
| | | |
| | | export interface RequestConfig {} |
| | | |
| | | export class BlLifeRechargeServices<T extends IRequest> { |
| | | private request: T; |
| | | request2: T; |
| | | constructor({ request, axiosOptions }: BlLifeRechargeServicesOptions<T>) { |
| | | this.request = request; |
| | | const axiosInstance = axios.create(axiosOptions); |
| | | // @ts-expect-error |
| | | this.request2 = (url: string, opts: any = { method: 'GET' }) => { |
| | | return new Promise((resolve, reject) => { |
| | | axiosInstance |
| | | .request({ ...opts, url }) |
| | | .then((res) => { |
| | | //@ts-ignore |
| | | resolve(res); |
| | | }) |
| | | .catch((error) => { |
| | | try { |
| | | // const handler = config?.errorConfig?.errorHandler; |
| | | // if (handler) { |
| | | // handler(error, opts, config); |
| | | // } |
| | | } catch (e) { |
| | | reject(e); |
| | | } |
| | | reject(error); |
| | | }); |
| | | }); |
| | | }; |
| | | export class BlLifeRechargeServices<TResponse = any, TRequestOptions = any> { |
| | | private request: IRequest; |
| | | constructor({ axiosConfig }: BlLifeRechargeServicesOptions<TResponse, TRequestOptions>) { |
| | | this.request = Request.create(axiosConfig); |
| | | } |
| | | |
| | | async lifePayPhoneMesssageCodeLogin(body: PhoneMesssageCodeLoginInput, options?: RequestConfig) { |
| | |
| | | /** 获取折扣 GET /api/LifePay/GetRate */ |
| | | async getRate(options?: RequestConfig) { |
| | | return this.request<LifePayRateListOutput[]>('/api/LifePay/GetRate', { |
| | | method: 'GET', |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** 获取电费充值区域 GET /api/LifePay/GetElectricSupportArea */ |
| | | async getElectricSupportArea(options?: RequestConfig) { |
| | | return this.request<ElectricSupportAreaResponse>('/api/LifePay/GetElectricSupportArea', { |
| | | method: 'GET', |
| | | ...(options || {}), |
| | | }); |
| | |
| | | refundTime?: string; |
| | | } |
| | | |
| | | export interface ElectricSupportAreaResponse { |
| | | success?: boolean; |
| | | requestNo?: string; |
| | | partnerId?: string; |
| | | service?: string; |
| | | version?: string; |
| | | protocol?: string; |
| | | context?: string; |
| | | ext?: any; |
| | | code?: string; |
| | | message?: string; |
| | | detail?: string; |
| | | electricAreaList?: ElectricSupportAreaListOutput[]; |
| | | } |
| | | |
| | | export interface ElectricSupportAreaListOutput { |
| | | childCityList?: ElectricSupportAreaChildCityListOutput[]; |
| | | cityName?: string; |
| | | cityParentId?: string; |
| | | ciytId?: string; |
| | | electricType?: string; |
| | | parValue?: string[]; |
| | | rate?: number; |
| | | } |
| | | |
| | | export interface ElectricSupportAreaChildCityListOutput { |
| | | cityName?: string; |
| | | cityParentId?: string; |
| | | ciytId?: string; |
| | | } |
| | | export interface APIgetLifePayWxIndentityParams { |
| | | /** 用户登录凭证 */ |
| | | code?: string; |