Commit c9385ddd by huangzhi

feat: 余额错误

parent 5b53f0f6
......@@ -91,22 +91,20 @@ export class Payment {
}
//isHandleErr 是否要自定义处理异常
async getBalance(isHandleErr: Boolean): Promise<number|BalanceReturns> {
async getBalance(handleErr: (err: BalanceReturns) =>void): Promise<number|null> {
try {
const {data: res} = await requestForPhp.post(MY_BALANCE, {balance: 1})
if (res.data && res.data.balance) {
this.balance = Number(res.data.balance)
}
if(isHandleErr && res.msg !== 'success'){
return {
success: false,
msg: res.msg,
code: res.code
}
if(handleErr && res.msg !== 'success'){
handleErr && handleErr(res)
return null
}
return this.balance
} catch (err) {
return isHandleErr ? { success: false } : 0
handleErr && handleErr({success: false})
return !!handleErr ? null : 0
}
}
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