Commit 33d8c3f9 by huangzhi

feat: 余额自定义异常处理开关

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