reim_xina.js 77 KB

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