function showErrorMsg(msg){ layer.msg(msg, {icon: 5,time: 2000}); } function showErrorAlert(msg, icon){ if (!icon && icon != 0) { icon = 5; } layer.alert(msg, {icon: icon, title: false, closeBtn: false}); } // 鍔犺浇灞 function layer_loading(msg){ var loading = layer.msg( msg+'...                璇峰嬁鍒锋柊椤甸潰', { icon: 1, time: 3600000, //1灏忔椂鍚庡悗鑷姩鍏抽棴 shade: [0.2] //0.1閫忔槑搴︾殑鐧借壊鑳屾櫙 }); //loading灞 var index = layer.load(3, { shade: [0.1,'#fff'] //0.1閫忔槑搴︾殑鐧借壊鑳屾櫙 }); return loading; } $(document).keydown(function(event){ if(event.keyCode ==13){ $('form#popup_login_submit input[name=submit]').trigger("click"); } }); function ey_fleshVerify(){ var src = __eyou_basefile__ + "?m=api&c=Ajax&a=vertify&type=users_login&r=" + Math.floor(Math.random()*100); $('form#popup_login_submit #imgVerifys').attr('src', src); } function popup_login_submit() { var username = $('form#popup_login_submit input[name=username]'); var password = $('form#popup_login_submit input[name=password]'); if($.trim(username.val()) == ''){ layer.msg('鐢ㄦ埛鍚嶄笉鑳戒负绌猴紒', {time: 1500, icon: 5}); username.focus(); return false; } if($.trim(password.val()) == ''){ layer.msg('瀵嗙爜涓嶈兘涓虹┖锛?, {time: 1500, icon: 5}); password.focus(); return false; } $('form#popup_login_submit input[name=referurl]').val(window.location.href); layer_loading('姝e湪澶勭悊'); $.ajax({ // async:false, url : __eyou_basefile__ + "?m=user&c=Users&a=login", data: $('#popup_login_submit').serialize(), type:'post', dataType:'json', success:function(res){ if (1 == res.code) { if (5 == res.data.status) { layer.alert(res.msg, {icon: 5, title: false, closeBtn: false},function(){ window.location.href = res.url; }); }else{ window.location.href = res.url; } } else { layer.closeAll(); if ('vertify' == res.data.status) { ey_fleshVerify(); } if (2 == res.data.status) { showErrorAlert(res.msg, 4); } else { layer.msg(res.msg, {icon: 5,time: 1500}); } } }, error:function(e) { layer.closeAll(); showErrorAlert(e.responseText); } }); }