Commit 67e6b14c by huangzhi

feat: 余额请求能力透出

parent e1749b07
{ {
"name": "ydl-packages", "name": "ydl-packages",
"version": "1.0.0", "version": "1.0.1-beta.1",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scoped": "@ydl-packages", "scoped": "@ydl-packages",
......
...@@ -126,6 +126,13 @@ export type ToPayReturns = { ...@@ -126,6 +126,13 @@ export type ToPayReturns = {
payUrl?: string payUrl?: string
} }
export type BalanceReturns = {
success: boolean
code?: number
msg?: string
}
export interface DoUnifiedParams extends Omit<ToPayParams, 'totalAmount' | 'redirectUrl'> { export interface DoUnifiedParams extends Omit<ToPayParams, 'totalAmount' | 'redirectUrl'> {
payChannel?: PayChannel, payChannel?: PayChannel,
payBalance: number, payBalance: number,
......
...@@ -18,6 +18,7 @@ import { ...@@ -18,6 +18,7 @@ import {
PayType, PayType,
ToPayParams, ToPayParams,
ToPayReturns, ToPayReturns,
BalanceReturns,
WechatPayParams WechatPayParams
} from "./Defined"; } from "./Defined";
import {ACCESS_TOKEN, UID} from "@/Const"; import {ACCESS_TOKEN, UID} from "@/Const";
...@@ -89,15 +90,22 @@ export class Payment { ...@@ -89,15 +90,22 @@ export class Payment {
} }
} }
async getBalance(): Promise<number> { async getBalance(): Promise<number|BalanceReturns> {
try { try {
const {data: res} = await requestForPhp.post(MY_BALANCE, {balance: 1}) const {data: res} = await requestForPhp.post(MY_BALANCE, {balance: 1})
if (res.data && res.data.balance) { if (res.data && res.data.balance) {
this.balance = Number(res.data.balance) this.balance = Number(res.data.balance)
} }
if(res.msg === 'success'){
return this.balance return this.balance
}
return {
success: false,
msg: res.msg,
code: res.code
}
} catch (err) { } catch (err) {
return 0 return { success: false }
} }
} }
getPayMethodList (totalAmount:number) { getPayMethodList (totalAmount:number) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment