qlg.frontend/js/register.js
2021-07-16 23:23:05 +08:00

265 lines
6.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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);
// 判断用户名是否存在
$('#loginName').on('blur', function() {
var loginName = $('#loginName').val();
if ('' == loginName) {
mui.mui.alert('用户名不能为空')
return;
}
JZL.ajax(qlgUrl('app/users/check_login_name'), {
loginName: loginName
}, function(data) {
// //console.log(data);
if (1 != data.status) {
mui.confirm(data.msg, "提示", [
"我要核实",
"继续注册"
], function(result) {
if (result.index == 0) {
mui.back()
}
})
}
})
})
// 判断用户名是否存在
$('#householdName').on('blur', function() {
var householdName = $('#householdName').val();
if ('' == householdName) {
mui.mui.alert('户主姓名不能为空')
return;
}
JZL.ajax(qlgUrl('app/users/check_real_name'), {
householdName: householdName
}, function(data) {
// //console.log(data);
if (1 != data.status) {
mui.confirm(data.msg, "提示", [
"我要核实",
"继续注册"
], function(result) {
if (result.index == 0) {
mui.back()
}
})
}
})
})
// 判断用户名是否存在
$('#householdIdCard').on('blur', function() {
var householdIdCard = $('#householdIdCard').val();
if ('' == householdIdCard) {
mui.mui.alert('户主身份证不能为空')
return;
}
JZL.ajax(qlgUrl('app/users/check_real_no'), {
householdIdCard: householdIdCard
}, function(data) {
// //console.log(data);
if (1 != data.status) {
mui.confirm(data.msg, "提示", [
"我要核实",
"继续注册"
], function(result) {
if (result.index == 0) {
mui.back()
}
})
}
})
})
// 推荐人信息
$('.pNameCode').hide();
var PName = "";
$('#pName').on('blur', function() {
pName = $('#pName').val();
if ('' != pName) {
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(pName))) {
mui.alert("手机号码有误,请重填!");
return;
}
$('.pNameCode').show();
mui('.row').on('tap', '#getMobileCode', function() {
var that=$(this)
that.attr("disabled", true);
JZL.ajax(qlgUrl('app/users/getPhoneVerifyCode'), {
userPhone: pName
}, function(data) {
if (1 == data.status) {
time()
} else {
mui.alert(data.msg);
}
that.removeAttr('disabled');
})
})
} else {
$('.pNameCode').hide();
}
})
function time() {
if (wait == 0) {
$('#getMobileCode').removeAttr("disabled");
$('#getMobileCode').val("重新发送");
wait = 120;
} else {
$('#getMobileCode').attr("disabled", true);
$('#getMobileCode').val("重新发送(" + wait + ")");
wait--;
setTimeout(function() {
time()
},
1000)
}
}
//注册协议
mui.ajax(qlgUrl('app/Tags/articleDetail'), {
data: {
articleId: 114
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) {
//console.log(data);
// if(data.status==1){
// //console.log(1);
$('.zcxycontent').html(data.articleContent)
// }
},
error: function(xhr, type, errorThrown) {
}
});
//上传图片
$(".photos").on("tap", '.regConfirm', function() {
// UP.init("accountBookImg", "test", "accountBookImgTag")
UP.init("regConfirmImg", "test", "regConfirm")
openCamera()
})
mui('.down').on('tap', '.btn', function() {
var loginName = $('#loginName').val();
// var mobileCode = $('.yzm').val();
var loginPwd = $('#loginPwd').val();
var reUserPwd = $('#reUserPwd').val();
var mobileCode = $('#mobileCode').val() ? $('#mobileCode').val() : ""; //推荐人验证码
var payPwd = $('#loginPaywd').val();
var reUserPaywd = $('#reUserPaywd').val();
var pName = $('#pName').val();
var householdName = $('#householdName').val();
var householdIdCard = $('#householdIdCard').val();
// var verifyCode = $('.tpyzm').val();
var regConfirmImg = $('#regConfirmImg').val();
if (loginName == '') {
mui.alert('用户名不能为空!');
return;
}
if (householdName == '') {
mui.alert('户主姓名不能为空!');
return;
}
if (householdIdCard == '') {
mui.alert('户主身份证号不能为空!');
return;
}
if (loginPwd.length < 6) {
mui.alert('登录密码不能小于6位');
return;
}
if (!(loginPwd == reUserPwd)) {
mui.alert('两次登录密码不一致!');
return;
}
if (payPwd.length < 6) {
mui.alert('操作密码不能小于6位');
return;
}
if (payPwd != reUserPaywd) {
mui.alert('两次操作密码不一致!');
return;
}
if (regConfirmImg == '') {
mui.alert('请上传确认书照片');
return;
}
if (pName != '') {
if ('' == mobileCode) {
mui.alert('请输入推荐人验证码');
return;
}
}
var ajaxData={
loginName: loginName,
// mobileCode: mobileCode,
loginPwd: loginPwd,
payPwd: payPwd,
pName: pName,
// nameType: 3,
regConfirmImg: regConfirmImg,
householdName: householdName,
householdIdCard: householdIdCard,
mobileCode: mobileCode
};
var that = $(this)
that.attr("disabled", true);
mui.ajax(qlgUrl('app/users/register'), {
data:ajaxData,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) {
//服务器返回响应,根据响应结果,分析是否登录成功;
mui.alert(data.msg);
if (data.status == 1) {
mui.back();
} else {
// $('.yzmhh').attr('src', hyhUrl('mobile/users/getverify?rnd=' + Math.random()));
}
that.removeAttr('disabled');
},
error: function(xhr, type, errorThrown) {
//异常处理;
// mui.alert(type);
}
});
})
})