// pages/distribution/withdraw.js Page({ data: { balance: '1234.56', pendingAmount: '456.78', settledAmount: '777.78', amount: '', minWithdraw: 10, maxWithdraw: 50000, selectedMethod: 'wxpay', canWithdraw: false }, onLoad: function (options) { this.loadBalance() }, // 加载余额信息 loadBalance: function () { // 模拟API请求 setTimeout(() => { this.setData({ balance: '1234.56', pendingAmount: '456.78', settledAmount: '777.78' }) }, 500) }, // 输入金额 onAmountInput: function (e) { const amount = e.detail.value.trim() let canWithdraw = false if (amount) { const numAmount = parseFloat(amount) canWithdraw = numAmount >= this.data.minWithdraw && numAmount <= this.data.maxWithdraw && numAmount <= parseFloat(this.data.balance) } this.setData({ amount, canWithdraw }) }, // 全部提现 setMaxAmount: function () { const amount = this.data.balance const canWithdraw = parseFloat(amount) >= this.data.minWithdraw this.setData({ amount, canWithdraw }) }, // 选择提现方式 selectMethod: function (e) { const method = e.currentTarget.dataset.method this.setData({ selectedMethod: method }) }, // 提交提现 submitWithdraw: function () { if (!this.data.canWithdraw) return const amount = parseFloat(this.data.amount) if (isNaN(amount)) { wx.showToast({ title: '请输入正确的提现金额', icon: 'none' }) return } // 根据提现方式判断 if (this.data.selectedMethod === 'bank') { wx.navigateTo({ url: '/pages/bank/list' }) return } // 模拟提现请求 wx.showLoading({ title: '提现申请中...', mask: true }) setTimeout(() => { wx.hideLoading() wx.showToast({ title: '提现申请成功', icon: 'success', duration: 2000, success: () => { setTimeout(() => { wx.navigateBack() }, 2000) } }) }, 1500) } })