var http = require("../../utils/http.js"); Page({ /** * 页面的初始数据 */ data: { settledAmount: 0, amount: null, "frequency": 0, //天数 "number": 0, //提现次数 "amountMax": 0, //最大金额 "amountMin": 0, //最低金额 "paymentExplain": '' //其他提示 }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { this.getDisInfoData(); this.loadWithdrawCashRule(); //提现规则 }, /** * 获取用户钱包数据 */ getDisInfoData: function() { wx.showLoading(); var params = { url: "/p/distribution/user/info", method: "GET", // data: { // shopId: 1 // }, callBack: res => { console.log(res) this.setData({ settledAmount: res.distributionUserWallet.settledAmount, addupAmount: res.distributionUserWallet.addupAmount }); wx.hideLoading(); } } http.request(params); }, /** * 确认提现 */ confirmWithdraw: function() { if (!this.data.amount || this.data.amount <= 0) { wx.showToast({ title: '请输入正确金额!', icon: 'none', }) return; } else if (this.data.amount > this.data.settledAmount) { wx.showToast({ title: '余额不足', icon: "none" }) return; } wx.showLoading({ mask: true }) http.request({ url: "/p/distribution/withdrawCash/apply", method: "POST", data: { // shopId: 1, amount: this.data.amount }, callBack: res => { wx.hideLoading(); wx.showModal({ content: '提现申请已提交', showCancel: false, complete: function() { wx.navigateBack(); } }) } }); }, onAmountInput: function(e) { this.setData({ amount: e.detail.value }); }, onAllWithdraw: function() { this.setData({ amount: this.data.settledAmount }); }, /** * 加载提现规则 */ loadWithdrawCashRule: function() { var ths = this; wx.showLoading(); var params = { url: "/p/distribution/withdrawCash/info", method: "GET", // data: { // shopId: 1 // }, callBack: function(res) { wx.hideLoading(); ths.setData({ frequency: res.frequency, number: res.number, amountMax: res.amountMax, amountMin: res.amountMin, paymentExplain: res.paymentExplain }); } }; http.request(params); } })