/* * 手太欠 * 愿这世界都如故事里一样 美好而动人~ */ Page({ /** * 页面的初始数据 */ data: { balance : '', //金额 accounts : '', //账户列表 amount : '', //提现金额 disabled : false ,// 提交按钮状态 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { // 获取账户前置 this.createInfo(); }, /** * 生命周期函数--监听页面显示 */ onShow() {}, /** * 账户前置 */ createInfo() { wx.$api.user.createUser().then(res => { this.setData({ balance : res.data.balance, accounts : res.data.bank_account }) }).catch(err => {}) }, /** * 输入商品数量 */ goodsNumberInput(e) { let goodsNum = (e.detail.value.match(/^\d*(\.?\d{0,2})/g)[0]) if (goodsNum > 0) { if(parseFloat(goodsNum) > parseFloat(this.data.balance)){ wx.showToast({ title: '提现金额不能大于总金额', icon: 'none' }); return } this.setData({ amount: goodsNum }) } else { uni.showToast({ title: '商品数量不能小于1', icon: 'none' }); this.setData({ amount: 1 }) } }, /** * 全部提现 */ allCash() { this.setData({ amount: this.data.balance }) }, //提现 banksForm() { let data = { bank_account_id : this.data.accounts.bank_account_id, amount : this.data.amount, type : 1 } wx.$api.user.bankCash(data).then(() => { this.setData({ disabled: true }) // 跳到审核页面 wx.redirectTo({ url: "../tips/index" }) }).catch(err => { uni.showToast({ title: err.message, icon : 'none' }) }) } })