var basic={form:'Erlo',err:{ok:'确认',cl:'取消',tit:'系统提示',reset:'重新请求',sx:'刷新页面',suc:'操作成功',fail:'服务器响应失败',maxtime:'【处理数据过大,请等待】'},load:'erloLoad',email:'lj_f123@126.com',www:'//www.deyuad.com/',loadimg:'style/img/load.gif',path:'/',version:'2.4'},ljTimes,nophone=['passwd','old','set','sq'],fdata=[]; var ue; $(function(){ /*****************************************************/ $('.nameToem').each(function(){ let name=$(this).text(); name=name.substr(0,name.length-2)+''+name.substr(-2)+'' $(this).html(name); }) /*****************************************************/ $(document).on('click','.ljImg',function(){ var html=''; alertLj(html,{img:true}); }) $('.ljSub').click(function(){ $(this).parents('form').submit(); }) $('.ljForm').submit(function(){ let obj=$(this),data=obj.data(); data.action=obj.attr('action'); if(obj.attr('fun')){ return false; } data=getFormDataa(obj,data); if(!data)return false; ajaxForm(obj,data,function(msg){ if(msg && msg.error=='0'){ if(msg.url){ if(msg.url=='/vip' && obj.attr('url')){ window.location.href=obj.attr('url'); }else{ window.location.href=msg.url; }; }else{ if(obj.attr('ourl')) alertLj(msg.html?msg.html:basic.err.suc,{click:'window.location.href=\''+obj.attr('ourl')+'\';'}); else alertLj(msg.html?msg.html:basic.err.suc,{click:'window.location.reload();'}); } }else{ alertLj(msg?(msg.html?msg.html:basic.err.fail):basic.err.fail); obj.removeClass(basic.load); if(obj.find('.codeClick').length>0)obj.find('.codeClick').click(); } },false,function(){ alertLj(basic.err.fail) }) return false; }); var srcs=[],wx=$('meta[name="wx"]').length>0?$('meta[name="wx"]').attr('content'):''; $('.ljimgshow img').each(function(){ srcs.push(wx+$(this).attr('src')) }) $('.ljimgshow img').click(function(){ var src=$(this).attr('src'),img=''; wx=false; if(wx){ var n=$(this).index(); WeixinJSBridge.invoke('imagePreview', { 'current' : n, 'urls' : srcs }); }else{ var box='
'+img+'
关闭
'; $('body').append(box); } }) }) function ajaxForm(obj,data,suc,bef,err){//异步请求 if($('meta[name="web"]').length>0)data['ljweb']=true; if(obj.hasClass(basic.load))return false; $.ajax({ type:'post',data:data,dataType:'json',beforeSend:function(){ if(bef)bef(); obj.addClass(basic.load); },error:function(){ if(err)err(); obj.removeClass(basic.load); },success:function(msg){ if(suc)suc(msg) } }) } function getFormDataa(obj,data){ var e; data['sign']=$('meta[name="sign"]').attr('content'); obj.find('.formValt').each(function(){ data[$(this).attr('name')]=''; }) obj.find('.formValt').each(function(){ if(!e && $(this).attr('nonull') && !$(this).val()){ if(isNaN($(this).attr('nonull'))){ e=$(this).attr('nonull'); }else{ e=$(this).attr('data-placeholder')?$(this).attr('data-placeholder'):$(this).attr('placeholder'); } } if(data[$(this).attr('name')]){ data[$(this).attr('name')]+=' - '+$(this).val(); }else{ data[$(this).attr('name')]=$(this).val(); } }) obj.find('.formVal').each(function(){ if(!e && $(this).attr('nonull') && !$(this).val()){ if(isNaN($(this).attr('nonull'))){ e=$(this).attr('nonull'); }else{ e=$(this).attr('data-placeholder')?$(this).attr('data-placeholder'):$(this).attr('placeholder'); } } if($(this).val()!=$(this).attr('data-placeholder')){ data[$(this).attr('name')]=$(this).val(); } }) obj.find('.formVals:checked').each(function(){ if(data[$(this).attr('name')]){ data[$(this).attr('name')]+=$(this).val()+','; }else{ data[$(this).attr('name')]=','+$(this).val()+','; } }) obj.find('.formValz.on').each(function(){ if(data[$(this).attr('name')]){ data[$(this).attr('name')]+=','+$(this).attr('val'); }else{ data[$(this).attr('name')]=$(this).attr('val'); } }) obj.find('.formValLi').each(function(){ if($(this).find('li.on').length>0){ data[$(this).attr('name')]=$.trim($(this).find('li.on').text()); } }) obj.find('.formValc:checked').each(function(){ data[$(this).attr('name')]=$(this).val(); }) if(ue)data['cont']=ue.getContent(); if(e){ alertLj(e); //alertLj(e+'不能为空'); return false; } return data; } function alertLj(str,obj,ppobj){ if(ljTimes)clearInterval(ljTimes); if($('.alertLjBox').length)$('.alertLjBox').remove(); if(!obj)obj={}; if(typeof obj=='string')obj=o(obj); if(!obj.title)obj.title=basic.err.tit; if(!obj.ok)obj.ok=basic.err.ok; if(!obj.c)obj.c=basic.err.cl; var pobj=ppobj?ppobj:$('body'),pwobj=ppobj?(ppobj.attr('class')?ppobj:$(window)):$(window); var load='',html,close='关闭',title='
'+obj.title+'
',sure=''+obj.ok+'',cancel=''+obj.c+''; var handle='
'+sure+cancel+'
'; html='
'+str+'
'; html='
'+close+title+html+handle+'
'; html='
'+html+'
'; var cssLeft='-'+pwobj.width()+'px',cssTop=0; pobj.append(html).find('.alertLj').css({left:cssLeft,top:cssTop}); if(obj.click){ $('.alertLj .alertSure').attr('onclick',obj.click); }else{ $('.alertLj .alertSure').attr('onclick','alertLjClose()'); } if(obj.noClose)$('.alertLj .alertClose').remove(); if(!obj.cancel)$('.alertLj .alertCancel').remove(); if(obj.cancel && obj.cancelClick)$('.alertLj .alertCancel').attr('onclick',obj.cancelClick); if(str=='load'){ $('.alertLj').addClass('load').find('.alertBox').html(load).append(' '); $('.alertLj .alertClose').remove(); ljLoadTimes(); } cssLeft=(pwobj.width()-$(".alertLj").width())/2; cssTop=(pwobj.height()-$(".alertLj").height())/2.5+pwobj.scrollTop(); $('.alertLj').css({left:cssLeft,top:cssTop},300).fadeIn(300); $('.alertLjBox').height($(document).height()); } function ljLoadTimes(res){ var ljI=1; ljTimes=setInterval(ljTimesGo,1000); function ljTimesGo(){ if($('.ljTimes').length>0){ if(ljI>10){ $('.ljTimes').html((ljI<10?("0"+ljI):ljI)+'s'+(ljI>10?('
'+basic.err.maxtime):'')); } ljI++; }else{ clearInterval(ljTimes); } } } function alertLjClose(fun,now){ if(now) { $('.alertLjBox').hide();fun; }else{ $('.alertLjBox').fadeOut(300,function(){ $(this).remove();fun }); } } function errHandle(error){ if(error.status==810){ alertLj(error.responseText,{ok:basic.err.reset,click:'window.location.reload();',cancel:false,noClose:true}); }else if(error.status==818){ alertLj(error.responseText,{ok:basic.err.sx,click:'window.location.reload();',cancel:false,noClose:true}); }else{ alertLj(basic.err.fail) } }