Commit 67e6b14c by huangzhi

feat: 余额请求能力透出

parent e1749b07
{
"name": "ydl-packages",
"version": "1.0.0",
"version": "1.0.1-beta.1",
"description": "",
"main": "index.js",
"scoped": "@ydl-packages",
......
......@@ -126,6 +126,13 @@ export type ToPayReturns = {
payUrl?: string
}
export type BalanceReturns = {
success: boolean
code?: number
msg?: string
}
export interface DoUnifiedParams extends Omit<ToPayParams, 'totalAmount' | 'redirectUrl'> {
payChannel?: PayChannel,
payBalance: number,
......
......@@ -18,6 +18,7 @@ import {
PayType,
ToPayParams,
ToPayReturns,
BalanceReturns,
WechatPayParams
} from "./Defined";
import {ACCESS_TOKEN, UID} from "@/Const";
......@@ -89,15 +90,22 @@ export class Payment {
}
}
async getBalance(): Promise<number> {
async getBalance(): Promise<number|BalanceReturns> {
try {
const {data: res} = await requestForPhp.post(MY_BALANCE, {balance: 1})
if (res.data && res.data.balance) {
this.balance = Number(res.data.balance)
}
if(res.msg === 'success'){
return this.balance
}
return {
success: false,
msg: res.msg,
code: res.code
}
} catch (err) {
return 0
return { success: false }
}
}
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