cashout.js
3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// pages/main/rewardpoint/cashout/cashout.js
Page({
/**
* Page initial data
*/
data: {
taxpercent:25,//暂时固定为25%
showModal:false,
hasBind:false,
rightNum:false,
cashNum:6989.88,
inputNum:"",
inputNum2Fixed:"",
taxNum:"",
pwdList: [1, 2, 3, 4, 5, 6],
//输入框聚焦状态
isFocus: false,
//输入框聚焦样式 是否自动获取焦点
focusType: true,
valueData: '', //输入的值
dataLength: '',
},
/**
* Lifecycle function--Called when page load
*/
onLoad: function (options) {
},
/**
* Lifecycle function--Called when page is initially rendered
*/
onReady: function () {
},
/**
* Lifecycle function--Called when page show
*/
onShow: function () {
},
/**
* 绑定银行卡
*/
bindCard:function(){
wx.navigateTo({
url: '../bindcard/bindcard',
})
},
/**
* 实时监听输入框内容
*/
getInput:function(e){
var money;
if (/^(\d?)+(\.\d{0,2})?$/.test(e.detail.value)) { //正则验证,提现金额小数点后不能大于两位数字
money = e.detail.value;
} else {
money = e.detail.value.substring(0, e.detail.value.length - 1);
}
var flag = (money&&money>0&&money<=this.data.cashNum)?true:false
this.setData({
inputNum: money,
rightNum:flag
})
},
/**
* 清空输入内容
*/
clear:function(){
this.setData({
inputNum: "",
rightNum:false
})
},
/**
* 全部提现
*/
cashAll:function(){
this.setData({
inputNum: this.data.cashNum,
rightNum:true
})
},
/**
* 提现
*/
cashOut:function(){
var inputnum = this.data.inputNum
if(this.data.rightNum){
this.setData({
inputNum2Fixed:parseFloat(inputnum).toFixed(2),
taxNum:parseFloat(inputnum*this.data.taxpercent/100).toFixed(2),
showModal: !this.data.showModal?true:this.data.showModal,
})
}else{
wx.showToast({
title: '请输入正确提现金额',
icon:"none"
})
}
},
/**
* Lifecycle function--Called when page hide
*/
onHide: function () {
},
/**
* Lifecycle function--Called when page unload
*/
onUnload: function () {
},
/**
* Page event handler function--Called when user drop down
*/
onPullDownRefresh: function () {
},
/**
* Called when page reach bottom
*/
onReachBottom: function () {
},
/**
* Called when user click on the top right corner to share
*/
onShareAppMessage: function () {
},
// 获得焦点时
handleUseFocus() {
this.setData({
focusType: true
})
},
// 失去焦点时
handleUseBlur() {
this.setData({
focusType: false
})
},
// 点击6个框聚焦
handleFocus() {
this.setData({
isFocus: true
})
},
// 获取输入框的值
handleSetData(e) {
// 更新数据
this.setData({
dataLength: e.detail.value.length,
valueData: e.detail.value
})
// 当输入框的值等于6时(发起支付等...)
if (e.detail.value.length === 6) {
// 通知用户输入数字达到6位数可以发送接口校验密码是否正确
this.triggerEvent('initData', e.detail.value)
}
},
closeModal:function(){
this.setData({
showModal:false
})
}
})