// pages/mine/mydc/applyextract/applyextract.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { amount: '', extractAmount: '', wv_account_bank: '', wv_account_number: '', wv_account_number_short: '', wv_account_name: '', loading: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { var that = this this.setData({ amount: options.amount }) wx.request({ url: app.globalData.url + '/checkDcIntroducers', method: 'get', data: { wv_phone: app.globalData.userphone }, success: function(res) { that.setData({ wv_account_bank: res.data.wv_account_bank, wv_account_number_short: res.data.wv_account_number, wv_account_number: res.data.wv_account_number, wv_account_name: res.data.wv_account_name }) }, fail() { app.timeOut() } }) let _this = this; _this.setData({ navH: app.globalData.navHeight }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { }, AmountInput: function(e) { this.setData({ extractAmount: e.detail.value }) }, getAll: function() { this.setData({ extractAmount: Number(this.data.amount).toFixed(2) }) }, applyExtract: function() { var that = this var re = /^\d{0,8}\.{0,1}(\d{1,2})?$/; if (!re.test(this.data.extractAmount)) { wx.showToast({ title: '金额输入错误!', icon: 'none', duration: 1500 }) that.setData({ extractAmount: '' }) } else if (Number(this.data.extractAmount) > Number(this.data.amount) || Number(this.data.extractAmount) <= 1) { wx.showToast({ title: '提现金额不能超过奖励金额,并且不能为0!', icon: 'none', duration: 2000 }) that.setData({ extractAmount: '' }) } else { this.setData({ loading: true }) wx.showLoading({ title: '保存中......', icon: 'loading', duration: 5500 }) wx.request({ url: app.globalData.url + '/insertDcIntroducerExtract', method: 'post', header: { "Content-Type": "application/x-www-form-urlencoded" }, data: { wue_phone: app.globalData.userphone, wue_account_name: this.data.wv_account_name, wue_bank_card: this.data.wv_account_number, wue_type: 1, wue_applysum: this.data.extractAmount }, success: function(res) { that.setData({ loading: false }) if (res.data == 1) { wx.hideLoading() that.setData({ loading: false }) //发送消息 wx.showToast({ title: '成功!', icon: 'success', duration: 2000 }) // 发送消息 wx.request({ url: app.globalData.url + '/WXSendExtractMessage', method: 'get', data: { wue_applysum: that.data.extractAmount, wue_phone: app.globalData.userphone, wue_bank_card: that.data.wv_account_number, wue_account_name: that.data.wv_account_name, } }) //减掉金额 that.setData({ amount: that.data.amount - that.data.extractAmount, extractAmount: '' }) } else { wx.hideLoading() that.setData({ loading: false }) wx.showToast({ title: '保存失败,请联系相关人员!', icon: 'none', duration: 2000 }) } }, fail() { app.timeOut() } }) } } })