var ROabc={index:0,splittime:5,ctabci:0,rock:function(){for(var _i in werock)this[_i]=werock[_i];date=js.now();js.ajaxwurbo=true;this.touchobj=$('#mbody').rockdoupull({downbool:true,scrollbool:false,ondownsuccess:function(){RO.reload('none');},ondownbefore:function(){return(RO.index==0||RO.index==1||RO.index==2);},ondrayrlend:function(lx){if(lx<-100)RO.ctab(RO.index+1);if(lx>100)RO.ctab(RO.index-1);}});adminface=js.getoption('adminface','images/noface.png');adminame=js.getoption('adminame',this.bd6('5oiR'));if(adminface)get('myface').src=adminface;$('#myname').html(adminame);$('#my_mz').html(adminame);$('#my_bm').html(js.getoption('deptallname'));$('#my_zw').html(js.getoption('ranking'));var si=sessionStorage.getItem('nowtabs');if(!si)si=0;var dz=location.href;if(dz.indexOf('#list')>0)si=0;if(dz.indexOf('#ying')>0)si=1;if(dz.indexOf('#user')>0)si=2;this.ctab(si);var errmsg=js.request('errmsg');if(!isempt(errmsg))js.wx.alert(this.bd6(errmsg));if(!this.checkyz()){this.ctab=this.lda=function(){};}
this.lda();},lda:function(){this.resiezess();$(window).resize(RO.resiezess);var agentjson=js.getoption('agentjson');var hisjson=js.getoption('historyjson');if(agentjson==''||hisjson==''){this.reload();}else{this.reload();var str=js.getoption('silderarr');if(str)this.showsilder(js.decode(str));RO.showagent(js.decode(agentjson));RO.showhistory(js.decode(hisjson));}
this.initsearch();$('#nowc_div').html(js.getoption('nowcompany'));},reload:function(lx){if(this.index==2){this.reus(lx);}else{this.ress(lx);}},ress:function(lx){this.homeress(lx);},reus:function(lx){js.ajax('dept','data',false,function(ret){RO.reuss(ret);},lx,false,function(){RO.showerror();});},ressw:function(ret){this.loadtime=ret.loadtime;js.setoption('agentjson',ret.agentjson);js.setoption('historyjson',ret.historyjson);var yyda=js.decode(ret.agentjson);this.showcompanyinfo(ret.companyinfo);this.showagent(yyda);this.showhistory(js.decode(ret.historyjson));js.setoption('myhomenum',ret.myhomenum);if(ret.silderarr){var str='';if(ret.silderarr.length>0)str=JSON.stringify(ret.silderarr);js.setoption('silderarr',str);this.showsilder(ret.silderarr);}
this.shagent(yyda);this.reloadok();if(ret.editpass==0){js.wx.alert(RO.bd6('6K!35YWI5L!u5pS55a!G56CB5ZCO5Zyo5L2.55So'),function(){RO.xgmm();});}else{this.timeajaxs();}},shagent:function(d){var stotal=0;var myhomenum=js.getoption('myhomenum');$('#hylidiv').hide();$('#hyli').html('');if(!myhomenum)return;myhomenum=','+myhomenum+',';var bo=false;for(var i=0;i<d.length;i++){stotal+=parseFloat(d[i].stotal);if(myhomenum.indexOf(','+d[i].num+',')>-1){this.showagents(d[i],'hyli','histotal_home_');bo=true;}}
if(bo)$('#hylidiv').show();this.changestotl(false,0);},showmyinfo:function(){js.ajaxbool=false;js.ajax('indexreim','showmyinfo',false,function(ret){RO.sufo(ret);},'none');},sufo:function(ret){js.setoption('deptallname',ret.deptallname);js.setoption('ranking',ret.ranking);adminface=ret.face;js.setoption('adminface',adminface);js.setoption('admintoken',ret.admintoken);adminame=ret.name;js.setoption('adminame',adminame);js.setoption('adminid',ret.id);adminid=ret.id;var sj=ret.mobile;get('myface').src=adminface;$('#myname').html(adminame);$('#my_mz').html(adminame);$('#my_bm').html(ret.deptallname);$('#my_yh').html(ret.user);$('#my_sj').html(''+sj.substr(0,3)+'****'+sj.substr(-4)+'');$('#my_zw').html(ret.ranking);this.showcompanyinfo(ret.companyinfo);if(get('bdwx')){if(ret.bdwx){$('#bdwx').html(''+this.bd6('5bey57uR5a6a')+'(<img src="'+ret.bdwx.headimgurl+'" whdth="16" height="16" align="absmiddle">'+ret.bdwx.nickname+')');}else{$('#bdwx').html(this.bd6('5pyq57uR5a6aLOeCueWHu!e7keWumg::'));}}}};var grouparr=[],userarr=[],agentarr={},RO={};function initbody(){new touchclass({}).reglongmenu();for(var i in ROabc)js.main[i]=ROabc[i];js.main.zhuinit();RO=js.main;js.main.rock();}
var werock={ctab:function(lx){if(!get('tabnav'+lx+''))return;lx=parseFloat(lx);if(lx<0)lx=3;if(lx>3)lx=0;$("[index='m']").hide();var sid='m_index'+lx+'';$('#'+sid+'').show();$('.weui_tabbar a').removeClass('weui_bar_item_on');$('#tabnav'+lx+'').addClass('weui_bar_item_on');var tass=[document.title,this.bd6('5bqU55So'),this.bd6('6IGU57O75Lq6'),adminame];$('.r-header-text').html(tass[lx]);var tabs=['chat','ying','user','my'];if(get('rtb'+this.index+''))get('rtb'+this.index+'').src='images/nav_'+tabs[this.index]+'0.png';if(get('rtb'+lx+''))get('rtb'+lx+'').src='images/nav_'+tabs[lx]+'1.png';this.index=lx;try{sessionStorage.setItem('nowtabs',lx);}catch(e){}
this.touchobj.hidescrolls();if(lx==2){this.showuserlist();}
if(lx==3){this.showmyinfo();}else{setTimeout('RO.showmyinfo()',200);}
this.ctabci++;},resiezess:function(){var hei=RO.geth();$('#mbody').css('height',''+hei+'px');if(RO.touchobj)RO.touchobj.resize();},qihuendrap:function(yd){if(yd>100&&this.index>0)this.ctab(this.index-1);if(yd<-100&&this.index!=3)this.ctab(this.index+1);},showagent:function(a){var i,len=a.length,d,oshow,typearr={},s,ois=0;oshow=$('#m_index1');oshow.html('');for(i=0;i<len;i++){d=a[i];d.i=i;if(!typearr[d.types])typearr[d.types]=[];typearr[d.types].push(d);}
for(ty in typearr){ois++;len=typearr[ty].length;s='<div class="agentp">'+ty+'</div><div id="agentshow_'+ois+'" style="background-color:white" class="weui_grids"></div>';oshow.append(s);for(i=0;i<len;i++){this.showagents(typearr[ty][i],'agentshow_'+ois+'');}}
this.changestotl('agentstotal_',1);},showagents:function(d,shows,qizx){var s='';if(!qizx)qizx='agentstotal_';var s1=d.stotal;if(s1==0)s1='';s='<a href="javascript:;" onclick="RO.openagent('+d.id+')" class="weui_grid">';s+='<div class="weui_grid_icon">';s+=' <img src="'+d.face+'">';s+=' <span id="'+qizx+''+d.id+'" temp="agent'+d.id+'" class="badge">'+s1+'</span>';s+='</div>';s+='<p class="weui_grid_label">';s+=' '+d.name+'';s+='</p>';s+='</a>';agentarr[d.id]=d;$('#'+shows+'').append(s);},changestotl:function(jg,lx){if(!jg)jg='histotal_';var o=$("span[id^='"+jg+"']"),oi=0,i,len=o.length,v1;for(i=0;i<len;i++){v1=$(o[i]).text();if(v1=='')v1='0';oi=oi+parseFloat(v1);}
if(oi==0)oi='';$('#stotal_ss'+lx+'').html(''+oi);},openagent:function(id){var d=agentarr[id],a=[],i,d1,d2,s2;if(!d)return;var url='?m=ying&d=we&num='+d.num+'';if(d.url=='link'&&!isempt(d.urlm))url=d.urlm;$('span[temp="agent'+id+'"]').html('');this.changestotl('agentstotal_',1);this.changestotl(false,0);js.location(url);},changewxtx:function(o1){var tx=o1.checked?'1':'0';js.ajax('indexreim','changewxtx',{tx:tx},function(){},'none',false,false,'get');},tbtx:function(){js.ajax('indexreim','tongbuface',false,function(ret){var fac=ret.face;if(fac){adminface=fac;js.setoption('adminface',fac);get('myface').src=adminface+'?'+Math.random()+'';}
js.msg('success',RO.bd6('5ZCM5q2l5oiQ5Yqf'));},'wait');},bdwx:function(o1){if($(o1).text().indexOf(this.bd6('5bey'))>-1){js.wx.confirm(this.bd6('6KaB6Kej6Zmk57uR5a6a5ZCX77yf'),function(lx){if(lx=='yes')RO.bdwxjc();});return;}
if(!js.iswxbo()){js.wx.alert(this.bd6('6K!35Zyo5b6u5L!h5LiK5omT5byA'));return;}
js.wx.load(this.bd6('5aSE55CG5LitLi4u'));js.location('?m=login&d=we&a=oauthto&state=bang');},bdwxjc:function(){js.ajax('indexreim','wxbdjc',false,function(){js.wx.msgok(RO.bd6('5bey6Kej6Zmk57uR5a6a'));$('#bdwx').html(RO.bd6('5pyq57uR5a6aLOeCueWHu!e7keWumg::'));});},chdw:function(){js.location('?m=index&d=we&a=company');},initsearch:function(){$('#s_inp').keydown(function(){RO.slo();});$('#s_inp').keyup(function(){RO.slo();});},sus:function(){$('#s_bar').addClass('weui_search_focusing');$('#s_inp').focus();},bsor:function(){var val=$('#s_inp').val();if(val==''){$('#s_bar').removeClass('weui_search_focusing');this.hitsoubo(false);}},sqx:function(){$('#s_inp').val('').blur();this.bsor();},scle:function(){$('#s_inp').val('').focus();},slo:function(){clearTimeout(this.sousousoutime);this.sousousoutime=setTimeout('RO.slos()',500);},hitsoubo:function(bo){if(!bo){$('#userdao').show();$('#deptlist').show();$('#list').show();$('#sslst').hide();}else{$('#userdao').hide();$('#deptlist').hide();$('#list').hide();$('#sslst').show().html('');}},slos:function(){var val=$('#s_inp').val();if(val==''){this.hitsoubo(false);return;}
this.hitsoubo(true);var i,a=userarr,len=a.length;for(i=0;i<len;i++){if(a[i].name.indexOf(val)>-1||a[i].deptname.indexOf(val)>-1||a[i].ranking.indexOf(val)>-1||a[i].pingyin.indexOf(val)==0){this.showlist(a[i],true);}}},smenu:function(){js.wx.actionsheet({data:[{name:'<img src="'+adminface+'" align="absmiddle" height="30" width="30"> '+adminame+'',lx:0},{name:this.bd6('5Yi35paw5pWw5o2u'),lx:1},{name:this.bd6('5L!u5pS55a!G56CB'),lx:2},{name:this.bd6('6YCA5Ye655m75b2V'),lx:3}],onclick:function(a){var lx=a.lx;if(lx==0)RO.ctab(3);if(lx==1)RO.reload();if(lx==2)RO.xgmm();if(lx==3)RO.tui();}});},showuserlist:function(){var us=js.getoption('userjson');if(us==''){this.reus();}else{userarr=js.decode(us);grouparr=js.decode(js.getoption('groupjson'));deptarr=js.decode(js.getoption('deptjson'));this.showuserall();this.showgroupall();}},showuserall:function(){var i,len=userarr.length;$('#userdao').html('');$('#userstotal').html('('+len+')');this.showuserlists(deptarr[0].id,0);},showuserlists:function(id,level,o1){if(o1){var as=$('#userdao span');var rb=false;for(var i=0;i<as.length;i++){if(o1==as[i])rb=true;if(rb)$(as[i]).remove();}}
var a=deptarr,i,len=a.length,d,dn;$('#deptlist').html('');$('#list').html('')
for(i=0;i<len;i++){d=a[i];if(d.id==id)dn=d;if(d.pid==id){d.face='images/wjj.png';this.showdeptlsit(d,level+1);}}
if(level>0)$('#userdao').append('<span class="jiantou">＞</span>');$('#userdao').append('<span onclick="RO.showuserlists('+id+',0, this)">'+dn.name+'</span>');len=userarr.length;var noi=0;for(i=0;i<len;i++){d=userarr[i];if(d.deptid==id||d.deptidss.indexOf(','+id+',')>-1){this.showlist(d,false);noi++;}}
if(noi==0&&$('#deptlist').html()==''){$('#list').append('<div style="font-size:14px;text-align:center;padding:30px 10px;color:#cccccc">'+dn.name+' '+this.bd6('5LiL5peg6IGU57O75Lq6')+'</div>');}},showdeptlsit:function(a,level){var s='';s+='<a class="weui_media_box weui_media_appmsg" onclick="RO.showuserlists('+a.id+','+level+')">';s+='  <div class="weui_cell_hd"><img src="'+a.face+'" style="width:34px;margin-right:5px;display:block"></div>';s+='  <div class="weui_cell_bd weui_cell_primary"><p>'+a.name+'';if(a.ntotal>0)s+=' <span style="font-size:12px;color:#888888">('+a.ntotal+')</span>';s+=' </p></div>';s+='</a>';$('#deptlist').append(s);},showlist:function(a,cbo){var s='<a temp="user_'+a.id+'" onclick="RO.opu('+a.id+')" class="weui_media_box weui_media_appmsg">';s+=' <div class="weui_media_hd">';s+='  <img class="weui_media_appmsg_thumb" src="'+a.face+'">';s+=' </div>';s+=' <div class="weui_media_bd">';s+='  <h4 class="weui_media_title">'+a.name+'</h4>';s+='  <p class="weui_media_desc">'+a.deptname+'('+a.ranking+')</p>';s+=' </div>';s+='</a>';if(!cbo){$('#list').append(s);}else{$('#sslst').append(s);}},showgroupall:function(){var i,len2=grouparr.length;$('#glist').html('');$('#glists').html('('+len2+')');for(i=0;i<len2;i++)this.showgroup(grouparr[i],true);},showgroup:function(a,cbo){var s='';s+='<a class="weui_cell"  onclick="RO.openguser(\'group\','+a.id+')">';s+='  <div class="weui_cell_hd"><img src="'+a.face+'" alt="" style="width:34px;margin-right:5px;display:block"></div>';s+='  <div class="weui_cell_bd weui_cell_primary"><p>'+a.name+'</p></div>';s+='</a>';$('#glist').append(s);},shdata:{},showhistory:function(a){var i,len=a.length;$('#historylist').html('');$('#hwu_tems').show();for(i=0;i<len;i++){this.showhistorys(a[i]);}
this.changestotl(false,0);if(i>0)$('#hwu_tems').hide();},showhistorys:function(d,pad){var s,ty,o=$('#historylist'),d1,st,attr;var num=''+d.type+'_'+d.receid+'';$('#index_'+num+'').remove();this.shdata[num]=d;st=d.stotal;if(st=='0')st='';var ops=d.optdt.substr(11,5);if(d.optdt.indexOf(date)!=0)ops=d.optdt.substr(5,5);ty=d.type;var bstr=new touchclass({type:ty,receid:d.receid,onlongclick:function(){RO.clickitems(this.type,this.receid,this.obj)},onclick:function(){RO.openguser(this.type,this.receid);}}).touchstring();s='<a id="index_'+num+'" '+bstr+' class="weui_media_box weui_media_appmsg">';s+=' <div class="weui_media_hd">';s+='  <img class="weui_media_appmsg_thumb" src="'+d.face+'">';s+=' </div>';s+=' <div class="weui_media_bd">';s+='  <span id="histotal_'+num+'" class="badge">'+st+'</span>';s+='  <font >'+ops+'</font>';s+='  <h4 class="weui_media_title">'+d.name+'</h4>';s+='  <p class="weui_media_desc">'+this.bd6(d.cont)+'</p>';s+=' </div>';s+='</a>';if(!pad){o.append(s);}else{o.prepend(s);}},clickitems:function(ty,id,o){var o1=$(o),num=''+ty+'_'+id+'',d=this.shdata[num];var da=[{name:this.bd6('5omT5byA'),lx:0}];if(d&&d.stotal>0)da.push({name:this.bd6('5qCH6K!G5bey6K!7'),lx:2});da.push({name:this.bd6('5Yig6Zmk5q2k6K6w5b2V'),lx:1});js.showmenu({data:da,onclick:function(a){var lx=a.lx;if(lx==0){RO.openguser(ty,id);}
if(lx==1){o1.remove();var tst=$('#historylist').text();if(tst=='')$('#hwu_tems').show();js.ajax('reim','delhistory',{type:ty,gid:id},false,'none');}
if(lx==2){RO.biaoyidu(ty,id,true);}}});},opu:function(id){js.location('?a=userinfo&d=we&uid='+id+'');},biaoyidu:function(ty,id,lbo){if(lbo){var num=''+ty+'_'+id+'';$('#histotal_'+num+'').html('');this.changestotl(false,0);var d=this.shdata[num];if(d)d.stotal='0';}
js.ajax('reim','yiduall',{type:ty,gid:id},false,'none');},openguser:function(ty,id){var num=''+ty+'_'+id+'';$('#histotal_'+num+'').html('');this.changestotl(false,0);if(ty=='agent'){var d=this.shdata[num];var url='';if(d&&d.stotal>0&&!isempt(d.xgurl)){d.stotal='0';var xga=d.xgurl.split('|');if(xga[1]>0)url='task.php?a=x&num='+xga[0]+'&mid='+xga[1]+'';}
if(!url){this.openagent(id);}else{this.biaoyidu(ty,id,false);js.location(url);}}else{js.location('?m=chat&d=we&type='+ty+'&uid='+id+'');}},tui:function(){js.wx.confirm(this.bd6('56Gu5a6a6KaB6YCA5Ye657O757uf5ZCX77yf'),function(lx){if(lx=='yes')RO.tuis();});},tuis:function(){js.ajax('login','loginexit',false,function(){js.wx.msgok(RO.bd6('5bey5oiQ5Yqf6YCA5Ye6'),function(){js.location('?m=login&d=we');},1);});},cusr:function(lx){$("#uslx div").removeClass('active');$("#uslx_"+lx+"").addClass('active');$("div[temp='us']").hide();$("div[temp='us']:eq("+lx+")").show();},timeajaxs:function(){clearTimeout(this.homeretime);if(this.loadtime)this.homeretime=setTimeout(function(){RO.timeajax()},this.splittime*1000);},timeajax:function(){js.ajax('indexreim','loadhit',{time:this.loadtime},function(ret){RO.loadtime=ret.loadtime;if(ret.rows.length>0){RO.shownewhis(ret.rows);}
RO.timeajaxs();},'none',false,function(){js.msg();RO.timeajaxs();},'get');},shownewhis:function(a){var i,len=a.length,d=false;for(i=0;i<len;i++){if(!d&&a[i].stotal>0)d=a[i];this.showhistorys(a[i],true);}
this.changestotl(false,0);if(i>0)$('#hwu_tems').hide();},showcompanyinfo:function(info){if(info){this.companyinfo=info;var neme=info.name;js.setoption('nowcompany',neme);$('#nowc_div').html(neme);}},showsilder:function(a){if(this.showsilderobj)this.showsilderobj.remove();if(!a||a.length==0)return;this.showsilderobj=$.rocksilder({view:'home_silder',titlebool:true,data:a,onclick:function(d){js.location(d.url);}});},reuss:function(ret){js.setoption('deptjson',ret.deptjson);js.setoption('userjson',ret.userjson);js.setoption('groupjson',ret.groupjson);deptarr=js.decode(ret.deptjson);userarr=js.decode(ret.userjson);grouparr=js.decode(ret.groupjson);this.showuserall();this.showgroupall();this.reloadok();}}