| | |
| | | import Taro from '@tarojs/taro'; |
| | | import { VueQueryPlugin, VueQueryPluginOptions } from '@tanstack/vue-query'; |
| | | import { myClient } from '@/constants/query'; |
| | | import { VueLifeRechargePlugin, BlLifeRecharge } from '@life-payment/components'; |
| | | import { VueLifeRechargePlugin } from '@life-payment/components'; |
| | | import { blLifeRecharge } from '@/utils/blLifeRecharge'; |
| | | |
| | | window.uni = Taro; |
| | | |
| | |
| | | }; |
| | | |
| | | App.use(VueQueryPlugin, vueQueryPluginOptions); |
| | | |
| | | const blLifeRecharge = new BlLifeRecharge(); |
| | | |
| | | App.use(VueLifeRechargePlugin, { |
| | | blLifeRecharge, |
New file |
| | |
| | | import { BlLifeRecharge } from '@life-payment/components'; |
| | | import { request } from './request'; |
| | | |
| | | export const blLifeRecharge = new BlLifeRecharge({ |
| | | request, |
| | | }); |
| | |
| | | export class BlLifeRecharge { |
| | | import { BlLifeRechargeServices } from './lifeRechargeServices'; |
| | | import { IRequest, BlLifeRechargeOptions } from './types'; |
| | | |
| | | export class BlLifeRecharge<T extends IRequest> { |
| | | services: BlLifeRechargeServices<T>; |
| | | |
| | | constructor(options: BlLifeRechargeOptions<T>) { |
| | | this.services = new BlLifeRechargeServices(options); |
| | | } |
| | | |
| | | getRechargeParValue(amount: number, rate: number) { |
| | | return (amount * rate).toFixed(2); |
| | | } |
New file |
| | |
| | | import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; |
| | | import { IRequest, BlLifeRechargeServicesOptions } from './types'; |
| | | |
| | | export class BlLifeRechargeServices<T extends IRequest> { |
| | | request: T; |
| | | constructor({ request }: BlLifeRechargeServicesOptions<T>) { |
| | | this.request = request; |
| | | } |
| | | } |
New file |
| | |
| | | import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; |
| | | |
| | | export interface IRequestOptions extends AxiosRequestConfig {} |
| | | |
| | | export interface IRequest { |
| | | <T = any>(url: string, opts: IRequestOptions): Promise<AxiosResponse<T>>; |
| | | } |
| | | |
| | | export type BlLifeRechargeServicesOptions<T extends IRequest> = { |
| | | request: T; |
| | | }; |
| | | |
| | | export type BlLifeRechargeOptions<T extends IRequest> = BlLifeRechargeServicesOptions<T> & {}; |