Commit c9385ddd by huangzhi

feat: 余额错误

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