| | |
| | | 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; |
| | | constructor({ request }: BlLifeRechargeServicesOptions<T>) { |
| | | this.request = request; |
| | | export class BlLifeRechargeServices<TResponse = any, TRequestOptions = any> { |
| | | private request: IRequest; |
| | | constructor({ axiosConfig }: BlLifeRechargeServicesOptions<TResponse, TRequestOptions>) { |
| | | this.request = Request.create({ |
| | | ...axiosConfig, |
| | | // baseURL: process.env.NODE_ENV === 'development' ? '/' : 'https://api.81812333.com', |
| | | timeout: 10 * 1000, |
| | | headers: { |
| | | Accept: 'application/json, text/plain, */*', |
| | | 'Content-Type': 'application/json', |
| | | 'X-Requested-With': 'XMLHttpRequest', |
| | | }, |
| | | withCredentials: true, |
| | | }); |
| | | } |
| | | |
| | | 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 || {}), |
| | | }); |
| | |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** 获取生活缴费用户身份会话信息 GET /api/Account/GetLifePayWxIndentity */ |
| | | async getLifePayWxIndentity( |
| | | // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) |
| | | params: APIgetLifePayWxIndentityParams, |
| | | options?: RequestConfig |
| | | ) { |
| | | return this.request<WxMiniAppIndentityInfo>('/api/Account/GetLifePayWxIndentity', { |
| | | method: 'GET', |
| | | params: { |
| | | ...params, |
| | | }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** 获取微信支付的JSAPI POST /api/LifePay/GetPayOrderForJsAPI */ |
| | | async getPayOrderForJsAPI(body: GetPayOrderForJsAPIInput, options?: RequestConfig) { |
| | | return this.request<ModelPaymentMiniPay>('/api/LifePay/GetPayOrderForJsAPI', { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | } |
| | | |
| | | export interface PhoneMesssageCodeLoginInput { |
| | | /** 手机号 */ |
| | | phoneNumber: string; |
| | | /** 验证码 */ |
| | | code: string; |
| | | // code: string; |
| | | } |
| | | |
| | | export interface LifePayRateListOutput { |
| | |
| | | finishTime?: string; |
| | | /** 订单详细数据 */ |
| | | orderParamDetailJsonStr?: string; |
| | | /** 下单时间 */ |
| | | creationTime?: string; |
| | | /** 退款时间 */ |
| | | 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; |
| | | } |
| | | |
| | | export interface WxMiniAppIndentityInfo { |
| | | /** 会话密钥 */ |
| | | sessionKey?: string; |
| | | /** 小程序OpenId */ |
| | | openId?: string; |
| | | /** 用户名(该值为空则需手机授权登录,不为空则已有该小程序用户) */ |
| | | userName?: string; |
| | | unionId?: string; |
| | | } |
| | | |
| | | export interface GetPayOrderForJsAPIInput { |
| | | orderNo: string; |
| | | lifePayType?: LifeRechargeConstants.LifePayTypeEnum; |
| | | openId?: string; |
| | | attach?: string; |
| | | } |
| | | |
| | | export interface ModelPaymentMiniPay { |
| | | nonceStr?: string; |
| | | package?: string; |
| | | signType?: string; |
| | | paySign?: string; |
| | | timestamp?: string; |
| | | timeExpire?: string; |
| | | message?: string; |
| | | } |