|
|
@ -185,19 +185,80 @@ export default { |
|
|
|
this.$api('cashout', { transferAmount: this.withdrawAmount, userName: this.realName }, res => { |
|
|
|
uni.hideLoading() |
|
|
|
if (res.code === 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: '提现成功', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
this.$store.commit('getUserInfo') |
|
|
|
this.withdrawAmount = '' |
|
|
|
this.realName = '' |
|
|
|
// 处理待收款用户确认的情况 |
|
|
|
if (res.result && res.result.state === 'WAIT_USER_CONFIRM' && res.result.packageInfo && res.result.outBillNo) { |
|
|
|
// 拉起微信收款确认页面 |
|
|
|
if (!wx.canIUse('requestMerchantTransfer')) { |
|
|
|
wx.showModal({ |
|
|
|
content: '你的微信版本过低,请更新至最新版本。', |
|
|
|
showCancel: false, |
|
|
|
}); |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 判断是否在开发者工具中 |
|
|
|
const systemInfo = uni.getSystemInfoSync(); |
|
|
|
const isDevTools = systemInfo.platform === 'devtools'; |
|
|
|
|
|
|
|
if (isDevTools) { |
|
|
|
// 在开发者工具中,显示提示信息 |
|
|
|
console.log('开发者工具中无法调试此API,请在真机上测试'); |
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '当前在开发者工具中,无法调试支付相关API,请在真机上测试。', |
|
|
|
showCancel: false, |
|
|
|
success: () => { |
|
|
|
// 模拟成功,方便开发调试 |
|
|
|
this.$store.commit('getUserInfo') |
|
|
|
this.withdrawAmount = '' |
|
|
|
this.realName = '' |
|
|
|
this.isFormValid = true |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 在真机环境中,调用API |
|
|
|
wx.requestMerchantTransfer({ |
|
|
|
mchId: res.result.outBillNo, |
|
|
|
appId: wx.getAccountInfoSync().miniProgram.appId, |
|
|
|
package: res.result.packageInfo, |
|
|
|
success: (res) => { |
|
|
|
uni.showToast({ |
|
|
|
title: '提现申请已提交', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
this.$store.commit('getUserInfo') |
|
|
|
this.withdrawAmount = '' |
|
|
|
this.realName = '' |
|
|
|
}, |
|
|
|
fail: (res) => { |
|
|
|
console.log('fail:', res); |
|
|
|
uni.showToast({ |
|
|
|
title: '提现失败,请稍后再试', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
this.isFormValid = true |
|
|
|
}, |
|
|
|
complete: (res) => { |
|
|
|
console.log('requestMerchantTransfer完成:', res); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: '提现成功', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
this.$store.commit('getUserInfo') |
|
|
|
this.withdrawAmount = '' |
|
|
|
this.realName = '' |
|
|
|
} |
|
|
|
}else { |
|
|
|
uni.showToast({ |
|
|
|
title: res.message, |
|
|
|
title: 'res.message', |
|
|
|
icon: 'error' |
|
|
|
}) |
|
|
|
} |
|
|
|
this.isFormValid = true |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|