123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- // 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()
- }
- })
- }
- }
- })
|