reim_xina.js 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514
  1. /**
  2. * REIM即时通信主js-最新版本
  3. * caratename:雨中磐石(rainrock)
  4. * caratetime:2018-11-01 21:40:00
  5. * homepage:www.rockoa.com
  6. */
  7. var agentarr={},userarr={},grouparr={},cnum='',windowfocus=true,jietubool=false;
  8. var reim={
  9. chatobj:{},
  10. maindata:{},
  11. nowtabs:'home',
  12. initci:0,
  13. timeloads:0,
  14. ruloadtime:5*60, //5分钟
  15. init:function(){
  16. js.ajaxwurbo = true;
  17. this.centlistobj = $('#centlist');
  18. js.xpbodysplit = 0;
  19. date = js.now('Y-m-d');
  20. nwjs.init();
  21. bodyunload=function(){
  22. nwjs.removetray();
  23. reim.onoffline(0);
  24. }
  25. this.resize();
  26. nwjs.serverdata=function(d){
  27. return reim.serverdata(d);
  28. }
  29. //var sw = js.getoption('setchatlistw');
  30. //if(sw)$('#centlist').css('width',''+sw+'px');
  31. $(window).resize(this.resize);
  32. $(window).focus(function(){windowfocus=true;im.windowfocus();reim.lastload();});
  33. $(window).blur(function(){windowfocus=false});
  34. //数秒
  35. setInterval('reim.timeload()', 1000);
  36. var fse=js.getoption('loginface');
  37. token =js.getoption('admintoken');
  38. if(fse)get('myface').src=fse;
  39. nwjs.createtray(document.title+'-'+adminname, 1);
  40. strformat.ismobile=0;
  41. //禁止后退
  42. try{
  43. history.pushState(null, null, document.URL);
  44. window.addEventListener('popstate', function (){
  45. history.pushState(null, null, document.URL);
  46. });
  47. }catch(e){}
  48. this.initload();
  49. this.centlistobj.perfectScrollbar();
  50. uploadobj = $.rockupload({
  51. inputfile:'allfileinput',
  52. initpdbool:false,
  53. updir:'reimchat',
  54. urlparams:{noasyn:'no',shuiyin:'size'}, //不需要同步到文件平台上
  55. onchange:function(d){
  56. im.sendfileshow(d);
  57. },
  58. onprogress:function(f,per,evt){
  59. im.upprogresss(per);
  60. },
  61. onsuccess:function(f,str,o1){
  62. im.sendfileok(f,str);
  63. },
  64. onerror:function(str){
  65. js.msg('msg', str);
  66. im.senderror();
  67. }
  68. });
  69. strformat.upobj = uploadobj;
  70. js.setoption('kefulist', '');
  71. $('body').keydown(function(e){
  72. return reim.bodykeydown(e);
  73. });
  74. //注册推送提醒的
  75. var ssrc = js.getoption('soundsrc');
  76. if(!ssrc)ssrc='web/res/sound/email.mp3';
  77. notifyobj=new notifyClass({
  78. title:'系统提醒',
  79. sound:ssrc,
  80. sounderr:'',
  81. soundbo:this.getsound(), //是否要声音
  82. showbool:false
  83. });
  84. this.righthistroboj = $.rockmenu({
  85. data:[],
  86. itemsclick:function(d){
  87. reim.rightclick(d);
  88. }
  89. });
  90. $('#reimcog').click(function(){
  91. reim.clickcog(this);
  92. return false;
  93. });
  94. $('#homeplus').click(function(){
  95. reim.clickcog(get('reimcog'));
  96. return false;
  97. });
  98. document.ondragover=function(e){e.preventDefault();};
  99. document.ondrop=function(e){e.preventDefault();};
  100. //注册全局ajax的错误
  101. js.ajaxerror=function(msg,code){
  102. if(code==401){
  103. js.msg();
  104. js.msgerror('登录失效,重新登录');
  105. if(!nwjsgui){
  106. js.location('/users/login?backurl=reim');
  107. }else{
  108. js.location('/reim/login.html');
  109. }
  110. }
  111. }
  112. if(!nwjsgui){
  113. $('#closediv').remove();
  114. }
  115. $('#reim_keysou').keyup(function(){reim.searchss();});
  116. $('#reim_keysou').click(function(){reim.searchss();});
  117. },
  118. resize:function(){
  119. viewheight = winHb(); //可操作高度
  120. $('#mindivshow').css('height',''+(viewheight)+'px');
  121. if(reim.centlistobj)reim.centlistobj.css('height',''+(viewheight-60)+'px');
  122. $('#viewzhulist').css('height',''+viewheight+'px');
  123. var obj = $('div[resizeh]'),o,hei;
  124. for(var i=0;i<obj.length;i++){
  125. o = $(obj[i]);
  126. hei=parseInt(o.attr('resizeh'));
  127. o.css('height',''+(viewheight-hei)+'px');
  128. }
  129. //控制最小宽高
  130. if(nwjsgui){
  131. var w1 = 900,h1 = 600;
  132. var wid = winWb();
  133. var hei = winHb();
  134. if(wid<w1)nwjs.win.width=w1;
  135. if(hei<h1)nwjs.win.height=h1;
  136. }
  137. },
  138. timeload:function(){
  139. this.timeloads++;
  140. //刷新
  141. if(this.timeloads >= this.ruloadtime){
  142. this.timeloads = 0;
  143. this.initload();
  144. }
  145. //if(this.timeloads==5)this.getonline();//获取在线人员id
  146. },
  147. bodykeydown:function(e){
  148. var code = e.keyCode;
  149. if(code==27){
  150. if($.imgviewclose())return false;
  151. var objt = $('div[tanbodynew]');
  152. if(objt.length>0){
  153. js.tanclose($(objt[objt.length-1]).attr('tanbodynew'));return false;
  154. }
  155. if(get('xpbg_bodydds')){
  156. js.tanclose($('#xpbg_bodydds').attr('xpbody'));
  157. }else{
  158. this.closenowtabss();
  159. }
  160. return false;
  161. }
  162. if(code==65 && e.altKey){//Alt+A截屏
  163. try{this.chatobj[this.nowtabs].cropScreen();}catch(e){}
  164. return false;
  165. }
  166. },
  167. winclose:function(){
  168. nwjs.win.hide();
  169. },
  170. winzuida:function(){
  171. if(!this.zdhbo){
  172. nwjs.win.maximize();
  173. this.zdhbo=true;
  174. }else{
  175. nwjs.win.unmaximize();
  176. this.zdhbo=false;
  177. }
  178. },
  179. changetabs:function(ind){
  180. $('div[id^="changetabs"]').removeClass('leftactive');
  181. $('div[id^="centshow"]').hide();
  182. $('#changetabs'+ind+'').addClass('leftactive');
  183. $('#centshow'+ind+'').show();
  184. if(ind==1)this.showdept();
  185. if(ind==2){
  186. $('#maincenter').hide();
  187. this.showagent(true);
  188. }else{
  189. this.hideagent();
  190. $('#maincenter').show();
  191. }
  192. this.centlistobj.scrollTop(0);
  193. this.centlistobj.find('.ps-scrollbar-y-rail').hide();
  194. this.showbadge('chat');
  195. },
  196. getapiurl:function(m,a,lx){
  197. if(lx=='gout')return this.outgroup.geturl(a);
  198. if(lx=='zixun' || lx=='wait')m='rockkefu';
  199. var dzs = 'api.php?m='+m+'&a='+a+'&cfrom=reim&adminid='+adminid+'&token='+token+'';
  200. if(companynum)dzs+='&dwnum='+companynum+'';
  201. return dzs;
  202. },
  203. //ajax访问处理
  204. ajax:function(url,cans, fun, lx,efun){
  205. if(!lx)lx='get';
  206. if(!fun)fun=function(){}
  207. if(!efun)efun=function(){}
  208. js.ajaxbool = false;
  209. js.ajax(url,cans,function(ret){
  210. if(ret.code==200){
  211. fun(ret);
  212. }else if(ret.code==199){
  213. if(!get('confirm_main'))js.confirm(ret.msg, function(){
  214. reim.exitlogin(true);
  215. });
  216. }else{
  217. js.msg('msg',ret.msg);
  218. efun(ret);
  219. }
  220. },''+lx+',json', efun);
  221. },
  222. initloads:function(){
  223. $('#mainreload').html(''+js.ling(12)+' 刷新中...');
  224. this.initload(true);
  225. },
  226. lastload:function(){
  227. if(!this.loadtime)this.loadtime = parseInt(js.now('time') * 0.001);
  228. this.ajax(this.getapiurl('indexreim','loadhit'),{'time':this.loadtime}, function(ret){
  229. var da = ret.data;
  230. reim.lastloads(da);
  231. });
  232. },
  233. lastloads:function(da){
  234. this.loadtime = da.loadtime;
  235. var i,ds=da.rows;
  236. for(i=0;i<ds.length;i++){
  237. this.showhistorys(ds[i], true);
  238. }
  239. },
  240. //初始加载数据
  241. initload:function(bo){
  242. this.initbool = true;
  243. this.ajax(this.getapiurl('indexreim','indexinit'),{'initci':this.initci,'gtype':'reim'}, function(ret){
  244. reim.initci++;
  245. reim.showdata(ret.data);
  246. if(bo)reim.reloaduser();
  247. $('#mainreload').html('<i class="icon-refresh"></i> 刷新');
  248. });
  249. },
  250. firstpid:0,
  251. showdata:function(ret){
  252. if(!ret.userjson)return;
  253. this.loadtime = ret.loadtime;
  254. this.lastloaddt = ret.loaddt;
  255. this.maindata.darr = js.decode(ret.deptjson);
  256. this.maindata.uarr = js.decode(ret.userjson);
  257. this.maindata.garr = js.decode(ret.groupjson);
  258. this.maindata.harr = js.decode(ret.historyjson);
  259. this.onlinearr = ret.onlinearr;
  260. this.firstpid = this.maindata.darr[0].pid;
  261. if(!this.showconfigarr){
  262. this.showconfigarr = ret.config;
  263. this.websocketlink(ret.config);
  264. }
  265. var aarr = js.decode(ret.agentjson);
  266. var cbarr = {},i;
  267. for(i=0;i<aarr.length;i++){
  268. if(!cbarr[aarr[i].types])cbarr[aarr[i].types]=[];
  269. cbarr[aarr[i].types].push(aarr[i]);
  270. }
  271. this.maindata.aarr=cbarr;
  272. aarr = this.maindata.garr;
  273. for(i=0;i<aarr.length;i++){
  274. grouparr[aarr[i].id]=aarr[i];
  275. }
  276. aarr = this.maindata.uarr;
  277. for(i=0;i<aarr.length;i++){
  278. userarr[aarr[i].id]=aarr[i];
  279. }
  280. this.showagent(false);
  281. this.myip = ret.ip;
  282. this.outgroupopen = ret.outgroupopen;
  283. this.showhistory(this.maindata.harr);
  284. this.outgroup.loaddata(ret.outunum,0);
  285. if(this.kefu)this.kefu.loaddata();
  286. if(ret.editpass==0)this.editpass('请先修改密码后在使用','none');
  287. },
  288. //搜索联系人/会话/应用
  289. searchss:function(){
  290. clearTimeout(this.searchsstime);
  291. this.searchsstime=setTimeout('reim.searchssss()',500);
  292. if(!this.searchright)this.searchright=$.rockmenu({
  293. data:[],iconswh:20,width:210,
  294. itemsclick:function(d){
  295. reim.searchclick(d);
  296. }
  297. });
  298. },
  299. searchclick:function(d){
  300. var ty = d.type;
  301. if(ty=='user')this.showuserinfo(d.xuoi);
  302. if(ty=='group')this.openchat(d.type,d.id,d.name,d.icons);
  303. if(ty=='agent')this.openagenh(d.id);
  304. },
  305. searchssss:function(){
  306. var o = $('#reim_keysou'),val=strreplace(o.val());
  307. var d=[];
  308. if(val==''){
  309. this.searchright.hide();
  310. return;
  311. }
  312. val=val.toLowerCase();
  313. var off=o.offset(),sid,a,s1,arr,i,oi=1;
  314. arr = this.maindata.uarr;
  315. for(i=0;i<arr.length;i++){
  316. a=arr[i];
  317. if(a.name.indexOf(val)>-1 || a.pingyin.indexOf(val)==0 || a.deptname.indexOf(val)>-1 || a.ranking.indexOf(val)>-1){
  318. s1=''+a.name+'<font color=#888888>('+a.ranking+')</font>';
  319. d.push({name:s1,id:a.id,icons:a.face,type:'user',xuoi:i});
  320. oi++;
  321. }
  322. if(oi>10)break;//最多显示10人
  323. }
  324. arr = this.maindata.garr;
  325. for(i=0;i<arr.length;i++){
  326. a=arr[i];
  327. if(a.name.indexOf(val)>-1){
  328. s1=''+a.name+'<font color=#888888>(会话)</font>';
  329. d.push({name:s1,id:a.id,icons:a.face,type:'group'});
  330. }
  331. }
  332. for(sid in agenharr){
  333. a=agenharr[sid];
  334. if(a.name.indexOf(val)>-1){
  335. s1=''+a.name+'<font color=#888888>(应用)</font>';
  336. d.push({name:s1,id:a.id,icons:a.face,type:'agent'});
  337. }
  338. }
  339. if(d.length==0){
  340. this.searchright.hide();
  341. return;
  342. }
  343. this.searchright.setData(d);
  344. this.searchright.showAt(off.left+1,off.top+30);
  345. },
  346. websocketlink:function(a){
  347. if(this.connectbool){
  348. this.serverstatus(1);
  349. return false;
  350. }
  351. if(!a){
  352. this.serverstatus(3);
  353. return false;
  354. }
  355. var wsurl = jm.base64decode(a.wsurl),receid = a.recid;
  356. this.showconfigarr = a;
  357. if(isempt(wsurl) || wsurl.indexOf('ws')<0){
  358. this.serverstatus(3);
  359. return false;
  360. }
  361. clearTimeout(this.relianshotime_time);
  362. websocketobj = new websocketClass({
  363. adminid:adminid,
  364. reimfrom:receid,
  365. wshost:wsurl,
  366. sendname:adminname,
  367. onerror:function(o,ws){
  368. reim.connectbool=false;
  369. reim.serverstatus(0);
  370. js.msg('msg','无法连接服务器1<br><span id="lianmiaoshoetime"></span><a href="javascript:;" onclick="reim.connectservers()">[重连]</a>',0);
  371. reim.relianshotime(30);
  372. },
  373. onmessage:function(str){
  374. reim.connectbool=true;
  375. clearTimeout(reim.relianshotime_time);
  376. var a=js.decode(str);
  377. reim.receivemesb(a);
  378. },
  379. onopen:function(){
  380. reim.connectbool=true;
  381. reim.serverstatus(1);
  382. clearTimeout(reim.relianshotime_time);
  383. js.msg('none');
  384. reim.initnotify();
  385. setTimeout('reim.getonline()',1000);
  386. setTimeout('reim.onoffline(1)',2000);
  387. },
  388. onclose:function(o,e){
  389. reim.connectbool=false;
  390. if(reim.otherlogin)return;
  391. reim.serverstatus(0);
  392. js.msg('msg','连接已经断开了<br><span id="lianmiaoshoetime"></span><a href="javascript:;" onclick="reim.connectservers()">[重连]</a>',0);
  393. reim.relianshotime(10);
  394. }
  395. });
  396. },
  397. connectservers:function(){
  398. if(this.connectbool){
  399. this.serverstatus(1);
  400. return;
  401. }
  402. var bo = this.websocketlink(this.showconfigarr);
  403. if(bo)js.msg('wait','连接中...');
  404. },
  405. serverstatus:function(lx){
  406. var s = '<font color="green">已连接</font>';s='';
  407. if(lx==0)s='<font color="red">未连接</font>'
  408. if(lx==2)s='<font color="#ff6600">在别处连接</font>'
  409. if(lx==3)s='<font color="blue">没服务端</font>';
  410. $('#reim_statusserver').html(s);
  411. },
  412. relianshotime:function(oi){
  413. clearTimeout(this.relianshotime_time);
  414. $('#lianmiaoshoetime').html('('+oi+'秒后重连)');
  415. if(oi<=0){
  416. this.connectservers();
  417. }else{
  418. this.relianshotime_time=setTimeout('reim.relianshotime('+(oi-1)+')',1000);
  419. }
  420. },
  421. showdept:function(id){
  422. if($('#showdept').html()==''){
  423. this.reloaduser();
  424. }else{
  425. }
  426. },
  427. initnotify:function(){
  428. var lx=notifyobj.getaccess();
  429. if(lx!='ok'){
  430. //js.msg('msg','为了可及时收到信息通知 <br>请开启提醒,<span class="zhu cursor" onclick="reim.indexsyscogss()">[开启]</span>',-1);
  431. }
  432. },
  433. indexsyscogs:function(){
  434. var str = notifyobj.getnotifystr('reim.indexsyscogss()');
  435. return '桌面通知提醒'+str+'';
  436. },
  437. indexsyscogss:function(){
  438. notifyobj.opennotify(function(){
  439. js.msg('success', reim.indexsyscogs());
  440. });
  441. },
  442. reloaduser:function(){
  443. $('#showdept').html('');
  444. this.showuserlists(this.firstpid,0, 'showdept');
  445. this.showgroup();
  446. },
  447. //服务端发消息调用opener.reim.serversend(a);
  448. serversend:function(a){
  449. if(!this.connectbool)return false;
  450. websocketobj.send(a);
  451. return true;
  452. },
  453. //获取在线人员
  454. getonline:function(){
  455. this.serversend({'atype':'getonline'});
  456. },
  457. onoffline:function(on){
  458. this.serversend({'atype':'send','type':'onoffline','online':on,'receid':'all'});
  459. },
  460. //别的地方登录
  461. otherlogins:function(){
  462. this.otherlogin = true;
  463. var msg='已在别的地方连接了';
  464. js.msg('success', msg, -1);
  465. this.serverstatus(2);
  466. },
  467. //收到推送消息
  468. receivemesb:function(d, lob){
  469. var lx=d.type,sendid=d.adminid;
  470. d.zijiid = adminid;
  471. if(lx=='offoline'){
  472. this.otherlogins();
  473. return;
  474. }
  475. if(d.optdt){
  476. var time = parseInt(js.now('time', d.optdt) * 0.001);
  477. this.loadtime = time;
  478. }
  479. if(lx=='user' || lx=='group'){
  480. if(sendid!=adminid)this.receivechat(d);
  481. }
  482. if(lx=='agent'){
  483. this.receiveagenh(d);
  484. nwjs.jumpicon();
  485. }
  486. if(lx=='chehui'){
  487. $('#qipaocont_mess_'+d.messid+'').html(js.getmsg(jm.base64decode(d.cont),'green'));
  488. this.historyreload();
  489. }
  490. if(lx=='getonline'){
  491. this.addonline(d.online, true, 1);
  492. }
  493. if(lx=='onoffline'){
  494. this.addonline(sendid, false, d.online);
  495. }
  496. if(lx=='calltonghua'){
  497. this.calltonghua(d);
  498. }
  499. },
  500. addonline:function(s1,isa,zt){
  501. s1 = ''+s1+'';
  502. var a1 = s1.split(','),i,i1;
  503. if(isa)for(i in this.onlinearr)this.onlinearr[i].reim=0;
  504. for(i=0;i<a1.length;i++){
  505. i1 = a1[i];
  506. if(!this.onlinearr[i1])this.onlinearr[i1] = {reim:0,mobile:0,web:''};
  507. if(zt==2){this.onlinearr[i1].mobile=1;}else{this.onlinearr[i1].reim=zt;}
  508. }
  509. if(!isa){
  510. var o1 = $('div[temp="usname_user_'+s1+'"]');
  511. o1.find('font').remove();
  512. var str = this.getonlinestr(s1);
  513. if(str)o1.append(str);
  514. }
  515. },
  516. getonlinestr:function(uid){
  517. var str = '';
  518. var d = this.onlinearr[uid];
  519. this.nowonlinearr = d;
  520. if(!d)return str;
  521. if(d.reim==1)str+='<font title="PC端在线" class="zhu" style="font-size:10px;margin-left:5px"><i class="icon-desktop"></i></font>';
  522. if(d.mobile==1)str+='<font title="APP在线" class="zhu" style="font-size:10px;margin-left:5px"><i class="icon-tablet"></i></font>';
  523. return str;
  524. },
  525. showuserlists:function(pid,xu, svie){
  526. var o = $('#'+svie+'');
  527. var tx= o.text();
  528. if(tx){if(pid!=0){o.toggle();}return;}
  529. var a =this.maindata.uarr,i,len=a.length,d,dn,s='',wfj,zt,sids;
  530. for(i=0;i<len;i++){
  531. d=a[i];
  532. if(!userarr[d.id])userarr[d.id]=d;
  533. sids = ','+d.deptids+',';
  534. if(pid==d.deptid || sids.indexOf(','+pid+',')>-1){
  535. zt=this.getonlinestr(d.id);
  536. s='<div class="lists" onclick="reim.showuserinfo('+i+')" style="padding-left:'+(xu*20+10)+'px" >';
  537. s+='<table cellpadding="0" border="0" width="100%"><tr>';
  538. s+='<td style="padding-right:5px"><div style="height:24px;overflow:hidden"><img src="'+d.face+'" style="height:24px;width:24px"></div></td>';
  539. s+='<td align="left" width="100%"><div temp="usname_user_'+d.id+'" class="name">'+d.name+''+zt+'</div></td>';
  540. s+='</tr></table>';
  541. s+='</div>';
  542. o.append(s);
  543. }
  544. }
  545. a = this.maindata.darr;
  546. len=a.length;
  547. for(i=0;i<len;i++){
  548. d = a[i];
  549. if(d.pid==pid){
  550. wfj = 'icon-folder-close-alt';
  551. s='<div class="lists" style="padding-left:'+(xu*20+10)+'px" onclick="reim.showuserlists('+d.id+','+(xu+1)+',\'showdept_'+d.id+'\')">';
  552. s+=' <i class="'+wfj+'"></i> '+d.name+'';
  553. if(d.ntotal>0)s+=' <span style="font-size:12px;color:#888888">('+d.ntotal+')</span>';
  554. s+='</div>';
  555. s+='<span id="showdept_'+d.id+'"></span>';
  556. o.append(s);
  557. if(xu==0)this.showuserlists(d.id, xu+1, 'showdept_'+d.id+'');
  558. }
  559. }
  560. },
  561. showgroup:function(){
  562. var a =this.maindata.garr,ds=[],i;
  563. for(i=0;i<a.length;i++)ds.push(a[i]);
  564. if(this.outgroupopen=='open' && this.outgrouplist){
  565. for(i=0;i<this.outgrouplist.length;i++){
  566. this.outgrouplist[i].type1='gout';
  567. ds.push(this.outgrouplist[i]);
  568. }
  569. }
  570. var len=ds.length,d,s='',s1,lx;
  571. s='<div style="padding:5px;margin-top:5px;color:#aaaaaa;border-bottom:var(--border)">会话('+len+')</div>';
  572. for(i=0;i<len;i++){
  573. d = ds[i];
  574. lx= d.type1;
  575. if(!lx)lx='group';
  576. s1= this.grouptype(d.deptid,lx);
  577. s+='<div onclick="reim.openchat(\''+lx+'\',\''+d.id+'\',\''+d.name+'\',\''+d.face+'\')" class="lists">';
  578. s+='<table cellpadding="0" border="0" width="100%"><tr>';
  579. s+='<td style="padding-right:5px"><div style="height:24px;overflow:hidden"><img src="'+d.face+'" style="height:24px;width:24px"></div></td>';
  580. s+=' <td align="left" width="100%"><div class="name">'+d.name+''+s1+'</div></td>';
  581. s+='</tr></table>';
  582. s+='</div>';
  583. }
  584. $('#showgroup').html(s)
  585. },
  586. historyreload:function(){
  587. this.ajax(this.getapiurl('indexreim','gethistory'),{id:0},function(
  588. ret){
  589. var data = ret.data;
  590. reim.showhistory(data);
  591. });
  592. },
  593. sortpaxh:function(d1,d2){
  594. if(d1.optdt > d2.optdt){
  595. return -1;
  596. }else if(d1.optdt < d2.optdt){
  597. return 1;
  598. }else{
  599. return 0;
  600. }
  601. },
  602. showhistory:function(a){
  603. var outstr = js.getoption('outgrouplist0'),i,outa,ds=[];
  604. for(i=0;i<a.length;i++)ds.push(a[i]);
  605. if(outstr && this.outgroupopen=='open'){
  606. outa = JSON.parse(outstr);
  607. for(i=0;i<outa.length;i++)ds.push(outa[i]);
  608. ds.sort(this.sortpaxh);
  609. }
  610. outstr = js.getoption('kefulist');
  611. if(outstr){
  612. outa = JSON.parse(outstr);
  613. for(i=0;i<outa.length;i++)ds.push(outa[i]);
  614. ds.sort(this.sortpaxh);
  615. }
  616. var len=ds.length;
  617. $('#historylist').html('');
  618. $('#historylist_tems').show();
  619. for(i=0;i<len;i++){
  620. this.showhistorys(ds[i]);
  621. }
  622. if(i>0)$('#historylist_tems').hide();
  623. },
  624. grouptype:function(did, lx){
  625. var s = '';
  626. if(lx=='gout')did='-1';
  627. if(lx=='zixun')did='-2';
  628. if(isempt(did) || (lx && lx=='user'))return s;
  629. if(did=='1')s=' <span class="reimlabel">全员</span>';
  630. if(did=='-1')s=' <span class="reimlabel2">外部</span>';
  631. //if(did=='-2')s=' <span class="reimlabel3">咨询</span>';
  632. if(did=='-2')s=' <span style="font-size:10px;color:#aaaaaa"><i class="icon-headphones"></i></span>';
  633. if(did>1)s=' <span class="reimlabel1">部门</span>';
  634. return s;
  635. },
  636. showhistorydata:{},
  637. showhistorys:function(d,pad, lex, glx){
  638. var s,ty,o=$('#historylist'),d1,st,nas=d.names,qz=d.qian;
  639. var num = ''+d.type+'_'+d.receid+'';if(num==this.nowtabs)lex=true;
  640. this.showhistorydata[num]=d;
  641. $('#history_'+num+'').remove();
  642. st = d.stotal;if(st=='0')st='';
  643. if(!d.optdt)d.optdt=js.now('now');
  644. var ops = d.optdt.substr(11,5);
  645. if(d.optdt.indexOf(date)!=0)ops=d.optdt.substr(5,5);
  646. ty = d.type;
  647. var cls = lex ? ' active' : '';
  648. var na = d.name;
  649. if(d.title)na = d.title;
  650. var tit = ''+na+'';
  651. if(d.type=='group'){
  652. var d2 = grouparr[d.receid];
  653. if(d2)d.deptid = d2.deptid;
  654. }
  655. if(!nas)nas='';
  656. if(!qz)qz='chat';
  657. if(d.subname){
  658. nas+='<span style="color:'+maincolor+';font-size:10px">@'+d.subname+'</span>';
  659. tit+='@'+d.subname+'';
  660. }
  661. var s1 = this.grouptype(d.deptid,d.type);
  662. s = '<div class="lists'+cls+'" rtype="hist" oncontextmenu="reim.historyright(this,event,\''+num+'\')" tsaid="'+d.receid+'" tsaype="'+d.type+'" style="display:flex;align-items:center;" temp="hist" id="history_'+num+'" onclick="reim.openchat(\''+ty+'\',\''+d.receid+'\',\''+d.name+'\',\''+d.face+'\')">';
  663. s+='<div style="padding-right:8px"><div class="img"><img src="'+d.face+'"></div></div>';
  664. s+='<div style="flex:1;overflow:hidden;">';
  665. s+=' <div style="display:flex;align-items:center;">';
  666. s+=' <div style="flex:1;" title="'+tit+'" id="lname_'+num+'" class="name">'+na+''+nas+''+s1+'</div>';
  667. s+=' <span id="'+qz+'_stotal_'+num+'" class="badge red">'+st+'</span>';
  668. s+=' </div>';
  669. s+=' <div style="display:flex;align-items:center;">';
  670. s+=' <div style="flex:1;padding-right:3px" class="huicont">'+strhtml(jm.base64decode(d.cont))+'</div>';
  671. s+=' <div style="color:#aaaaaa;font-size:10px;white-space:nowrap">'+ops+'</div>';
  672. s+=' </div>';
  673. s+='</div>';
  674. s+='</div>';
  675. if(glx)return s;
  676. if(!pad){o.append(s);}else{o.prepend(s)}
  677. $('#historylist_tems').hide();
  678. this.showbadge('chat');
  679. if(pad && (d.type=='gout' || d.type=='uout'))this.outgroup.updatelist(d.type,d.receid,d);
  680. },
  681. historyright:function(o1,e,num){
  682. var rt = $(o1).attr('rtype');
  683. if(isempt(rt))return false;
  684. this.rightdivobj = o1;
  685. var da=[{name:'打开',lx:0}],d=this.showhistorydata[num];
  686. if(d && d.stotal>0)da.push({name:'标识已读',lx:1});
  687. if(rt.indexOf('hist')>-1){
  688. da.push({name:'删除此记录',lx:2});
  689. }
  690. this.righthistroboj.setData(da);
  691. this.righthistroboj.showAt(e.clientX-3,e.clientY-3);
  692. return false;
  693. },
  694. rightclick:function(d){
  695. var o1 = $(this.rightdivobj),lx=d.lx;
  696. var tsaid = o1.attr('tsaid'),
  697. tsayp = o1.attr('tsaype');
  698. if(lx==0){
  699. this.rightdivobj.onclick();
  700. }
  701. if(lx==2){
  702. o1.remove();
  703. var tst=$('#historylist').text();if(tst=='')$('#historylist_tems').show();
  704. tst=$('#kefulistwait').text();if(tst=='')$('#kefulist_tems').show();
  705. js.ajax(this.getapiurl('reim','delhistory',tsayp),{type:tsayp,gid:tsaid},false,'get');
  706. if(tsayp=='gout' || tsayp=='uout')this.outgroup.dellist(tsayp, tsaid);
  707. this.showbadge('chat');
  708. }
  709. if(lx==1){
  710. var num = ''+tsayp+'_'+tsaid+'';
  711. $('#chat_stotal_'+num+'').html('');
  712. $('#wait_stotal_'+num+'').html('');
  713. var d=this.showhistorydata[num];
  714. if(d)d.stotal='0';
  715. this.showbadge('chat');
  716. this.biaoyd(tsayp,tsaid);
  717. }
  718. },
  719. openmyinfo:function(){
  720. this.showuserinfo(0,userarr[adminid]);
  721. },
  722. showuserinfo:function(oi, d1){
  723. var d = this.maindata.uarr[oi];
  724. if(d1)d=d1;
  725. if(d.email==null)d.email='';
  726. if(d.mobile==null)d.mobile='';
  727. if(d.tel==null)d.tel='';
  728. var num = 'userinfo_'+d.id+'';
  729. var s = '<div align="center"><div align="left" style="width:300px;margin-top:50px">';
  730. s+=' <div style="padding-left:70px"><img id="myfacess" onclick="$(this).imgview()" src="'+d.face+'" height="100" width="100" style="border-radius:50%;border:var(--border)"></div>';
  731. if(d.id==adminid)s+='<div style="padding-left:90px"><a href="javascript:;" id="fupbgonet" onclick="reim.upfaceobj.click()" style="font-size:12px">修改头像</a></div>';
  732. s+=' <div style="line-height:30px;padding:10px;padding-left:20px;"><font color=#888888>姓名:</font>'+d.name+'<br><font color=#888888>部门:</font>'+d.deptallname+'<br><font color=#888888>职位:</font>'+d.ranking+'<br><font color=#888888>性别:</font>'+d.sex+'<br><font color=#888888>电话:</font>'+d.tel+'<br><font color=#888888>手机:</font>'+d.mobile+'<br><font color=#888888>邮箱:</font>'+d.email+'</div>';
  733. s+=' <div style="padding-top:10px;padding-left:50px"><input type="button" value="发消息" onclick="reim.openchat(\'user\',\''+d.id+'\',\''+d.name+'\',\''+d.face+'\')" class="btn">&nbsp; &nbsp; <input onclick="reim.closetabs(\''+num+'\')" type="button" value="关闭" class="btn btn-danger"></div>';
  734. s+='</div></div>';
  735. this.addtabs(num,s);
  736. if(d.id==adminid){
  737. if(!this.upfaceobj)this.upfaceobj=$.rockupload({
  738. inputfile:'upfacess',
  739. uptype:'image',
  740. urlparams:{noasyn:'yes'}, //不需要同步到文件平台上
  741. onsuccess:function(f,str){
  742. var a=js.decode(str);
  743. if(!a.id)return;
  744. reim.saveface(a.id);
  745. },
  746. onchange:function(){
  747. $('#fupbgonet').html('上传中...');
  748. }
  749. });
  750. }
  751. },
  752. saveface:function(fid){
  753. this.ajax(this.getapiurl('reim','changeface'),{id:fid},function(ret){
  754. var face = ret.data;
  755. get('myface').src=face;
  756. get('myfacess').src=face;
  757. adminface=face;
  758. js.setoption('loginface', face);
  759. js.setoption('adminface', face);
  760. $('#fupbgonet').html('修改成功');
  761. });
  762. },
  763. openchat:function(type,reid,na,fac){
  764. var num = ''+type+'_'+reid+'';
  765. $('#chat_stotal_'+num+'').html('');
  766. this.showbadge('chat');
  767. if(type=='agent'){
  768. var d = this.showhistorydata[num];
  769. var url='';
  770. if(d && d.stotal>0 && !isempt(d.xgurl)){
  771. d.stotal='0';
  772. var xga = d.xgurl.split('|');
  773. if(xga[1]>0)url='task.php?a=p&num='+xga[0]+'&mid='+xga[1]+'';
  774. }
  775. if(url==''){
  776. this.openagenh(reid);
  777. }else{
  778. this.biaoyd('agent',reid);
  779. js.open(url,760,500);
  780. }
  781. return;
  782. }
  783. if(type=='wait'){
  784. this.kefu.openwait(this.showhistorydata[num]);
  785. return;
  786. }
  787. var s = '<div>';
  788. s+='<div id="viewtitle_'+num+'" style="height:50px;overflow:hidden;border-bottom:var(--border);">';
  789. s+='</div>';
  790. var hei = 206;
  791. s+='<div resizeh="'+hei+'" id="viewcontent_'+num+'" style="height:'+(viewheight-hei)+'px;overflow:hidden;position:relative;"><div style="margin-top:50px;color:#cccccc" align="center">'+js.ling(30)+'</div></div>';
  792. s+='<div class="toolsliao" style="background:none" id="toolsliao_'+num+'">';
  793. s+=' <span title="表情" tools="emts" class="cursor"><i class="icon-heart"></i></span>';
  794. s+=' <span title="文件/图片" tools="file" class="cursor"><i class="icon-folder-close"></i></span>';
  795. if(nwjsgui){
  796. s+=' <span title="粘贴图片" tools="paste" class="cursor"><i class="icon-paste"></i></span>';
  797. s+=' <span title="截屏(Alt+A)" tools="crop" class="cursor"><i class="icon-cut"></i></span>';
  798. }
  799. if(video_bool && type=='user')s+=' <span title="音视频通话" tools="tonghua" class="cursor"><i class="icon-facetime-video"></i></span>';
  800. s+=' <span title="收藏消息" tools="star" class="cursor"><i class="icon-star"></i></span>';
  801. s+=' <span title="消息记录" tools="jilu" class="cursor"><i class="icon-time"></i></span>';
  802. if(type=='gout')s+=' <span title="@信呼客服" tools="atkf" class="cursor"><i class="icon-headphones"></i></span>';
  803. s+='</div>';
  804. s+='<div style="height:80px;overflow:hidden;"><div style="height:70px;margin:5px"><textarea onpaste="im.readclip(\''+num+'\',event)" class="content" style="background:none;" id="input_content_'+num+'"></textarea></div></div>';
  805. s+='<div style="height:40px;overflow:hidden;"><div align="right" style="padding:9px"><input id="chatclosebtn_'+num+'" class="webbtn" style="background:none;color:#aaaaaa" type="button" value="关闭(C)">&nbsp;<input class="webbtn" style="background:none;color:'+maincolor+'" id="chatsendbtn_'+num+'" type="button" value="发送(S)"></div></div>';
  806. s+='</div>';
  807. var bo = this.addtabs(num,s),sid='input_content_'+num+'';
  808. if(get(sid))get(sid).focus();
  809. if(!bo){
  810. this.chatobj[num]=new chatcreate({
  811. 'type' : type,
  812. 'gid' : reid,
  813. 'num' : num,
  814. 'name' : na,
  815. 'face' : fac
  816. });
  817. }
  818. this.chatobj[num].onshow();
  819. },
  820. biaoyd:function(type,gid){
  821. js.ajax(this.getapiurl('reim','yiduall',type),{type:type,gid:gid},false,'get');
  822. },
  823. receiveagenh:function(d){
  824. var gid = d.gid;
  825. var num = d.type+'_'+gid,stotal=0,msg;
  826. var so = $('#chat_stotal_'+num+'').html();
  827. if(!so)so=0;
  828. stotal = parseInt(so)+1;
  829. this.showhistorys({
  830. 'cont' : d.cont,
  831. 'name' : d.gname,
  832. 'title' : d.title,
  833. 'face' : d.gface,
  834. 'optdt' : d.optdt,
  835. 'type' : d.type,
  836. 'receid' : gid,
  837. 'stotal' : stotal
  838. }, true);
  839. msg = jm.base64decode(d.cont);
  840. msg = msg.replace(/\\n/gi,' ');
  841. var sopenfun=function(b){
  842. js.alertclose();
  843. notifyobj.close();//关闭右下角的提示
  844. if(b.url){
  845. js.open(b.url,760,500);
  846. return true;
  847. }else{
  848. reim.openagenh(b.gid, b.url);
  849. }
  850. return true; //不激活主窗口
  851. }
  852. js.alertclose();
  853. js.confirm(msg,function(jg){if(jg=='yes'){sopenfun(d)}},'','<img src="'+d.gface+'" align="absmiddle" width="20" height="20">&nbsp;'+d.title);
  854. if(this.getzhuom()){
  855. notifyobj.showpopup(msg,{icon:d.gface,url:d.url,gid:gid,title:d.title,rand:num,click:function(b){
  856. return sopenfun(b);
  857. }});
  858. }else{
  859. if(notifyobj.getsound())notifyobj.playsound();
  860. }
  861. nwjs.jumpicon();
  862. },
  863. receivechat:function(d){
  864. var gid = d.gid,lx = d.type,stotal=0,num,msg,name=d.gname,face=d.face,s1='';
  865. if(lx=='user'){
  866. gid = d.adminid;
  867. name= d.sendname;
  868. }
  869. if(lx=='group'){
  870. face = d.gface;
  871. s1 = jm.base64encode(''+d.sendname+':');
  872. if(isempt(face))face = 'images/group.png';
  873. }
  874. if(lx=='gout'){
  875. name = d.title;
  876. }
  877. num = d.type+'_'+gid;
  878. var showtx = true;
  879. if(this.isopentabs(num)){
  880. this.chatobj[num].receivedata(d);
  881. if(this.nowtabs!=num){
  882. this.chatobj[num].newbool=true;
  883. }
  884. }
  885. //if(windowfocus && this.nowtabs==num)showtx=false;
  886. if(windowfocus)showtx=false;
  887. if(d.nottixi)showtx=false;
  888. if(d.atid)showtx = (d.atid==d.zijiid)//不是@我就不要提醒
  889. //未读数
  890. if(this.nowtabs!=num){
  891. var so = $('#chat_stotal_'+num+'').html();
  892. if(!so)so=0;
  893. stotal = parseInt(so)+1;
  894. }
  895. if(d.ismysend)stotal = 0;
  896. if(lx != 'zixun')this.showhistorys({
  897. 'cont' : s1+d.cont,
  898. 'name' : name,
  899. 'face' : face,
  900. 'optdt' : d.optdt,
  901. 'type' : d.type,
  902. 'receid' : gid,
  903. 'stotal' : stotal
  904. }, true, this.nowtabs==num);
  905. if(d.ismysend)return;//自己发的
  906. var nr = jm.base64decode(d.cont);
  907. var title = '会话消息';
  908. msg = '人员['+d.sendname+'],发来一条信息';
  909. if(lx == 'group'){
  910. msg += ',来自['+name+']';
  911. }
  912. if(lx == 'gout'){
  913. title = name;
  914. msg = nr;
  915. }
  916. if(lx == 'zixun'){
  917. title = d.title;
  918. msg = nr;
  919. }
  920. var cans = {
  921. icon:face,sound:d.sound,type:lx,gid:gid,name:name,title:title,rand:num,
  922. click:function(b){if(b.gid)reim.openchat(b.type, b.gid,b.name,b.icon);}
  923. }
  924. if(showtx || nr.indexOf('@'+adminname+'')>-1){
  925. if(this.getzhuom()){
  926. notifyobj.showpopup(msg, cans);
  927. }else{
  928. if(notifyobj.getsound())notifyobj.playsound();
  929. }
  930. nwjs.jumpicon();
  931. showtx = true;
  932. }
  933. if(!showtx && windowfocus && this.nowtabs!=num){
  934. js.msg('success','<div id="idngmsg" class="cursor" align="left"><b>'+title+'</b><br>'+msg+'</div>');
  935. if(cans.gid)$('#idngmsg').click(function(){reim.openchat(cans.type, cans.gid,cans.name,cans.icon);});
  936. if(notifyobj.getsound())notifyobj.playsound();
  937. }
  938. },
  939. addtabs:function(num, s){
  940. var ids = 'tabs_'+num+'',bo;
  941. if(!get(ids)){
  942. var s = '<div tabs="'+num+'" id="'+ids+'">'+s+'</div>';
  943. $('#viewzhulist').append(s);
  944. bo = false;
  945. }else{
  946. bo = true;
  947. }
  948. this.showtabs(num);
  949. return bo;
  950. },
  951. closetabs:function(num){
  952. var ids = 'tabs_'+num+'';
  953. $('#'+ids+'').remove();
  954. var ood = $('#viewzhulist div[tabs]:last');
  955. var snu = ood.attr('tabs');
  956. this.showtabs(snu);
  957. },
  958. closenowtabs:function(){
  959. if(this.nowtabs)this.closetabs(this.nowtabs);
  960. },
  961. closenowtabss:function(){
  962. var nun = this.nowtabs;
  963. if(!nun)return;
  964. if(nun.indexOf('user_')==0 || nun.indexOf('group_')==0 || nun.indexOf('gout_')==0 || nun.indexOf('zixun_')==0 || nun.indexOf('userinfo_')==0)this.closenowtabs();
  965. },
  966. isopentabs:function(num){
  967. return get('tabs_'+num+'');
  968. },
  969. showtabs:function(num){
  970. $('div[tabs]').hide();
  971. var ids = 'tabs_'+num+'';
  972. $('#'+ids+'').show();
  973. $('div[temp]').removeClass('active');
  974. $('#history_'+num+'').addClass('active');
  975. this.nowtabs = num;
  976. },
  977. showagent:function(sbo){
  978. var agedt = this.maindata.aarr,s='',ty,a,len,d,d1,sno,so=0,sodd=1;
  979. s+='<div id="agenhview" resizeh="0" style="height:'+viewheight+'px;overflow:hidden;position:relative;" align="center"><div style="width:80%;padding:20px" align="left">';
  980. agenharr={};
  981. for(ty in agedt){
  982. a = agedt[ty];
  983. len = a.length;
  984. s+='<div style="color:#aaaaaa;padding-left:20px;margin-bottom:10px;padding:5px;border-bottom-width:'+sodd+'px;border-bottom:var(--border)">&nbsp;&nbsp;'+ty+'</div>';
  985. s+='<div class="agenhclsdiv">';
  986. for(i=0;i<len;i++){
  987. d1 = a[i];
  988. if(!agenharr[d1.id])agenharr[d1.id]=d1;
  989. d = agenharr[d1.id];
  990. sno = d.stotal;
  991. so += sno;
  992. if(sno==0)sno='';
  993. s+='<div onclick="reim.openagenh(\''+d.id+'\')" class="agenhcls"><div style="padding-top:5px"><img src="'+d.face+'"></div><div>'+d.name+'</div>';
  994. s+='<span id="agenh_stotal_'+d.id+'" class="badge">'+sno+'</span>';
  995. s+='</div>';
  996. }
  997. s+='</div>';
  998. sodd=1;
  999. }
  1000. s+='</div>';
  1001. if(!sbo){
  1002. if(so==0)so='';
  1003. $('#agenh_stotal').html(so);
  1004. return;
  1005. }
  1006. var bo = this.addtabs('agenh',s);
  1007. if(!bo)$('#agenhview').perfectScrollbar();
  1008. this.showbadge('agenh');
  1009. },
  1010. hideagent:function(){
  1011. if(get('tabs_agenh'))
  1012. this.closetabs('agenh');
  1013. },
  1014. openagenh:function(id, url){
  1015. var d = agenharr[id];
  1016. if(!d){
  1017. js.msg('msg','应用不存在,请刷新');
  1018. return;
  1019. }
  1020. d.stotal=0;
  1021. var num = 'agenh_'+d.id+'';
  1022. $('#agenh_stotal_'+d.id+'').html('');
  1023. this.showagent(false);
  1024. $('#chat_stotal_'+num+'').html('');
  1025. this.showbadge('chat');
  1026. this.biaoyd('agent',d.id);
  1027. var w = screen.width-200,h=screen.height-150,url = d.urlpc;
  1028. if(isempt(url)){
  1029. url = d.urlm;
  1030. if(isempt(url)){
  1031. url = '?d=we&m=ying&num='+d.num+''; //先默认用移动端
  1032. }
  1033. w = 350;
  1034. }
  1035. var jg = (url.indexOf('?')>-1)?'&':'?';
  1036. url+=''+jg+'openfrom=reim';
  1037. //考勤打卡
  1038. if(d.num=='kqdaka'){
  1039. this.opendaka();return;
  1040. }
  1041. if(url.substr(0,4)=='http' && url.indexOf(HOST)<0 && nwjsgui){
  1042. nwjs.openurl(url);
  1043. }else{
  1044. js.open(url, w,h,'agent'+d.num+'');
  1045. }
  1046. },
  1047. //考勤打卡
  1048. opendaka:function(bo){
  1049. var url = '?d=reim&m=ying&a=daka',w = 550;h=300;
  1050. js.open(url, w,h,'agentkqdaka',{},{icon:'images/adddk.png'});
  1051. },
  1052. showbadge:function(lx){
  1053. var obj = $('span[id^="'+lx+'_stotal_"]'),so=0,s1,o,i;
  1054. for(i=0;i<obj.length;i++){
  1055. o = $(obj[i]);
  1056. s1= o.html();
  1057. if(!s1)s1='0';
  1058. so+=parseInt(s1);
  1059. }
  1060. if(so==0)so='';
  1061. $('#'+lx+'_stotal').html(so);
  1062. var zoi = 0;
  1063. so = $('#agenh_stotal').html();
  1064. if(!so)so = 0;
  1065. zoi+=parseInt(so);
  1066. so = $('#chat_stotal').html();
  1067. if(!so)so = 0;
  1068. zoi+=parseInt(so);
  1069. so = $('#wait_stotal').html();
  1070. if(!so)so = 0;
  1071. zoi+=parseInt(so);
  1072. nwjs.changeicon(zoi);
  1073. if(lx=='chat')this.showbadge('wait');
  1074. },
  1075. clickcog:function(o1){
  1076. if(!this.cogmenu)this.cogmenu =$.rockmenu({
  1077. data:[],
  1078. width:120,
  1079. itemsclick:function(d){
  1080. reim.clickcogclick(d);
  1081. }
  1082. });
  1083. var d = [{'name':'消息记录',lx:'jl'},{'name':'刷新',lx:'sx'},{'name':'创建会话',lx:'create'},{'name':'修改密码',lx:'pass'},{'name':'切换主题',lx:'theme'}];
  1084. if(companymode)d.push({'name':'切换单位',lx:'qhqy'});
  1085. if(nwjsgui)d.push({'name':'下载管理器',lx:'down'});
  1086. d.push({'name':'设置',lx:'cog'});
  1087. d.push({'name':'退出',lx:'exit'});
  1088. this.cogmenu.setData(d);
  1089. var off = $(o1).offset();
  1090. this.cogmenu.showAt(60,off.top+d.length*36);
  1091. },
  1092. openrecord:function(){
  1093. var url = '?homeurl=cmVpbSxyZWNvcmQsYXR5cGU9bXk:&homename=5oiR55qE5Lya6K!d6K6w5b2V&menuid=MjI3';
  1094. js.open(url,1000,550,'chatrecord');
  1095. },
  1096. clickcogclick:function(d){
  1097. var lx=d.lx;
  1098. if(lx=='sx'){
  1099. js.loading('刷新中...');
  1100. if(nwjsgui){
  1101. nwjs.reload();
  1102. }else{
  1103. location.reload();
  1104. }
  1105. }
  1106. if(lx=='exit')this.exitlogin();
  1107. if(lx=='cog')this.cogshow();
  1108. if(lx=='jl')this.openrecord();
  1109. if(lx=='create')this.creategroup();
  1110. if(lx=='pass')this.editpass();
  1111. if(lx=='qhqy')this.changecom();
  1112. if(lx=='theme')this.changetheme();
  1113. if(lx=='down')js.open('?d=reim&m=record&a=download', 630,450,'downs');
  1114. },
  1115. //创建会话
  1116. creategroup:function(){
  1117. js.prompt('创建会话','请输入会话名称:',function(lx,v){
  1118. if(lx=='yes'){
  1119. if(!v){js.msg('msg','没有输入会话名称');return false;}
  1120. js.msg('wait','创建中...');
  1121. reim.ajax(reim.getapiurl('reim','createlun'),{val:jm.base64encode(strreplace(v))}, function(da){
  1122. js.msg('success','创建成功,请打开会话窗口邀请人员加入');
  1123. reim.changetabs(1);
  1124. reim.initload(true);
  1125. });
  1126. }
  1127. });
  1128. return false;
  1129. },
  1130. changetheme:function(){
  1131. var zys = ['#1389D3','#99cc66','#003366','#6666CC','#CC3333','#009966','#333333','#990066','#333300','#333366','#99CC99','#663366','#003399','#338899'];
  1132. var h = '<div style="padding:10px"><table height="20px" class="cursor"><tr>';
  1133. var nst = '';
  1134. for(var i=0;i<zys.length;i++){
  1135. nst = (zys[i]==maincolor) ? '✔':'&nbsp;';
  1136. h+='<td width="20px" style="color:white;font-size:12px" align="center" onclick="js.location(\'?d=reim&a=xina&apptheme='+zys[i].substr(1)+'\')" bgcolor="'+zys[i]+'">'+nst+'</td>';
  1137. }
  1138. h+='</tr></table></div>';
  1139. js.tanbody('color','切换主题',310,200,{
  1140. html:h
  1141. });
  1142. },
  1143. editpass:function(bt,cse){
  1144. if(!bt)bt='修改密码';
  1145. if(!cse)cse='';
  1146. js.tanbody('winiframe',bt,350,300,{
  1147. html:'<div style="height:250px;overflow:hidden"><iframe src="" name="openinputiframe" width="100%" height="100%" frameborder="0"></iframe></div>',
  1148. bbar:'none',
  1149. closed:cse
  1150. });
  1151. openinputiframe.location.href='?m=index&d=we&a=editpass&hideheader=true&ofrom=reim';
  1152. },
  1153. changecom:function(){
  1154. js.tanbody('winiframe','切换单位',350,300,{
  1155. html:'<div style="height:250px;overflow:hidden"><iframe src="" name="openinputiframe" width="100%" height="100%" frameborder="0"></iframe></div>',
  1156. bbar:'none'
  1157. });
  1158. openinputiframe.location.href='?m=index&d=we&a=company&hideheader=true&ofrom=reim';
  1159. },
  1160. changecomok:function(){
  1161. js.tanclose('winiframe');
  1162. js.msgok('切换成功');
  1163. location.reload();
  1164. },
  1165. exitlogin:function(bo){
  1166. if(!bo){
  1167. js.confirm('确定要退出系统吗?',function(jg){
  1168. if(jg=='yes')reim.exitlogin(true);
  1169. });
  1170. return;
  1171. }
  1172. if(nwjsgui || 1==1){
  1173. js.loading('退出中...');
  1174. js.ajax(this.getapiurl('login','loginexit'),{},function(ret){
  1175. js.setoption('autologin', '0');
  1176. js.location('?d=reim&a=login&a=xina');
  1177. });
  1178. }else{
  1179. window.close();
  1180. }
  1181. },
  1182. getsound:function(){
  1183. var lx = js.getoption('soundcog'),chs=false;
  1184. if(lx=='')lx='1';
  1185. if(lx==1)chs=true;
  1186. return chs;
  1187. },
  1188. setsound:function(o1){
  1189. var lx=(o1.checked)?'1':'2';
  1190. js.setoption('soundcog', lx);
  1191. notifyobj.setsound(o1.checked);
  1192. },
  1193. getzhuom:function(){
  1194. var lx = js.getoption('zhuomcog'),chs=false;
  1195. if(lx=='')lx='1';
  1196. if(lx==1)chs=true;
  1197. return chs;
  1198. },
  1199. setzhuom:function(o1){
  1200. var lx=(o1.checked)?'1':'2';
  1201. js.setoption('zhuomcog', lx);
  1202. },
  1203. setsendkkj:function(vs){
  1204. js.setoption('sendkuijie', vs);
  1205. },
  1206. changesound:function(o1){
  1207. var src = o1.value;
  1208. js.setoption('soundsrc', src);
  1209. notifyobj.sound = src;
  1210. notifyobj.playsound();
  1211. },
  1212. setchatlistw:function(kg){
  1213. $('#centlist').css('width',''+kg+'px');
  1214. js.setoption('setchatlistw', ''+kg+'');
  1215. },
  1216. cogshow:function(){
  1217. //nw.Window.open('file:///F:/IIS/demo/webrtc_v5_latest/quick-demo-js/index.html');return;
  1218. var chs= (this.getsound())?'checked':'';
  1219. var ch1= (this.getzhuom())?'checked':'';
  1220. var num = 'userinfo_cogshow';
  1221. var s = '<div align="center"><div align="left" style="width:300px;margin-top:40px;padding:15px;background:var(--main-bgcolor);border-radius:5px;border:var(--border)">';
  1222. s+=' <div style="line-height:30px"><b>设置</b></div>';
  1223. s+=' <div style="padding:10px 0px;border-top:var(--border)"><label><input '+ch1+' onclick="reim.setzhuom(this)" type="checkbox">新信息桌面提醒</label></div>';
  1224. s+=' <div style="padding:10px 0px;border-top:var(--border)"><label><input '+chs+' onclick="reim.setsound(this)" type="checkbox">新信息声音提示</label></div>';
  1225. s+=' <div style="padding:10px 0px;border-top:var(--border)">提示声音:<select onchange="reim.changesound(this)" id="changesoundid"><option value="web/res/sound/email.mp3">email.mp3</option><option value="web/res/sound/dong.mp3">dong.mp3</option><option value="web/res/sound/todo.ogg">todo.ogg</option><option value="web/res/sound/niu.mp3">niu.mp3</option><option value="web/res/sound/don1.mp3">don1.mp3</option></select></div>';
  1226. chs = 'checked';
  1227. ch1 = '';
  1228. if(js.getoption('sendkuijie')=='1'){
  1229. ch1='checked';chs='';
  1230. }
  1231. s+=' <div style="padding:10px 0px;border-top:var(--border)">发送快捷键:<label><input onclick="reim.setsendkkj(0)" '+chs+' type="radio" name="sendkuijie">Enter</label>&nbsp; <label><input onclick="reim.setsendkkj(1)" '+ch1+' type="radio" name="sendkuijie">Ctrl+Enter</label></div>';
  1232. //s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid">列表列宽:<label><input onclick="reim.setchatlistw(220)" checked type="radio" name="chatlistw">正常</label>&nbsp; <label><input onclick="reim.setchatlistw(230)" type="radio" name="chatlistw">宽点</label>&nbsp; <label><input onclick="reim.setchatlistw(250)" type="radio" name="chatlistw">大宽</label></div>';
  1233. if(nwjsgui){
  1234. var ips = nwjs.getipmac();
  1235. var d = nw.process.versions;
  1236. var json = nw.App.manifest;
  1237. s+='<div style="padding:10px 0px;border-top:var(--border)">开机启动:<button type="button" class="cursor" onclick="reim.kaijistart(0)">启动</button>&nbsp;<button type="button" class="cursor" onclick="reim.kaijistart(1)">删除</button>&nbsp;<button type="button" class="cursor" onclick="reim.kaijistart(2)">快捷方式</button></div>';
  1238. s+='<div style="padding:10px 0px;border-top:var(--border)">我局域网IP:'+ips.ip+'</div>';
  1239. s+='<div style="padding:10px 0px;border-top:var(--border)">我的MAC地址:'+ips.mac+'</div>';
  1240. s+='<div style="padding:10px 0px;border-top:var(--border)">此客户端版本:V'+json.version+',内核nwjs-'+d.nw+'</div>';
  1241. }
  1242. s+=' <div style="padding:10px 0px;border-top:var(--border)">网络IP:'+this.myip+'</div>';
  1243. s+=' <div style="padding-top:10px;"><input onclick="reim.closetabs(\''+num+'\')" type="button" value="关闭" class="btn btn-danger"></div>';
  1244. s+='</div></div>';
  1245. this.addtabs(num,s);
  1246. get('changesoundid').value=notifyobj.sound;
  1247. },
  1248. kaijistart:function(lx){
  1249. var dz = '加入开机启动.vbs';
  1250. if(lx==1)dz = '删除开机启动.vbs';
  1251. if(lx==2)dz = '创建桌面快捷方式.vbs';
  1252. nwjs.openfile(dz);
  1253. },
  1254. //内部服务处理
  1255. serverdata:function(a){
  1256. var lx = a.atype;
  1257. if(lx=='focus')nwjs.winshow();
  1258. if(lx=='crop')this.cropScreen(true);
  1259. if(lx=='notify')this.shownotify(a);
  1260. if(lx=='openchat')this.openchat(a.id,a.type);
  1261. if(lx=='getlogin')return {uid:adminid,uname:adminname,face:adminface};
  1262. if(lx=='getipmac')return nwjs.getipmac();
  1263. if(lx=='office')nwjs.editoffice(a.paramsstr);
  1264. if(lx=='upfile')return nwjs.filetobase64(a.path);
  1265. if(lx=='gpath')return nwjs.getpath();
  1266. },
  1267. //语音视频通话
  1268. calltonghua:function(d){
  1269. var lx = d.calltype;
  1270. if(lx=='call'){
  1271. var channel = d.th_channel;
  1272. if(js.getoption('nowchannel')==channel)return;
  1273. js.setoption('nowchannel', channel);
  1274. var url =NOWURL+'?d=reim&m=tonghua&channel='+channel+'&id='+d.adminid+'';
  1275. js.open(url, 350,530,'',{},{resizable:false,'always_on_top':true});
  1276. }
  1277. }
  1278. };
  1279. function chatcreate(cans){
  1280. for(var i in cans)this[i]=cans[i];
  1281. strformat.emotspath='web/';
  1282. var me = this;
  1283. this._init = function(){
  1284. this.minid = 999999999;
  1285. this.dktype = false;
  1286. this.showoba = get('viewcontent_'+this.num+'');
  1287. this.showobj = $(this.showoba);
  1288. this.inputobj = $('#input_content_'+this.num+'');
  1289. this.sendbtn = $('#chatsendbtn_'+this.num+'');
  1290. this.listdata = {};
  1291. this.sendinfo = {name:adminname,face:adminface};
  1292. this.loadci = 0;
  1293. this.atid = 0;
  1294. this.uptypes = '*';
  1295. this.createid = 0;
  1296. this.upurl = '';
  1297. this.soulx = '';
  1298. this.soukey = '';
  1299. this.objstr = 'reim.chatobj[\''+this.num+'\']';
  1300. var nstr = js.getoption('receinfo_'+this.num+'');
  1301. if(nstr)this.setreceinfor(js.decode(nstr));
  1302. this.sendbtn.click(function(){
  1303. me.sendcont();
  1304. });
  1305. $('#chatclosebtn_'+this.num+'').click(function(){
  1306. me.closechat();
  1307. });
  1308. this.inputobj.keydown(function(e){
  1309. return me.onkeydown(e);
  1310. });
  1311. this.showtools();
  1312. this.showtitle();
  1313. this.loaddata();
  1314. if(get('tabs_'+this.num+''))get('tabs_'+this.num+'').addEventListener('drop', function(e) {
  1315. var files = e.dataTransfer;
  1316. me.filedrop(files);
  1317. }, false);
  1318. this.showobj.click(function(e){
  1319. me.clickbody(this,e);
  1320. });
  1321. this.showobj.scroll(function(){
  1322. me.onsscroll();
  1323. });
  1324. this.inputobj.contextmenu(function(e){
  1325. me.inputright(this,e);
  1326. return false;
  1327. });
  1328. };
  1329. this.showtools=function(){
  1330. if(this.dktype){
  1331. var s = '<span title="有图片消息" tools="sou0" class="cursor"><i class="icon-picture"></i></span>';
  1332. s+= ' <span title="有文件消息" tools="sou1" class="cursor"><i class="icon-folder-open-alt"></i></span>';
  1333. s+= ' <span title="所有消息" tools="sou2" class="cursor"><i class="icon-file-alt"></i></span>';
  1334. s+= ' <span title="消息搜索" tools="sou3" class="cursor"><i class="icon-search"></i></span>';
  1335. $('#toolsliao_'+this.num+'').html(s);
  1336. }
  1337. $('#toolsliao_'+this.num+'').find('span').click(function(e){
  1338. me.clicktools(this);
  1339. return false;
  1340. });
  1341. };
  1342. this.showtitle=function(){
  1343. var o = $('#viewtitle_'+this.num+''),s='';
  1344. var od = this.receinfo;
  1345. if(!od)od={deptid:'-2'};
  1346. s+='<table width="100%"><tr>';
  1347. s+='<td width="30" align="center"><div style="padding:0px 10px;padding-right:8px;height:30px;overflow:hidden"><img onclick="$.imgview({url:this.src})" style="border-radius:5px" src="'+this.face+'" height="30" width="30"></div></td>';
  1348. s+='<td height="50" width="100%">';
  1349. s+=' <div temp="usname_'+this.num+'"><b style="font-size:16px;">'+this.name+'</b>';
  1350. if((this.type=='group' || this.type=='gout') && this.usershu)s+='('+this.usershu+')';
  1351. if(od.subname)s+='<span style="color:'+maincolor+';font-size:10px">@'+od.subname+'</span>';
  1352. s+=reim.grouptype(od.deptid,this.type);
  1353. if(od.ranking)s+=' <span style="font-size:12px;color:#aaaaaa">('+od.ranking+')</span>';
  1354. if(this.type=='user')s+=reim.getonlinestr(this.gid);
  1355. s+=' </div>';
  1356. if(od.unitname)s+='<div style="font-size:12px;color:#aaaaaa">'+od.unitname+'</div>';
  1357. s+='</td>';
  1358. if(this.type=='group' || this.type=='gout'){
  1359. if(!od.deptid || od.deptid=='0' || od.deptid=='-1'){
  1360. if(this.type=='group')s+='<td title="邀请" id="yaoqingchat_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-plus"></i></div></td>';
  1361. s+='<td title="退出会话" id="tuichuchat_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-signout"></i></div></td>';
  1362. }
  1363. s+='<td title="会话里的人员" id="tuiuserlist_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-group"></i></div></td>';
  1364. }
  1365. if(this.type=='zixun'){
  1366. s+='<td title="转给其他客服" id="sharebtn_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-share-alt"></i></div></td>';
  1367. s+='<td title="加更多客服" id="addkfbtn_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-plus"></i></div></td>';
  1368. s+='<td title="咨询人员信息" id="zixunbtn_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-user"></i></div></td>';
  1369. }
  1370. s+='</tr></table>';
  1371. o.html(s);
  1372. $('#yaoqingchat_'+this.num+'').click(function(){
  1373. me.yaoqing();
  1374. });
  1375. $('#tuichuchat_'+this.num+'').click(function(){
  1376. me.exitgroup();
  1377. });
  1378. $('#tuiuserlist_'+this.num+'').click(function(){
  1379. me.showhuilist();
  1380. });
  1381. $('#zixunbtn_'+this.num+'').click(function(){
  1382. reim.kefu.showuser(me.gid);
  1383. });
  1384. $('#sharebtn_'+this.num+'').click(function(){
  1385. reim.kefu.shareuser(me.gid,0);
  1386. });
  1387. $('#addkfbtn_'+this.num+'').click(function(){
  1388. reim.kefu.shareuser(me.gid,1);
  1389. });
  1390. };
  1391. this.getapiurl=function(m1,a1){
  1392. if(this.type=='zixun')m1='rockkefu';
  1393. if(this.type=='gout'){
  1394. return reim.outgroup.geturl(a1);
  1395. }else{
  1396. return reim.getapiurl(m1,a1);
  1397. }
  1398. };
  1399. this.recordsearch=function(lx){
  1400. this.soulx = lx;
  1401. this.minid = 999999999;
  1402. this.listdata = {};
  1403. js.loading('加载中...');
  1404. this.loadci = 0;
  1405. this.showobj.perfectScrollbar('destroy');
  1406. this.loaddata();
  1407. };
  1408. this.searchjilu=function(){
  1409. js.prompt('搜索消息','请输入搜索关键词',function(jg,txt){
  1410. if(jg=='yes'){
  1411. me.soukey = txt;
  1412. me.recordsearch(me.soulx);
  1413. }
  1414. }, this.soukey);
  1415. };
  1416. this.loaddata=function(o1, iref){
  1417. if(this.boolload)return;
  1418. var iref = (!iref)?false:true;
  1419. var minid= 0;
  1420. if(iref)minid=this.minid;
  1421. if(o1)$(o1).html(''+js.ling(12)+' 加载中...');
  1422. this.boolload = true;
  1423. reim.ajax(this.getapiurl('reim','getrecord'),{type:this.type,gid:this.gid,minid:minid,loadci:this.loadci,laiyuan:'not',soulx:this.soulx,soukey:jm.base64encode(this.soukey)},function(ret){
  1424. js.unloading();
  1425. if(o1)$(o1).html('');
  1426. var da = ret.data;
  1427. me.showloaddata(da,iref);
  1428. });
  1429. };
  1430. this.setreceinfor=function(rece){
  1431. this.receinfo = rece;
  1432. this.usershu = this.receinfo.utotal;
  1433. this.createid = this.receinfo.createid;
  1434. this.face = this.receinfo.face;
  1435. this.name = this.receinfo.name;
  1436. js.setoption('receinfo_'+this.num+'', JSON.stringify(rece));
  1437. };
  1438. this.showloaddata=function(da,iref){
  1439. if(this.loadci==0){
  1440. this.showobj.html('');
  1441. this.sendinfo = da.sendinfo;
  1442. this.setreceinfor(da.receinfor);
  1443. this.showobj.perfectScrollbar();
  1444. if(this.sendinfo.uptypes)this.uptypes = this.sendinfo.uptypes;
  1445. if(this.sendinfo.uploadurl)this.upurl = this.sendinfo.uploadurl+'&laiyuan=web';
  1446. this.showtitle();
  1447. }
  1448. this.loadci++;
  1449. this.boolload = false;
  1450. this.loaddatashow(da, iref);
  1451. };
  1452. this.loaddatashow=function(ret,isbf, isls){
  1453. if(!get('viewcontent_'+this.num+''))return;
  1454. var a = ret.rows;
  1455. this.lastdt = ret.nowdt;
  1456. var i,len = a.length,cont,lex,nas,fase,nr,d,na=[],rnd,sid,frs,nfr1;
  1457. if(!isls)$('#loadmored_'+this.num+'').remove();
  1458. var seseid = -100;
  1459. if(isbf){
  1460. if(len>0)this.showobj.prepend('<div class="showblanks">---------↑以上是新加载---------</div>');
  1461. na = a;
  1462. }else{
  1463. for(i= len-1; i>=0; i--)na.push(a[i]);
  1464. }
  1465. var budnr = false;
  1466. if(isls && len>0 && !this.isscrollbottom()){
  1467. this.showdownjd()
  1468. budnr = true;
  1469. }
  1470. this.isshangla = false;
  1471. for(i= 0; i<len; i++){
  1472. d = na[i];
  1473. sid = parseFloat(d.id);
  1474. lex = 'right';
  1475. nas = this.sendinfo.name;
  1476. fase= this.sendinfo.face;
  1477. if(d.sendid!=this.sendinfo.id){
  1478. lex='left';
  1479. nas= d.sendname;
  1480. fase= d.face;
  1481. }
  1482. frs = d.filers;
  1483. if(frs && frs.fileid && js.isimg(frs.fileext)){
  1484. nfr1 = js.getoption('filesrc_'+frs.fileid+'');
  1485. if(nfr1)frs.thumbpath = nfr1;
  1486. }
  1487. nr = this.contshozt(frs);
  1488. if(nr=='')nr= jm.base64decode(d.cont);
  1489. rnd = 'mess_'+sid+'';
  1490. if(get('qipaocont_'+rnd+'') || this.listdata[rnd])continue;
  1491. cont= strformat.showqp(lex,nas,d.optdt,nr ,'', fase, rnd,d.bqname,d.bqcolor);
  1492. if(!isbf){
  1493. this.addcont(cont, isbf, budnr);
  1494. }else{
  1495. this.showobj.prepend(cont);
  1496. seseid+=$('#ltcont_'+rnd+'').height();
  1497. }
  1498. this.listdata[rnd]=d;
  1499. $('#qipaocont_'+rnd+'').contextmenu(function(e){
  1500. me.contright(this,e);
  1501. return false;
  1502. });
  1503. if(sid<this.minid)this.minid=sid;
  1504. }
  1505. if(len>0 && !isls){
  1506. var s = '<div class="showblanks" >';
  1507. if(ret.wdtotal==0){
  1508. s+='---------↑以上是历史记录---------';
  1509. if(ret.systotal>0){
  1510. this.showobj.prepend('<div id="loadmored_'+this.num+'" class="showblanks" ><a onclick="'+this.objstr+'.loadmoreda(this)"><i class="icon-time"></i> 还有'+ret.systotal+'条点我查看更多</a></div>');
  1511. this.isshangla = true;
  1512. }else{
  1513. this.showobj.prepend('<div id="loadmored_'+this.num+'" class="showblanks" >没有更多了</div>');
  1514. }
  1515. }else{
  1516. s+='---↑以上是历史,还有未读信息'+ret.wdtotal+'条,<a href="javascript:;" onclick="'+this.objstr+'.loaddata(this)">点击加载</a>---';
  1517. }
  1518. s+='</div>';
  1519. if(!isbf)this.addcont(s);
  1520. }
  1521. if(ret.showmsg)this.addmsg(ret.showmsg);
  1522. if(seseid>0)this.showobj.scrollTop(seseid);
  1523. };
  1524. this.isscrollbottom=function(){
  1525. var o1 = this.showoba;
  1526. var jg = o1.scrollHeight - o1.scrollTop - o1.offsetHeight;
  1527. this.bodyscrollTop = o1.scrollTop;
  1528. return jg<20;
  1529. };
  1530. this.showdownjd=function(){
  1531. var sid = 'downjd_'+this.num+'';
  1532. if(get(sid)){
  1533. $('#'+sid+'').show();
  1534. }else{
  1535. var str = '<div style="height:24px;width:24px;position:fixed;text-align:center;right:10px;bottom:160px;line-height:24px;background:'+maincolor+';color:white;border-radius:50%;z-index:10;font-size:12px;cursor:pointer" id="'+sid+'"><i class="icon-arrow-down"></i></div>';
  1536. this.showobj.prepend(str);
  1537. $('#'+sid+'').click(function(){me.scrollboot();});
  1538. }
  1539. };
  1540. //邀请
  1541. this.yaoqing=function(){
  1542. if(this.type!='group')return;
  1543. js.changeuser(false,'usercheck','邀请人到会话中', {
  1544. onselect:function(sna,sid){
  1545. if(!sid)return;
  1546. me.yaoqings(sid);
  1547. }
  1548. });
  1549. };
  1550. this.yaoqings=function(sid){
  1551. js.msg('wait','邀请中...');
  1552. reim.ajax(reim.getapiurl('reim','yaoqinguid'),{val:sid,gid:this.gid},function(da){
  1553. js.msg();
  1554. if(da.success){
  1555. js.msgok('邀请成功');
  1556. me.userlistarr=false;
  1557. me.getreceinfor();
  1558. }else{
  1559. js.msg('msg',da);
  1560. }
  1561. });
  1562. };
  1563. this.getreceinfor=function(){
  1564. reim.ajax(reim.getapiurl('reim','getreceinfor'),{type:this.type,gid:this.gid},function(ret){
  1565. me.receinfo = ret.data.receinfor;
  1566. me.usershu = me.receinfo.utotal;
  1567. me.showtitle();
  1568. });
  1569. };
  1570. this.exitgroup=function(){
  1571. if(this.type=='user')return;
  1572. js.confirm('确定要此退出会话吗?',function(lx){
  1573. if(lx=='yes'){
  1574. me.exitgroups();
  1575. }
  1576. });
  1577. };
  1578. this.showhuilist=function(){
  1579. var s = '<div id="showuserlist" style="height:250px;overflow:hidden;position:relative"><div align="center" style="padding:10px;">'+js.ling()+'&nbsp;加载人员...</div></div>';
  1580. js.tanbody('syscogshow','会话上人员('+this.usershu+')',480,100,{html:s});
  1581. if(!this.userlistarr){
  1582. reim.ajax(this.getapiurl('reim','getgroupuser'),{type:this.type,gid:this.gid},function(ret){
  1583. me.showusershow(ret.data.uarr);
  1584. },'get');
  1585. }else{
  1586. this.showusershow(this.userlistarr);
  1587. }
  1588. };
  1589. this.showusershow=function(a){
  1590. this.userlistarr = a;
  1591. var sad = this.showtableda(a);
  1592. $('#showuserlist').html(sad[0]);
  1593. $('#showuserlist').perfectScrollbar();
  1594. $('#msgview_syscogshow').html('<span style="font-size:12px;">右键人名可以@TA,'+sad[1]+'人在线</span>');
  1595. $('#showuserlist').find('div[xuh]').contextmenu(function(e){
  1596. me.atright(this,e);
  1597. return false;
  1598. });
  1599. };
  1600. this.showtableda=function(a){
  1601. var i,len=a.length,s='',oi=0,s1='',zx=0,d1;
  1602. s+='<table width="100%"><tr>';
  1603. for(i=0;i<len;i++){
  1604. oi++;
  1605. s1='';
  1606. if(a[i].online==1 && this.type=='gout'){
  1607. s1='<font title="PC端在线" class="zhu" style="font-size:10px;margin-left:5px"><i class="icon-desktop"></i></font>';
  1608. zx++;
  1609. }
  1610. if(this.type=='group'){
  1611. s1=reim.getonlinestr(a[i].id);
  1612. d1=reim.nowonlinearr;
  1613. if(d1 && d1.reim==1)zx++;
  1614. }
  1615. s+='<td width="20%"><div style="padding:5px" align="center"><div><img style="height:34px;width:34px;border-radius:50%" onclick="$.imgview({url:this.src})" src="'+a[i].face+'"></div><div xuh="'+i+'">'+a[i].name+''+s1+'</div></div></td>';
  1616. if(oi%5==0)s+='</tr><tr>';
  1617. }
  1618. if(len<5)for(i=0;i<5-len;i++)s+='<td width="20%"></td>';
  1619. s+='</tr></table>';
  1620. return [s, zx];
  1621. };
  1622. this.atright=function(o1){
  1623. var xu = parseFloat($(o1).attr('xuh'));
  1624. var d1 = this.userlistarr[xu];
  1625. this.atid = d1.id;
  1626. this.addinput('@'+d1.name+' ');
  1627. };
  1628. this.clickbody=function(o,e){
  1629. if(e.target.nodeName=='FONT'){
  1630. var o1 = $(e.target);
  1631. var atid = o1.attr('atid'),nst;
  1632. if(atid){
  1633. this.atid = atid;
  1634. this.addinput(''+o1.text()+' ');
  1635. }
  1636. }
  1637. if(this.rightqipaoobj)this.rightqipaoobj.hide();
  1638. };
  1639. this.kefuat=function(){
  1640. this.atid = 2;
  1641. this.addinput('@信呼客服 ');
  1642. };
  1643. this.exitgroups=function(){
  1644. js.msg('wait','退出中...');
  1645. reim.ajax(this.getapiurl('reim','exitgroup'),{gid:this.gid,aid:this.sendinfo.id}, function(da){
  1646. js.msgok('成功退出此会话,无法在此会话发消息了');
  1647. });
  1648. };
  1649. this.contshozt=function(d){
  1650. return strformat.contshozt(d,'web/');
  1651. };
  1652. this.addmsg=function(msg){
  1653. this.addcont('<div class="showblanks" >'+msg+'</div>');
  1654. };
  1655. this.addcont=function(cont, isbf, isb1){
  1656. var o = this.showobj;
  1657. if(cont){if(isbf){o.prepend(cont);}else{o.append(cont);}}
  1658. clearTimeout(this.scrolltime);
  1659. this.scrolltime = setTimeout(function(){
  1660. if(!isb1)me.scrollboot();
  1661. }, 50);
  1662. };
  1663. //滚动条到最下面
  1664. this.scrollboot=function(){
  1665. var sid = 'viewcontent_'+this.num+'';
  1666. if(get(sid))this.showobj.animate({scrollTop:get(sid).scrollHeight},100);
  1667. sid = 'downjd_'+this.num+'';
  1668. if(get(sid))$('#'+sid+'').hide();
  1669. };
  1670. this.onsscroll=function(){
  1671. clearTimeout(this.onsscrolltime);
  1672. this.onsscrolltime = setTimeout(function(){me.onsscrolls();}, 200);
  1673. };
  1674. this.onsscrolls=function(){
  1675. var sid = 'downjd_'+this.num+'';
  1676. if(this.isscrollbottom() && get(sid)){
  1677. $('#'+sid+'').hide();
  1678. }
  1679. };
  1680. this.loadmoreda=function(o1){
  1681. this.loaddata(o1, true);
  1682. };
  1683. this.sendcont=function(ssnr){
  1684. if(this.sendbool)return;
  1685. js.msg('none');
  1686. var o = this.inputobj;
  1687. var nr = strformat.sendinstr(o.val());
  1688. nr = nr.replace(/</gi,'&lt;').replace(/>/gi,'&gt;').replace(/\n/gi,'<br>');
  1689. if(ssnr)nr=ssnr;
  1690. if(isempt(nr))return false;
  1691. if(nr.indexOf('@')<0)this.atid=0;
  1692. var conss = jm.base64encode(nr);
  1693. if(conss.length>3998){
  1694. js.msg('msg','发送内容太多了');
  1695. return;
  1696. }
  1697. var nuid= js.now('time'),optdt = js.serverdt();
  1698. if(optdt==this.nowoptdt){
  1699. js.msg('msg','消息发太快了');
  1700. return;
  1701. }
  1702. this.nowoptdt = optdt;
  1703. var cont= strformat.showqp('right',this.sendinfo.name,optdt, nr, nuid, this.sendinfo.face, nuid, this.sendinfo.bqname, this.sendinfo.bqcolor);
  1704. this.addcont(cont);
  1705. o.val('').focus();
  1706. this.sendconts(conss, nuid, optdt, 0);
  1707. return false;
  1708. };
  1709. //收到推送消息来了
  1710. this.receivedata=function(d){
  1711. var minid=this.minid;
  1712. reim.ajax(this.getapiurl('reim','getrecord'),{type:this.type,gid:this.gid,minid:0,lastdt:this.lastdt,loadci:this.loadci},function(ret){
  1713. me.loaddatashow(ret.data, false, true);
  1714. });
  1715. };
  1716. this.onshow=function(){
  1717. if(this.newbool){
  1718. this.scrollboot();
  1719. }
  1720. this.newbool = false;
  1721. };
  1722. this.onkeydown=function(e){
  1723. var code = e.keyCode,kj = js.getoption('sendkuijie');
  1724. if(code==13 && e.shiftKey){
  1725. this.addinput('\n')
  1726. return false;
  1727. }
  1728. if(code==13 && !e.ctrlKey && kj!='1'){
  1729. this.sendcont();
  1730. return false;
  1731. }
  1732. if(e.altKey && code==83){
  1733. this.sendcont();
  1734. return false;
  1735. }
  1736. if(e.altKey && code==67){
  1737. this.closechat();
  1738. return false;
  1739. }
  1740. if(e.ctrlKey && code==13){
  1741. if(kj=='1'){this.sendcont();}else{this.addinput('\n');}
  1742. return false;
  1743. }
  1744. return true;
  1745. };
  1746. this.sendconts=function(conss, nuid, optdt, fid){
  1747. this.sendbool = true;
  1748. var d = {cont:conss,gid:this.gid,type:this.type,nuid:nuid,optdt:optdt,fileid:fid,atid:''+this.atid+''};
  1749. this.atid= 0;
  1750. reim.ajax(this.getapiurl('reim','sendinfor'),d,function(ret){
  1751. me.sendsuccess(ret.data,nuid, d);
  1752. },'post',function(){
  1753. me.senderror(nuid, d);
  1754. });
  1755. var s1='';
  1756. if(this.type=='group' || this.type=='gout')s1=jm.base64encode(''+this.sendinfo.name+':');
  1757. //显示到会话里
  1758. reim.showhistorys({
  1759. 'cont' : s1+d.cont,
  1760. 'name' : this.receinfo.name,
  1761. 'subname' : this.receinfo.subname,
  1762. 'face' : this.receinfo.face,
  1763. 'optdt' : d.optdt,
  1764. 'type' : this.type,
  1765. 'receid' : this.gid,
  1766. 'stotal' : 0
  1767. }, true, true);
  1768. if(this.type=='zixun')reim.kefu.showonline(this.type,this.gid);
  1769. };
  1770. this.senderror=function(nuid, ds){
  1771. get(nuid).src='images/error.png';
  1772. get(nuid).title='发送失败';
  1773. if(ds)get(nuid).onclick=function(){
  1774. js.confirm('是否要重新发送?', function(jg){
  1775. if(jg=='yes'){
  1776. get(nuid).src='images/loadings.gif';
  1777. get(nuid).title='发送中...';
  1778. me.atid = ds.atid;
  1779. me.sendconts(ds.cont,ds.nuid,ds.optdt,ds.fileid);
  1780. }
  1781. });
  1782. }
  1783. this.sendbool=false;
  1784. };
  1785. this.sendsuccess=function(d,nuid,sd){
  1786. this.sendbool = false;
  1787. if(!d.id){
  1788. this.senderror(nuid,sd);
  1789. return;
  1790. }
  1791. $('#'+d.nuid+'').remove();
  1792. var bo = false;
  1793. d.messid=d.id;
  1794. d.face = this.sendinfo.face;
  1795. if(d.showmsg)this.addmsg(d.showmsg);
  1796. if(this.type=='group')d.gface=this.receinfo.face;
  1797. if(d.fileid)d.filers = this.nowfilers;
  1798. this.listdata[nuid]=d;
  1799. this.listdata['mess_'+d.id+'']=d;
  1800. //添加右键事件
  1801. $('#qipaocont_'+nuid+'').contextmenu(function(e){
  1802. me.contright(this,e);
  1803. return false;
  1804. });
  1805. reim.serversend(d);
  1806. };
  1807. this.addinput=function(s){
  1808. var val = this.inputobj.val()+s;
  1809. this.inputobj.val(val).focus();
  1810. };
  1811. this.closechat=function(){
  1812. if(this.sendbool)return;
  1813. reim.chatobj[this.num]=false;
  1814. reim.closetabs(this.num);
  1815. };
  1816. this.clicktools=function(o1){
  1817. var o = $(o1);
  1818. var lx = o.attr('tools');
  1819. if(lx=='emts')this.getemts(o);
  1820. if(lx=='file')this.sendfile(o);
  1821. if(lx=='paste')this.pasteimg();
  1822. if(lx=='crop')this.cropScreen();
  1823. if(lx=='tonghua')this.opentonghua();
  1824. if(lx=='jilu')this.openjilu();
  1825. if(lx=='sou0' || lx=='sou1' || lx=='sou2')this.recordsearch(lx);
  1826. if(lx=='sou3')this.searchjilu();
  1827. if(lx=='star')this.showstar();
  1828. if(lx=='atkf')this.kefuat();
  1829. };
  1830. this.getemts=function(o){
  1831. if(!get('aemtsdiv')){
  1832. var s = '<div id="aemtsdiv" style="width:400px;height:200px;overflow:hidden;border:var(--border);background:var(--main-bgcolor);left:3px;top:5px;position:absolute;display:none;z-index:6;border-radius:5px" class="box">';
  1833. s+='<div style="padding:5px">';
  1834. s+=this.getemtsbq('qq',0, 104, 11, 24);
  1835. s+='</div>';
  1836. s+='</div>';
  1837. $('body').append(s);
  1838. js.addbody('emts','hide','aemtsdiv');
  1839. $('#aemtsdiv').perfectScrollbar();
  1840. }
  1841. var o1 = $('#aemtsdiv');
  1842. o1.toggle();
  1843. var off = o.offset();
  1844. o1.css({'top':''+(off.top-205)+'px','left':''+(off.left)+'px'});
  1845. };
  1846. this.opentonghua=function(){
  1847. var url =NOWURL+'?d=reim&m=tonghua&id='+this.gid+'';
  1848. js.open(url, 350,530,'tonghuacall',{},{resizable:false,'always_on_top':true});
  1849. };
  1850. this.openjilu=function(){
  1851. var win = js.open(NOWURL+'?d=reim&m=record&a=history&type='+this.type+'&gid='+this.gid+'',850,550,'recorda');
  1852. if(win)js.openrun('recorda','reshow', this.type, this.gid);
  1853. };
  1854. this.getemtsbq=function(wj, oi1,oi2, fzd, dx){
  1855. var i,oi=0,j1 = js.float(100/fzd);
  1856. var s = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
  1857. for(i=oi1; i<=oi2; i++){
  1858. oi++;
  1859. s+='<td width="'+j1+'%" title="'+strformat.emotsarr[i+1]+'" align="center"><img onclick="im.backemts(\''+strformat.emotsarr[i+1]+'\')" src="web/images/im/emots/'+wj+'/'+i+'.gif" width="'+dx+'" height="'+dx+'"></td>';
  1860. if(oi % fzd==0)s+='</tr><tr>';
  1861. }
  1862. s+='</tr></table>';
  1863. return s;
  1864. };
  1865. this.sendfile=function(bo){
  1866. uploadobj.nownum = this.num;
  1867. uploadobj.setuptype(this.uptypes);
  1868. uploadobj.setupurl(this.upurl);
  1869. uploadobj.click();
  1870. };
  1871. this.sendfileshow=function(f){
  1872. f.face = this.sendinfo.face;
  1873. f.bqname= this.sendinfo.bqname;
  1874. f.sendname= this.sendinfo.name;
  1875. f.bqcolor= this.sendinfo.bqcolor;
  1876. var fa = strformat.showupfile(f);
  1877. var cont= fa.cont;
  1878. this.upfilearr = fa;
  1879. this.addcont(cont);
  1880. };
  1881. this.sendfileok=function(f,str){
  1882. var a=js.decode(str);
  1883. if(!a.id){
  1884. js.msg('msg', str);
  1885. this.senderrornss();
  1886. return;
  1887. }
  1888. var tm= this.upfilearr,conss='';
  1889. if(this.type=='gout')a.fileid = a.filenum;
  1890. f = a;
  1891. strformat.upsuccess(a);
  1892. if(js.isimg(f.fileext)){
  1893. conss = '[图片 '+f.filesizecn+']';
  1894. }else{
  1895. conss = '['+f.filename+' '+f.filesizecn+']'
  1896. }
  1897. this.nowfilers = a;
  1898. this.sendconts(jm.base64encode(conss), tm.nuid, tm.optdt, a.id);
  1899. };
  1900. this.senderrornss=function(){
  1901. this.senderror(this.upfilearr.nuid);
  1902. };
  1903. this.readclip=function(evt){
  1904. var clipboardData = evt.clipboardData;
  1905. if(!clipboardData)return;
  1906. for(var i=0; i<clipboardData.items.length; i++){
  1907. var item = clipboardData.items[i];
  1908. if(item.kind=='file'&&item.type.match(/^image\//i)){
  1909. var blob = item.getAsFile(),reader = new FileReader();
  1910. reader.onload=function(){
  1911. var cont=this.result;
  1912. me.readclipshow(cont);
  1913. }
  1914. reader.readAsDataURL(blob);
  1915. }
  1916. }
  1917. };
  1918. this.readclipshow=function(snr){
  1919. var f={face:this.sendinfo.face}
  1920. f.bqname= this.sendinfo.bqname;
  1921. f.bqcolor= this.sendinfo.bqcolor;
  1922. f.sendname= this.sendinfo.name;
  1923. var fa = strformat.showupfile(f, snr);
  1924. var cont= fa.cont;
  1925. this._sssnuid = fa.nuid;
  1926. this._sssoptdt = fa.optdt;
  1927. this.upfilearr = fa;
  1928. this.addcont(cont);
  1929. };
  1930. this.sendbase64 = function(strnr){
  1931. uploadobj.nownum = this.num;
  1932. uploadobj.setuptype(this.uptypes);
  1933. uploadobj.setupurl(this.upurl);
  1934. uploadobj.sendbase64(strnr);
  1935. };
  1936. this.clipobj = function(){
  1937. if(!this.clipobj1)this.clipobj1 = nw.Clipboard.get();
  1938. return this.clipobj1;
  1939. };
  1940. this.pasteimg=function(){
  1941. var snr = this.clipobj().get('png');
  1942. //console.log(this.clipobj().readAvailableTypes());
  1943. if(!snr){
  1944. //js.msgerror('剪切板上没有图片');
  1945. return;
  1946. }
  1947. this.readclipshow(snr);
  1948. };
  1949. this.cropScreen=function(){
  1950. this.clipobj().clear();
  1951. jietubool = true;
  1952. im.cropScreen();
  1953. };
  1954. this.filedrop=function(o1){
  1955. uploadobj.nownum = this.num;
  1956. uploadobj.setuptype(this.uptypes);
  1957. uploadobj.setupurl(this.upurl);
  1958. uploadobj.change(o1, 0);
  1959. };
  1960. this.inputright=function(o,e){
  1961. if(!this.inputrightobj)this.inputrightobj=$.rockmenu({
  1962. data:[],width:100,itemsclick:function(d){me.inputrightclick(d);}
  1963. });
  1964. this.selectionStart = o.selectionStart;
  1965. this.selectionEnd = o.selectionEnd;
  1966. var sel = o.value.substr(o.selectionStart,o.selectionEnd-o.selectionStart);
  1967. this.selectValue = sel;
  1968. var d = [];
  1969. d.push({name:'复制',lx:1});
  1970. d.push({name:'剪切',lx:2});
  1971. if(nwjsgui){d.push({'name':'粘贴',lx:0});d.push({'name':'粘贴图片',lx:5});}
  1972. d.push({name:'清空',lx:4});
  1973. if(!sel){
  1974. d[0].name='<font color=#aaaaaa>'+d[0].name+'</font>';d[0].lx = 3;
  1975. d[1].name='<font color=#aaaaaa>'+d[1].name+'</font>';d[1].lx = 3;
  1976. }
  1977. this.inputrightobj.setData(d);
  1978. this.inputrightobj.showAt(e.clientX,e.clientY);
  1979. };
  1980. this.inputrightclick=function(d){
  1981. if(d.lx==0){
  1982. var snr = this.clipobj().get('text'),nr = this.inputobj.val();
  1983. if(snr){
  1984. var s1 = nr.substr(0,this.selectionStart)+snr+nr.substr(this.selectionEnd);
  1985. this.inputobj.val(s1).focus();
  1986. }
  1987. }
  1988. if(d.lx==1){
  1989. js.setcopy(this.selectValue,true);
  1990. }
  1991. if(d.lx==2){
  1992. js.setcopy(this.selectValue,true);
  1993. var nr = this.inputobj.val();
  1994. var s1 = nr.substr(0,this.selectionStart)+nr.substr(this.selectionEnd);
  1995. this.inputobj.val(s1).focus();
  1996. }
  1997. if(d.lx==4)this.inputobj.val('').focus();
  1998. if(d.lx==5)this.pasteimg();
  1999. };
  2000. this.contright=function(o1,e){
  2001. var o=$(o1),rnd=o.attr('rand');
  2002. this.rightqipao(o1,e,rnd);
  2003. };
  2004. this.rightqipao=function(o1,e,rnd){
  2005. if(!this.rightqipaoobj)this.rightqipaoobj=$.rockmenu({
  2006. data:[],width:130,itemsclick:function(d){me.rightqipaoclick(d);}
  2007. });
  2008. this.randmess = rnd;
  2009. this.rightdata= this.listdata[rnd];
  2010. this.chuihuinr= 'PGRlbCBzdHlsZT0iY29sb3I6Z3JheSI!5bey5pKk5ZuePC9kZWw!';
  2011. var d=[{name:'复制此消息',lx:0},{name:'删除',lx:1}];
  2012. if(this.rightdata.cont!=this.chuihuinr)d.push({name:'收藏',lx:5});
  2013. if(!this.dktype){
  2014. if(this.type=='group' || this.type=='gout')d.push({name:'@TA',lx:3});
  2015. var chehui = reim.showconfigarr.chehui,isch=false;
  2016. if(this.type=='gout')chehui = 120;
  2017. if(o1.className.indexOf('right')>0 && chehui>0){
  2018. var t1 = js.now('time', this.rightdata.optdt),t2 = js.now('time');
  2019. var t3 = (t2-t1)*0.001;
  2020. if(t3<chehui)isch = true;
  2021. }
  2022. if(this.sendinfo.id==this.createid)isch = true; //创建者
  2023. if(this.rightdata.cont==this.chuihuinr)isch=false;
  2024. if(isch)d.push({name:'撤回',lx:2});
  2025. }
  2026. if(this.type!='gout' && this.rightdata.sendid==adminid)d.push({name:'已读未读情况',lx:6});
  2027. this.rightqipaoobj.setData(d);
  2028. this.rightqipaoobj.showAt(e.clientX,e.clientY);
  2029. };
  2030. this.rightqipaoclick=function(d){
  2031. var lx=d.lx;
  2032. var ids = this.rightdata.id;
  2033. if(lx==0){
  2034. var cont = $('#qipaocont_'+this.randmess+'').text();
  2035. if(cont)js.setcopy(cont);
  2036. }
  2037. if(lx==1){
  2038. $('#ltcont_'+this.randmess+'').remove();
  2039. if(!isNaN(ids)){
  2040. reim.ajax(this.getapiurl('reim','clearrecord'),{type:this.type,gid:this.gid,ids:ids});
  2041. }
  2042. }
  2043. if(lx==3){
  2044. var cont = $('#ltname_'+this.randmess+'').text();
  2045. if(this.rightdata.sendname)cont = this.rightdata.sendname;
  2046. if(cont){
  2047. this.atid = this.rightdata.sendid;
  2048. this.addinput('@'+cont+' ');
  2049. }
  2050. }
  2051. if(lx==2 && !isNaN(ids)){
  2052. var o1dd = $('#qipaocont_'+this.randmess+'')
  2053. o1dd.html(js.getmsg('撤回中...'));
  2054. reim.ajax(this.getapiurl('reim','chehuimess'),{type:this.type,gid:this.gid,ids:ids}, function(ret){
  2055. me.listdata[me.randmess].ocont = me.listdata[me.randmess].cont;
  2056. me.listdata[me.randmess].cont = 'PGRlbCBzdHlsZT0iY29sb3I6Z3JheSI!5bey5pKk5ZuePC9kZWw!';
  2057. o1dd.html(js.getmsg(ret.data.msg1,'green')+' <a onclick="'+me.objstr+'.rebianji(this,\''+me.randmess+'\')" href="javascript:;">重新编辑</a>');
  2058. },'get', function(){
  2059. o1dd.html(js.getmsg('撤回失败','red'));
  2060. });
  2061. };
  2062. if(lx==5)this.staradd(this.rightdata);
  2063. if(lx==6)this.showhuizhi();
  2064. };
  2065. this.rebianji=function(o1,rnd){
  2066. var d = this.listdata[rnd],
  2067. nstr = jm.base64decode(d.ocont);
  2068. $('body').append('<div id="addcstre" style="display:none">'+nstr+'</div>');
  2069. this.inputobj.val($('#addcstre').text());
  2070. $('#addcstre').remove();
  2071. };
  2072. this.showhuizhi=function(){
  2073. var s = '<div id="showstarlistdss" class="qipao" style="height:250px;overflow:hidden;position:relative"><div align="center" style="padding:10px;"><img src="images/mloading.gif" align="absmiddle">&nbsp;加载...</div></div>';
  2074. js.tanbody('xiaoxirece','消息已读未读情况',480,100,{html:s});
  2075. reim.ajax(reim.getapiurl('reim','getxqkkd'),{id:this.rightdata.id},function(ret){
  2076. me.showhuizhishow(ret.data);
  2077. },'get');
  2078. };
  2079. this.showhuizhishow=function(ret){
  2080. var str = '';
  2081. var d = ret.wdarr;
  2082. if(d.length>0){
  2083. str+='<div style="padding:5px 10px;border-bottom:var(--border);font-size:12px;color:gray">未读'+d.length+'人</div>';
  2084. var sad = this.showtableda(d);
  2085. str+=sad[0];
  2086. }
  2087. d = ret.ydarr;
  2088. if(d.length>0){
  2089. str+='<div style="padding:5px 10px;border-bottom:var(--border);font-size:12px;color:gray">已读'+d.length+'人</div>';
  2090. var sad = this.showtableda(d);
  2091. str+=sad[0];
  2092. }
  2093. $('#showstarlistdss').html(str);
  2094. $('#showstarlistdss').perfectScrollbar();
  2095. }
  2096. //以下是收藏使用的
  2097. this.showstar=function(){
  2098. var s = '<div id="showstarlist" class="qipao" style="height:300px;overflow:hidden;position:relative"><div align="center" style="padding:10px;"><img src="images/mloading.gif" align="absmiddle">&nbsp;加载...</div></div>';
  2099. js.tanbody('sysshowstar','收藏的消息',370,100,{html:s,btn:[{text:'管理'}]});
  2100. if(!reim.starlistarr){
  2101. this.showstarshu();
  2102. }else{
  2103. this.showstarshow(reim.starlistarr);
  2104. }
  2105. };
  2106. this.showstarshu=function(o1){
  2107. if(o1)o1.innerHTML=js.getmsg('刷新中...');
  2108. reim.ajax(reim.getapiurl('reim','getstar'),{},function(ret){
  2109. me.showstarshow(ret.data);
  2110. },'get');
  2111. };
  2112. this.showstarshow=function(a){
  2113. reim.starlistarr = a;
  2114. var i,len=a.length,s='',oi=0,s1='',s2='',zx=0,d1;
  2115. s+='';
  2116. for(i=0;i<len;i++){
  2117. if(!a[i])continue;
  2118. oi++;
  2119. d1= js.decode(jm.base64decode(a[i].value));
  2120. s1= jm.base64decode(d1.cont);
  2121. if(d1.fileid>0){
  2122. if(this.type=='gout' || this.type=='uout'){
  2123. if(d1.type=='user' || d1.type=='group')continue;
  2124. }
  2125. if(this.type=='user' || this.type=='group'){
  2126. if(d1.type=='gout' || d1.type=='uout')continue;
  2127. }
  2128. if(this.type=='zixun' || d1.type=='zixun'){
  2129. if(d1.type != this.type)continue;
  2130. }
  2131. }
  2132. if(d1.imgurl){
  2133. s2+='<div onclick="'+this.objstr+'.clickstar('+i+',this)" class="lists" style="padding:10px;float:left"><img src="'+d1.imgurl+'" fileid="'+d1.fileid+'" type="'+d1.type+'" style="width:50px;height:50px"></div>';
  2134. continue;
  2135. }
  2136. if(d1.filename){
  2137. if(d1.filenum)d1.fileid = d1.filenum;
  2138. s1=strformat.contshozt(d1);
  2139. }
  2140. s+='<div class="lists" onclick="'+this.objstr+'.clickstar('+i+',this,event)" style="border-bottom-width:1px">';
  2141. s+='<div>'+s1+'</div>';
  2142. s+='</div>';
  2143. }
  2144. s+='';
  2145. if(s2)s2='<div style="display:inline-block;border-bottom:var(--border);width:100%">'+s2+'</div>';
  2146. $('#showstarlist').html(s2+s);
  2147. $('#showstarlist').perfectScrollbar();
  2148. $('#msgview_sysshowstar').html('<a onclick="'+this.objstr+'.showstarshu(this)" href="javascript:;">刷新</a>');
  2149. this.starisguan = false;
  2150. $('#sysshowstar_btn0').click(function(){
  2151. if(!me.starisguan){
  2152. me.starisguan = true;
  2153. $(this).html('退出管理');
  2154. }else{
  2155. me.starisguan = false;
  2156. $(this).html('管理');
  2157. }
  2158. });
  2159. };
  2160. this.clickstar=function(i,o1,e1){
  2161. if(e1 && e1.target.nodeName=='A')return;
  2162. var d1 = reim.starlistarr[i];
  2163. var d = js.decode(jm.base64decode(d1.value));
  2164. if(!this.starisguan){
  2165. if(d.fileid==0){
  2166. var nr = jm.base64decode(d.cont);
  2167. $('body').append('<div id="addcstre" style="display:none">'+nr+'</div>');
  2168. this.addinput($('#addcstre').text());
  2169. $('#addcstre').remove();
  2170. }else{
  2171. var str = '确定要发送“'+d.filename+'('+d.filesizecn+')”文件吗?';
  2172. if(d.imgurl)str='<img src="'+d.imgurl+'" onclick="strformat.clickimg(this)" width="50px" height="50px"> 点确定发送。';
  2173. js.confirm(str, function(jg){
  2174. if(jg=='yes'){
  2175. var sf = {
  2176. fileext:d.fileext,
  2177. filename:d.filename,
  2178. filesizecn:d.filesizecn,
  2179. id:d.fileid,
  2180. filenum:d.filenum
  2181. }
  2182. if(d.imgurl){
  2183. sf.filename = '图片';
  2184. sf.isimg = true;
  2185. sf.imgviewurl = d.imgurl;
  2186. sf.thumbpath = d.imgurl;
  2187. }
  2188. me.sendfileshow(sf);
  2189. me.sendfileok({},JSON.stringify(sf));
  2190. }
  2191. });
  2192. }
  2193. js.tanclose('sysshowstar');
  2194. }else{
  2195. js.confirm('确定要删除此收藏吗?', function(jg){
  2196. if(jg=='yes'){
  2197. reim.starlistarr[i]=false;
  2198. $(o1).remove();
  2199. reim.ajax(reim.getapiurl('reim','delstar'),{id:d1.id});
  2200. }
  2201. });
  2202. }
  2203. };
  2204. this.staradd=function(d){
  2205. js.loading('收藏中...');
  2206. var da = {messid:d.id,fileid:d.fileid,cont:d.cont,type:this.type}
  2207. if(d.filers){
  2208. da.fileext = d.filers['fileext'];
  2209. var img = d.filers['thumbpath'];
  2210. var nae = d.filers['filename'];
  2211. var sids = d.filers['filesizecn'];
  2212. var nnud = d.filers['filenum'];
  2213. if(js.isimg(da.fileext) && img)da.imgurl = img;
  2214. if(nae)da.filename = nae;
  2215. if(sids)da.filesizecn = sids;
  2216. if(nnud)da.filenum = nnud;
  2217. }
  2218. var kev = ''+d.id+'';if(this.type=='gout' || this.type=='uout')kev='out_'+d.id+'';
  2219. if(this.type=='zixun')kev='zixun_'+d.id+'';
  2220. reim.ajax(reim.getapiurl('reim','savestar'),{kev:kev,content:jm.base64encode(JSON.stringify(da))}, function(ret){
  2221. reim.starlistarr=false;
  2222. js.msgok('收藏成功');
  2223. },'post');
  2224. }
  2225. this._init();
  2226. }
  2227. //相关回调
  2228. var im = {
  2229. clickqipao:function(o1,e){
  2230. },
  2231. rightqipao:function(o1,e,rnd){
  2232. reim.chatobj[reim.nowtabs].rightqipao(o1,e,rnd);
  2233. },
  2234. backemts:function(s){
  2235. reim.chatobj[reim.nowtabs].addinput(s);
  2236. $('#aemtsdiv').hide();
  2237. },
  2238. sendfileshow:function(f){
  2239. var num = uploadobj.nownum;
  2240. reim.chatobj[num].sendfileshow(f);
  2241. },
  2242. upprogresss:function(per){
  2243. var num = uploadobj.nownum;
  2244. strformat.upprogresss(per);
  2245. },
  2246. sendfileok:function(f,str){
  2247. var num = uploadobj.nownum;
  2248. reim.chatobj[num].sendfileok(f, str);
  2249. },
  2250. senderror:function(){
  2251. var num = uploadobj.nownum;
  2252. reim.chatobj[num].senderrornss();
  2253. },
  2254. readclip:function(num,e){
  2255. reim.chatobj[num].readclip(e);
  2256. },
  2257. upbase64:function(nuid){
  2258. var o = get('jietuimg_'+nuid+'');
  2259. reim.chatobj[reim.nowtabs].sendbase64(o.src);
  2260. },
  2261. cropScreen:function(){
  2262. if(nwjsgui){
  2263. var oatg = nwjs.getpath();
  2264. nw.Shell.openItem(''+oatg+'/images/reimcaptScreen.exe');
  2265. }
  2266. },
  2267. windowfocus:function(){
  2268. if(jietubool){
  2269. reim.chatobj[reim.nowtabs].pasteimg();
  2270. }
  2271. jietubool = false;
  2272. notifyobj.close();
  2273. nwjs.jumpclear();
  2274. },
  2275. fileyulan:function(pn,fid){
  2276. var url = '?m=public&a=fileviewer&id='+fid+'';
  2277. js.open(url, 800, 500);
  2278. }
  2279. }
  2280. //下载文件预览的,glx0预览,1下载
  2281. strformat.onopenfile=function(da,glx){
  2282. var url = da.upurl;
  2283. if(glx==0 && da.isimg=='1'){
  2284. strformat.imgview(url);
  2285. }else{
  2286. if(glx==1){
  2287. js.location(url);
  2288. }else{
  2289. js.open(url, 1000,600);
  2290. }
  2291. }
  2292. return true;
  2293. }
  2294. strformat.clickface=function(rnd,os){
  2295. $.imgview({url:os.src});
  2296. }
  2297. strformat.openurl=function(dz){
  2298. if(!nwjsgui){
  2299. window.open(dz);
  2300. }else{
  2301. nwjs.openurl(dz);
  2302. //js.open(dz,1000,600);
  2303. }
  2304. }
  2305. strformat.clickfile=function(fid,lx){
  2306. if(isNaN(fid)){
  2307. reim.outgroup.fileopt(fid,lx);
  2308. }else{
  2309. js.fileopt(fid,lx);
  2310. }
  2311. }
  2312. strformat.clickimg=function(o1){
  2313. var o=$(o1);
  2314. var src = o1.src.replace('_s.','.');
  2315. var fid = o.attr('fid');
  2316. $.imgview({
  2317. url:src,
  2318. fileid:fid,
  2319. ismobile:false,
  2320. onloadsuccess:function(img){
  2321. if(img.src.substr(-3)=='gif'){
  2322. o1.src = img.src;
  2323. js.setoption('filesrc_'+this.fileid+'', img.src);
  2324. }
  2325. }
  2326. });
  2327. }
  2328. //外部群使用
  2329. reim.outgroup={
  2330. objarr:[],
  2331. outgrouplist0:[],
  2332. myid:0,
  2333. istxs:'',
  2334. apiurl:'aHR0cDovL2FwaS5yb2Nrb2EuY29tLw::', //如果不想使用清空这个地址就可以
  2335. apiurls:'aHR0cHM6Ly9maWxlLnJvY2tvYS5jb20veGN5Lw::', //https使用
  2336. //apiurl:'aHR0cDovLzE5Mi4xNjguMS4yL2FwcC9yb2NrYXBpLw::',
  2337. geturl:function(fx){
  2338. if(NOWURL.substr(0,5)=='https')this.apiurl = this.apiurls;
  2339. var url = jm.base64decode(this.apiurl)+'?m=outgroup&a='+fx+'&outunum='+this.outunum+'&cfrom=reim';
  2340. return url;
  2341. },
  2342. isopen:function(){
  2343. if(reim.outgroupopen=='open')return true;
  2344. return false;
  2345. },
  2346. clearchache:function(){
  2347. js.setoption('outgrouplist0', '');
  2348. js.setoption('outunum', '');
  2349. },
  2350. reload:function(){
  2351. this.loaddata(this.outunum);
  2352. },
  2353. loaddata:function(unum){
  2354. this.outunum = unum;
  2355. if(!this.isopen()){
  2356. this.clearchache();
  2357. return;
  2358. }
  2359. js.setoption('outunum', unum);
  2360. var me = this;
  2361. reim.ajax(this.geturl('getlist'),{lx:0},function(ret){
  2362. me.showdata(ret.data);
  2363. });
  2364. },
  2365. dellist:function(typ,gid){
  2366. this.updatelist(typ,gid,{}, true);
  2367. },
  2368. updatelist:function(typ,gid,arr,isd){
  2369. var d = false,da=this.outgrouplist0,i,ds=[],d1,j,d2;
  2370. for(i=0;i<da.length;i++){
  2371. d1 = da[i];
  2372. if(d1.type==typ && d1.receid==gid){
  2373. for(j in arr)d1[j]=arr[j];
  2374. d2 = d1;
  2375. }else{
  2376. ds.push(d1);
  2377. }
  2378. }
  2379. if(d2 && !isd)ds.unshift(d2);
  2380. this.outgrouplist0 = ds;
  2381. js.setoption('outgrouplist0', JSON.stringify(ds));
  2382. },
  2383. showdata:function(da){
  2384. var hlist = da.hlist;
  2385. this.outgrouplist0 = hlist;
  2386. js.setoption('outgrouplist0', JSON.stringify(hlist));
  2387. reim.outgrouplist = da.alist;
  2388. var myinfo = da.myinfo;
  2389. reim.showhistory(reim.maindata.harr);
  2390. if(!this.socketob && da.wsconfig)this.linkwebsocket(da.wsconfig,0);
  2391. },
  2392. linkwebsocket:function(conf,lx){
  2393. this.reimconf = conf;
  2394. clearTimeout(this.webtimes);
  2395. if(this.ws)this.ws.close();
  2396. this.ws = new WebSocket(conf.url);
  2397. var me = this;
  2398. this.myid = conf.id;
  2399. this.istxs = conf.istxs;
  2400. this.ws.onopen = function(){
  2401. this.send('{"from":"'+conf.recid+'","adminid":"'+conf.id+'","atype":"connect","sendname":"outname"}');
  2402. me.socketob = true;
  2403. if(lx==1)me.linkwebsocket(conf,2);
  2404. };
  2405. this.ws.onerror = function(e){
  2406. me.socketob = false;
  2407. me.reloadWebSocket(false);
  2408. };
  2409. this.ws.onmessage = function (evt){
  2410. var ds = JSON.parse(evt.data);
  2411. me.onmessage(ds);
  2412. };
  2413. this.ws.onclose = function(e){
  2414. me.socketob = false;
  2415. me.reloadWebSocket(false);
  2416. };
  2417. },
  2418. reloadWebSocket:function(bo){
  2419. clearTimeout(this.webtimes);
  2420. if(!bo){
  2421. this.webtimes=setTimeout('reim.outgroup.reloadWebSocket(true)', 5*1000);
  2422. }else{
  2423. if(!this.socketob)this.linkwebsocket(this.reimconf,1);
  2424. }
  2425. },
  2426. onmessage:function(ds){
  2427. //console.log(ds);
  2428. if(ds.sendid==this.myid && ds.laiyuan=='reim')return;
  2429. ds.ismysend = (ds.sendid==this.myid);
  2430. if(ds.type=='chehui'){
  2431. $('#qipaocont_mess_'+ds.messid+'').html(js.getmsg(jm.base64decode(ds.cont),'green'));
  2432. this.reload();
  2433. }else{
  2434. if(ds.type=='gout' && ds.face){
  2435. ds.zijiid = this.myid;
  2436. if(this.istxs.indexOf(','+ds.gid+',')<0)ds.nottixi = true;
  2437. reim.receivechat(ds);
  2438. }
  2439. }
  2440. },
  2441. fileopt:function(id1,lx){
  2442. js.loading('加载中...');
  2443. reim.ajax(this.geturl('fileinfo'),{lx:lx,id:id1},function(ret){
  2444. var da = ret.data,url = da.url;
  2445. js.unloading();
  2446. if(da.lx==1){
  2447. js.location(url);
  2448. }else{
  2449. js.open(url, 1000,500);
  2450. }
  2451. },'',function(ret){
  2452. js.msgerror(ret.msg);
  2453. });
  2454. }
  2455. }
粤ICP备19079148号