Files
qlg.tsgz.moe/static/app/js/register.js
2019-09-06 23:53:10 +08:00

139 lines
3.8 KiB
JavaScript
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mui.init({
beforeback: function() {     //获得父页面的webview
var list = plus.webview.currentWebview().opener();     //触发父页面的自定义事件(refresh),从而进行刷新
mui.fire(list, 'refresh');
//返回true,继续页面关闭逻辑
return true;
}
});
mui.plusReady(function() {
var wait = 120;
var html = '<div class="row"><img src="../img/icon_pwd1.png" /><span class="s1">验证码:</span><input class="tpyzm" type="text" maxlength="4" placeholder="请输入图片验证码" /><img class="yzmhh" src = "'+ hyhUrl('mobile/users/getverify?rnd='+Math.random()) +'"/></input></div>';
$('.con').append(html);
function time() {
if(wait == 0) {
$('#mobileCode').removeAttr("disabled");
$('#mobileCode').val("重新发送");
wait = 120;
} else {
$('#mobileCode').attr("disabled", true);
$('#mobileCode').val("重新发送(" + wait + ")");
wait--;
setTimeout(function() {
time()
},
1000)
}
}
mui('.row').on('tap', '#mobileCode', function() {
var loginName = $('#loginName').val();
if(loginName == '') {
alert('手机号不能为空!');
return;
}
if(!(/^134[0-8]\d{7}$|^13[^4]\d{8}$|^14[5-9]\d{8}$|^15[^4]\d{8}$|^16[6]\d{8}$|^17[0-8]\d{8}$|^18[\d]{9}$|^19[8,9]\d{8}$/.test(loginName))) {
alert("手机号码有误,请重填!");
return;
}
$(this).attr("disabled", true);
mui.ajax(hyhUrl('app/users/getPhoneVerifyCode'), { 
data: {
userPhone: loginName
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) {
//服务器返回响应,根据响应结果,分析是否登录成功;
if(data.status == 1) {
time();
} else {
alert(data.msg);
}
$('#mobileCode').removeAttr('disabled');
},
error: function(xhr, type, errorThrown) {
//异常处理;
alert(type)
// alert(type);      
}
}); 
})
mui('.down').on('tap', '.btn', function() {
var loginName = $('#loginName').val();
var mobileCode = $('.yzm').val();
var loginPwd = $('#loginPwd').val();
var reUserPwd = $('#reUserPwd').val();
var pName = $('#pName').val();
var verifyCode = $('.tpyzm').val();
if(loginName == '') {
alert('手机号不能为空!');
return;
}
if(!(/^134[0-8]\d{7}$|^13[^4]\d{8}$|^14[5-9]\d{8}$|^15[^4]\d{8}$|^16[6]\d{8}$|^17[0-8]\d{8}$|^18[\d]{9}$|^19[8,9]\d{8}$/.test(loginName))) {
alert("手机号码有误,请重填!");
return;
}
if(mobileCode == '') {
alert('验证码不能为空!');
return;
}
if(loginPwd == '') {
alert('密码不能为空!');
return;
}
if(reUserPwd == '') {
alert('确认不能为空!');
return;
}
if(loginPwd.length < 6) {
alert('密码不能小于6位');
return;
}
if(!(loginPwd == reUserPwd)) {
alert('两次密码不一致!');
return;
}
$(this).attr("disabled", true);
mui.ajax(hyhUrl('app/users/register'), { 
data: {
loginName: loginName,
mobileCode: mobileCode,
loginPwd: loginPwd,
reUserPwd: reUserPwd,
pName: pName,
nameType: 3,
verifyCode: verifyCode
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) {
//服务器返回响应,根据响应结果,分析是否登录成功;
alert(data.msg);
if(data.status == 1) {
mui.back();
}else{
$('.yzmhh').attr('src',hyhUrl('mobile/users/getverify?rnd='+Math.random()));
}
$('.btn').removeAttr('disabled');
},
error: function(xhr, type, errorThrown) {
//异常处理;
// alert(type);      
}
}); 
})
})