'
},
},
errorClasses:{
user_name:{
required:'testTxt'
//match:'tipLayErr tipw150',
//remote:'tipLayErr tipw200'
},
password:{
required:'testTxt'
//rangelength:'tipLayErr tipw150'
},
catcha:{
required:'testTxt'
}
},
errorElement:'div',
errorPlacement:function(error,element){
$('#tipError').html(error);
},
success:function(label){
label.text(" ");
}
});
$(document).keydown(function (event) {
if (event.keyCode == 13) {
if($('#frmLoginMobile').hasClass('formShow')){
$("#btnSubMobile").click();
}else{
$("#btnSub").click();
}
}
});
var login = {
initalize:function(){
this.initControl();
},
checkNeedAuth:function(){
var user_name = $('#user_name').val();
if(user_name == "" || $('#verifycode').is(":visible")) {
return ;
}
else{
$.ajax({
url:"/login/NeedAuthCode",
type:"post",
data:{user_name:user_name},
dataType:"json",
success:function(json){
window.needAuthCode = json.needAuthCode == 'true';
// if(json.needAuthCode == "true"){
// $('#verifycode').show();
// }
// else{
// $('#verifycode').hide();
// }
}
});
}
},
initControl:function(){
var fn =this;
$('input:text,input:password').placeHolder();
if($('#user_name').val()){
$('#user_name').prev().hide();
}
if($('#password').val()){
$('#password').prev().hide();
}
// 重复调用了回车键
// $('#frmLogin').find(':input').keydown(function(event){
// var e = $.event.fix(event);
// if (e.keyCode == 13){
// $('#btnSub').click();
// }
// });
$('#imgCode,#btnCode,#btnCodeMobile,#imgCodeMobile').click(function(){
$(this).closest('.formMod').find('img').attr('src','/login/verify?seed=67d6814e34ed5&r='+Math.random());
return false;
});
this.checkNeedAuth();
$('#user_name').blur(function(){
login.checkNeedAuth();
});
$("#btnSub").click(function() {
window.loginDo();
});
}
}
login.initalize();
window.loginDoFunction = function () {
}
$('#mobile_phone').on("input",function(){
var phone = $("#mobile_phone").val();
var pattern = /^[1]\d{10}$/;
$('#tipErrorMobile').hide();
if(pattern.exec(phone)){
$.post("/login/GetPersonLoginTimes/",{mobile_phone:phone},function(r){
if(r.status){
$('#log_count').val(r.count);
}else{
$('#tipErrorMobile').html('
'+'系统错误,请刷新后重试'+'
').show();
window.location.reload();
}
},'json')
}else{
$('#verifycodemobile').hide();
}
});
$('.loginType').on('click','li',function () {
$(this).addClass('active').siblings().removeClass('active');
var index = $(this).index();
$('.formCon form').eq(index).addClass('formShow').siblings().removeClass('formShow');
});
//勾选注册协议
$('.agreement-login-box .icon').click(function(){
$(this).toggleClass('active');
});
//手机号输入正常自动获取验证码
var phoneFirstClick = true;
$('#mobile_phone').keyup(function () {
var txtPhone = $(this).val();
if(/^1/.test(txtPhone) && txtPhone.length == 11){
setTimeout(function() {
if(phoneFirstClick && $('#verifycodemobile').is(':hidden')){
$('.getMsg').click();
phoneFirstClick = false;
}
}, 500);
}
});
//发送验证码
$('.getMsg').click(function(){
if ($('.getMsg').hasClass('nameBtnavt')) {
return;
}
//判断是否输入眼买
var txtcode = $("#catchamobile").val();
var mobile_phone = $("#mobile_phone").val();
if(mobile_phone == ''){
$('#tipErrorMobile').html('
'+'请输入手机号'+'
').show();
return;
}
var phone = $('#mobile_phone').val();
var pattern = /^[1]\d{10}$/;
if(!pattern.exec(phone)){
$('#tipErrorMobile').html('
'+'手机号码格式不正确'+'
').show();
// showError('手机号码格式不正确');
return;
}
const count = $('#log_count').val();
if(count >= 5){
GridCapcha.showModal();
return;
}
sendMsgDo();
});
window.sendMsgDo = function(){
var sendMsgUrl = "/login/GetAuthCodeBySeedV2/";
var vali_code_count=1;
var login_verify = GridCapcha.getToken;
var data={txtPhone:$('#mobile_phone').val(),login_verify:login_verify,vali_code_count:vali_code_count};
$.getJSON(sendMsgUrl,data,function(result){
if(result && result.error){
$("#imgCodeMobile").click();
$('#tipErrorMobile').html('
'+result.error+'
').show();
//判断是否登录次数超过
if (result.data.login_count >= 5) {
$('#log_count').val(result.data.login_count);
GridCapcha.showModal();
}
// showError(result.error);
return;
}
//6个月内是否登录过1 登录过 0 未登录
if(result.has_login_in_6month == '1'){
$('.agreement-login-box .icon').addClass('active');
}else{
$('.agreement-login-box .icon').removeClass('active');
}
$('.getMsg').addClass('nameBtnavt').html('
60秒后重新获取验证码');
$('#tipErrorMobile').html('');
$('#txtValidateCode').focus();
$('#vali_code_count').val(parseInt($('#vali_code_count').val())+1);
interval = window.setInterval(countdown,1000);
});
}
window.loginDo = function () {
if (window.needAuthCode) {
LoadingNeedCapcha.showModal();
return;
}
var _this = $("#btnSub");
var outer_job_import = $("#outer_job_import").val();
var user_name,password,chkSave;
if(frmValid.element($('#user_name'))&&frmValid.element($('#password'))){
user_name = $("#user_name").val();
password = $("#password").val();
chkSave = $(".chkSave").is(':checked')?'true':'false';
var login_verify = LoadingNeedCapcha.getToken;
if(!$('.agreement-login-box .icon').hasClass('active')){
$.anchorMsg('请阅读并同意《汇博注册协议》《隐私协议》', {
icon: 'fail',
});
return;
}
$("#btnSub").running('正在提交数据');
if(_this.hasClass("_lock")){
return;
}
_this.addClass("_lock");
$.ajax({
url:"/login/LoginDo",
type:"post",
data:{user_name:user_name,password:password,chkSave:chkSave,outer_job_import:outer_job_import,login_verify:login_verify},
dataType:"json",
success:function(json){
if(402 == json.code) {
ConfirmBox.alert(''+json.success+'', function () {
//确认回调
window.location.href = json.url;
}, {
width: 350,
close: '',
confirmBtn: '