binding.js
3.14 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
var func = {
wait:60,
timeFlag:true,
statusFlag:true,
//1.获取验证码
getRandCode:function(){
$(document).on('click','#get_code',function(){
var mobileVal = $('#bind_mobile').val();
if(/^1[34578]\d{9}$/.test(mobileVal)){
if(func.timeFlag){
func.time($(this));
}else{
return false;
}
//发送验证码
func.sendRandCode(mobileVal);
}else{
$.toptip('亲!手机号不正确', 3000, 'error'); //设置显示时间
}
});
},
//2.倒计时
time:function(o){
if (func.wait == 0) {
o.attr("disabled",false);
o.html("获取验证码");
func.timeFlag = true;
func.wait = 60;
} else {
func.wait--;
func.timeFlag = false;
o.attr("disabled", true);
o.html("已发送" + func.wait + "S");
setTimeout(function() {
func.time(o)
},
1000)
}
},
//3.发送验证码
sendRandCode:function(phone){
$.ajax({
url:mUrl.sendRandCode,
async:false,
type:'POST',
dataType:'json',
data:{"phone_number":phone},
success:function(data){
//alert(dataObj.user);
}
});
},
//绑定用户手机号
bindingPhone:function(){
$(document).on('click','#binging_btn',function(){
var mobileVal = $('#bind_mobile').val();
var appid = $("#appid").val();
var randCode = $('#verification_code').val();
if(appid == null || appid == ""){
$.alert("亲!绑定失败,请重新尝试绑定");
return false;
}
if(mobileVal == null || mobileVal ==''){
$.toptip('亲!请输入手机号', 3000, 'error'); //设置显示时间
return false;
}
if(!(/^1[34578]\d{9}$/.test(mobileVal))){
$.toptip('亲!手机号不正确', 3000, 'error'); //设置显示时间
return false;
}
if(randCode == null || randCode ==""){
$.toptip('亲!请输入验证码', 3000, 'error'); //设置显示时间
return false;
}
var jsonInfo={};
jsonInfo.phone=mobileVal;
jsonInfo.appid=appid;
jsonInfo.randCode=randCode;
if(/^1[34578]\d{9}$/.test(mobileVal)){
jsutil.defaultReq(
mUrl.bindingPhone,
jsonInfo,
function(data){
if("1004" ==data.code ){
$.alert("亲!验证码错误,重新验证!");
return false;
}else if("8888" !=data.code){
$.alert("亲!绑定失败,请重新尝试绑定");
return false;
}else{
//$.toptip('绑定成功', 1000, 'success'); //设置显示时间
$.alert('亲,您已绑定成功!','成功', function() {
targetUrl=$("#targetUrl").val();
if(targetUrl == null ||targetUrl.length<3){
//如果为空,默认跳转到月卡、年卡界面
targetUrl = mUrl.toParkInfoListView;
}
window.location.href=targetUrl;
});
}
}
);
}else{
$.toptip('亲!手机号不正确', 3000, 'error'); //设置显示时间
}
});
}
};
$(function(){
func.getRandCode();
func.bindingPhone();
});