| | |
| | | const isTabbarPage = Object.values(TabBarPageRouter).some((x) => |
| | | latestRoute.value.toLowerCase().includes(x.toLowerCase()) |
| | | ); |
| | | if (isTabbarPage) { |
| | | if (isTabbarPage && isInAlipay) { |
| | | Taro.reLaunch({ |
| | | url: router.path, |
| | | success() { |
| | |
| | | const isAuth = computed(() => !needAuth || isLogin.value); |
| | | |
| | | const router = Taro.useRouter(); |
| | | console.log('222', 222); |
| | | useInitWeixinJSBridge(); |
| | | |
| | | Taro.useReady(async () => { |
| | |
| | | import { BlLifeRecharge } from '@life-payment/core-vue'; |
| | | import { request } from './request'; |
| | | import { config } from './request'; |
| | | import { getStorageVirtualUserId } from './storage'; |
| | | |
| | | export const blLifeRecharge = new BlLifeRecharge({ |
| | | request, |
| | | axiosConfig: config, |
| | | userId: getStorageVirtualUserId()?.virtualUserId ?? '', |
| | | phoneNumber: getStorageVirtualUserId()?.virtualPhoneNumber ?? '', |
| | | }); |
| | |
| | | REDIRECT = 9, |
| | | } |
| | | // 与后端约定的响应数据格式 |
| | | interface ResponseStructure { |
| | | export interface ResponseStructure { |
| | | success: boolean; |
| | | data: any; |
| | | /** |
| | |
| | | withCredentials: true, |
| | | }; |
| | | |
| | | const config: RequestConfig<ResponseStructure, IRequestOptions> = { |
| | | export const config: RequestConfig<ResponseStructure, IRequestOptions> = { |
| | | ...AxiosOptions, |
| | | |
| | | errorConfig: { |
| | |
| | | PhoneMesssageCodeLoginInput, |
| | | RequestConfig, |
| | | } from './lifeRechargeServices'; |
| | | import { IRequest, BlLifeRechargeOptions } from './types'; |
| | | import { BlLifeRechargeOptions } from './types'; |
| | | import { LifeRechargeConstants } from './lifeRechargeConstants'; |
| | | import { BlLifeRechargeAccountModel } from './lifeRechargeAccountModel'; |
| | | |
| | | export class BlLifeRecharge<T extends IRequest = IRequest> { |
| | | services: BlLifeRechargeServices<T>; |
| | | export class BlLifeRecharge<TResponse = any, TRequestOptions = any> { |
| | | services: BlLifeRechargeServices<TResponse, TRequestOptions>; |
| | | accountModel: BlLifeRechargeAccountModel; |
| | | |
| | | static constants = LifeRechargeConstants; |
| | | constants = LifeRechargeConstants; |
| | | |
| | | constructor(options: BlLifeRechargeOptions<T>) { |
| | | constructor(options: BlLifeRechargeOptions<TResponse, TRequestOptions>) { |
| | | this.services = new BlLifeRechargeServices(options); |
| | | this.accountModel = new BlLifeRechargeAccountModel({ |
| | | userId: options.userId, |
| | |
| | | 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) { |
| | |
| | | import { AxiosRequestConfig } from 'axios'; |
| | | import { type RequestConfig } from 'senior-request'; |
| | | |
| | | export interface IRequestOptions extends AxiosRequestConfig {} |
| | | |
| | | export interface IRequest { |
| | | <T = any>(url: string, opts: IRequestOptions): Promise<T>; |
| | | } |
| | | |
| | | export type BlLifeRechargeServicesOptions<T extends IRequest> = { |
| | | request: T; |
| | | axiosOptions?: AxiosRequestConfig; |
| | | export type BlLifeRechargeServicesOptions<TResponse = any, TRequestOptions = any> = { |
| | | axiosConfig?: RequestConfig<TResponse, TRequestOptions>; |
| | | }; |
| | | |
| | | export type BlLifeRechargeAccountModelOptions = { |
| | |
| | | phoneNumber?: string; |
| | | }; |
| | | |
| | | export type BlLifeRechargeOptions<T extends IRequest> = BlLifeRechargeServicesOptions<T> & |
| | | export type BlLifeRechargeOptions< |
| | | TResponse = any, |
| | | TRequestOptions = any |
| | | > = BlLifeRechargeServicesOptions<TResponse, TRequestOptions> & |
| | | BlLifeRechargeAccountModelOptions & {}; |