You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

268 lines
5.6 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// pages/withdraw/index.js
var common = require("../../utils/commonUtil.js");
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
array: ['中国建设银行 (2004)', '中国', '巴西', '日本'],
index: 0,
iosDialog1:false,
money:'',
moneyInput:'',
moneyBtn:true,
balance: 0,
auth: 0,
token: '',
},
bindPickerChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.setData({
index: e.detail.value
})
},
makeInput:function(e){
//今日最多可提现
var num = 200 - this.data.money;
num = this.data.balance > num ? num : this.data.balance;
if(num > 0){
this.setData({
moneyInput: num,
moneyBtn:false
})
}else{
wx.showToast({
duration: 2000,
title: '暂无可提现余额',
icon: 'none',
mask: true
})
}
},
goMakeInfo:function(e){
wx.navigateTo({
url: '/pages/makeInfo/index',
})
},
doWithdrawal: function() {
var that = this;
that.setData({
moneyBtn:true,
})
// setTimeout(function() {
// wx.hideLoading()
// that.goWithdrawSuccess(200, '提现成功');
// }, 2000)
wx.request({
url: app.globalData.ip + "/wallet/dowithdrawal",
data: {
money: that.data.moneyInput * 100,
token: that.data.token,
},
header: app.globalData.headers,
method: "POST",
success: function(res) {
console.log(res)
wx.hideLoading();
if(res.data.status == 200) {
console.log(res);
that.setData({
moneyBtn:true,
})
that.goWithdrawSuccess(200, '提现成功');
} else {
that.goWithdrawSuccess(res.data.status, res.data.msg);
}
},
fail: function(res) {
console.log("操作失败");
}
})
},
showDialog:function(e){
var that = this;
var myreg = /(^[1-9]([0-9]{0,2})(\.[0-9]{1,2})?$)|(^[0-9]{1}(\.[0-9]{1,2})?$)/g;
if(myreg.test(this.data.moneyInput)){
//不需实名
wx.showLoading({
title: '提现中...',
})
that.setData({
moneyBtn:false
})
that.doWithdrawal();
//需实名
/*if(this.data.auth - 1 == 0) {
this.setData({
moneyBtn:false
})
that.doWithdrawal();
} else {
this.setData({
iosDialog1: true,
moneyBtn:false
})
}*/
}else{
wx.showToast({
duration: 2000,
title: '请输入正确金额',
icon: 'none',
mask: true
})
}
},
cashValida:function(e){
var myreg = /(^[1-9]([0-9]{0,2})(\.[0-9]{1,2})?$)|(^[0-9]{1}(\.[0-9]{1,2})?$)/g;
if(myreg.test(e.detail.value)){
this.setData({
moneyInput:e.detail.value,
moneyBtn:false
})
}else{
this.setData({
moneyBtn:true
})
}
if(e.detail.value > 200){
this.setData({
moneyInput:200,
moneyBtn:false
})
}
if(e.detail.value == 0){
this.setData({
moneyBtn:true
})
}
if(this.data.balance > 0){
if(e.detail.value > this.data.balance){
this.setData({
moneyInput:this.data.money,
moneyBtn:false
})
}
}else{
this.setData({
moneyBtn:true,
})
}
},
bindCashCard:function(e){
wx.navigateTo({
url: '/pages/bindCashCard/index',
})
},
goWithdrawSuccess:function(code, msg){
wx.navigateTo({
url: '/pages/withdrawSuccess/index?code=' + code + '&msg=' + msg,
})
},
close: function () {
this.setData({
iosDialog1: false,
iosDialog2: false,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
getTodayInfo: function() {
var that = this;
wx.request({
url: app.globalData.ip + "/wallet/today/withdrawal",
data: {
},
header: app.globalData.headers,
method: "GET",
success: function(res) {
console.log(res)
if(res.data.status == 200) {
console.log(res);
//绑定成功
var balanceTemp = common.moneyToFixed(res.data.data.balance) * 1;
var moneyTemp = common.moneyToFixed(res.data.data.money) * 1;
that.setData({
balance: balanceTemp,
money: moneyTemp,
auth: res.data.data.auth,
token: res.data.data.token,
});
} else {
wx.showToast({
icon: "none",
title: res.data.msg,
})
}
},
fail: function(res) {
console.log("操作失败");
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getTodayInfo();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
// onShareAppMessage: function () {
// }
})