FriendWindow.js 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. /*
  2. 好友初始化区域 此文件为好友窗体使用初始化窗体
  3. */
  4. Namespace.register("U.MD.F.W"); //好友和群窗口区域命名空间
  5. //#region 好友聊天
  6. /**
  7. * 弹出好友窗体处理
  8. *
  9. * @param {object} 群信息
  10. */
  11. U.MD.F.W.viewFriend = U.MD.F.W.SLHCK = function (friendinfo) {
  12. //使用好友系统必须登录
  13. if (!(U.MD.U.L.isLogin())) {
  14. var _childs, //所有的好友元素
  15. _friendel; //好友的信息元素
  16. //如果有传入好友的信息,则查看指定的好友的信息,否则弹出默认的好友窗体
  17. if (friendinfo) {
  18. //如果用户是和自己聊天,那么直接提示不允许,否则弹出好友聊天框
  19. if (friendinfo.UserId == US.userInfo.userid) {
  20. U.alert("无法与本人聊天!");
  21. }
  22. else {
  23. //获取制定好友的点击元素
  24. _friendel = $("#U_MD_F_H_RCO").find("[tid=" + friendinfo.UserId + "]")[0];
  25. //如果查看的好友在好友列表里
  26. if (_friendel) {
  27. _friendel.onclick();
  28. }
  29. //弹出好有窗体
  30. else {
  31. U.MD.F.W.popupFriendsForm(friendinfo);
  32. }
  33. }
  34. }
  35. //弹出默认的好友窗体
  36. else {
  37. _childs = $("#U_MD_F_H_RCO").Child(); //右侧栏
  38. friendinfo = (US.friend.recentcontacts[0] || US.friend.friends[0]); //最近联系人、 我的好友列表
  39. //如果有显示的好友,则弹出第一个好友聊天
  40. if (_childs.length) {
  41. _childs[0].onclick();
  42. }
  43. //查看好友
  44. else {
  45. //这里判断如果弹出的是群聊天框,则选择群信息,需要修改
  46. if (friendinfo && friendinfo.tf) {
  47. friendinfo = U.Json.select(US.friend.group, { "GroupManageID": friendinfo.UserId })[0];
  48. }
  49. //弹出好友信息
  50. U.MD.F.W.popupFriendsForm(friendinfo);
  51. //如果用户没有好友和群,那么则直接弹出推荐好友
  52. if (!friendinfo || (!friendinfo.UserId && !friendinfo.GroupManageID)) {
  53. U.MD.F.W.recommendFriend();
  54. }
  55. }
  56. }
  57. }
  58. }
  59. //#region 空好友提示
  60. /**
  61. * 空好友的提示
  62. *
  63. */
  64. U.MD.F.W.recommendFriend = function () {
  65. U.MD.F.W.printRecommendFriend(US.userInfo.TJF.slice(0, 8), $("#U_MD_F_H_ZR")[0], 1); //推荐好友提示
  66. U.MD.F.W.friendDisplayAndNone([{ "display": "block" }, { "display": "none"}], true); //弹出好友窗体,隐藏右边好友栏
  67. }
  68. /**
  69. * 空用户的提示
  70. *
  71. */
  72. U.MD.F.W.printRecommendFriend = function (friendinfo, el, page) {
  73. //变量定义
  74. var _tempel, //临时元素变量
  75. _temponeel, //临时元素变量
  76. _temptwoel, //临时元素变量
  77. _tempthreeel, //临时元素变量
  78. _tempfourel, //临时元素变量
  79. _tempfiveel //临时元素变量
  80. ;
  81. //清空内容
  82. el.innerText = "";
  83. //创建显示
  84. _tempel = $$("div", {
  85. "className": "U_MD_F_H_ZRO",
  86. "onmousedown": U.UF.EV.stopBubble
  87. });
  88. _temponeel = $$("div", { "className": "U_MD_F_H_ZROS" }, _tempel);
  89. $$("div", { "className": "U_MD_F_H_ZROSS", "innerHTML": "这里暂时没有任何内容哦" }, _temponeel);
  90. $$("div", { "className": "U_MD_F_H_ZROSZ", "innerHTML": "Nothing!!" }, _temponeel);
  91. _temptwoel = $$("div", { "className": "U_MD_F_H_ZROSX" }, _temponeel);
  92. $$("div", { "className": "U_MD_F_H_ZROSXL", "innerHTML": "可尝试点击左边的头像,或追随一下的用户!" }, _temptwoel);
  93. $$("div", { "className": "U_MD_F_H_ZROSXR U_Img" }, _temptwoel);
  94. _temponeel = $$("div", { "className": "U_MD_F_H_ZROX" }, _tempel);
  95. _temptwoel = $$("div", { "className": "U_MD_F_H_ZROXT" }, _temponeel);
  96. $$("div", { "className": "U_MD_HomeSXLTTO U_MD_HomeSXROHTO", "innerHTML": "推荐追随" }, _temptwoel);
  97. $$("div",
  98. { "className": "U_MD_HomeSXLTTI U_Img",
  99. "onclick": function () {
  100. U.MD.F.W.recommendFriend(el, page);
  101. }
  102. },
  103. _temptwoel);
  104. _temptwoel = $$("div", { "className": "U_MD_F_H_ZROXX" }, _temponeel);
  105. //推荐好友循环打印区域
  106. for (i = 0; i < friendinfo.length; i++) {
  107. _tempthreeel = $$("div", { "className": "U_MD_F_H_ZROXXO", "style": { "marginLeft": "65px"} }, _temptwoel);
  108. _tempfourel = $$("div", { "className": "U_MD_F_H_ZROXXOS" }, _tempthreeel);
  109. _tempfiveel = $$("div", { "className": "U_MD_F_H_ZROXXOSL" }, _tempfourel);
  110. $$("img",
  111. { "onerror": U.MD.C.imgError,
  112. "title": "点击查看",
  113. "onclick": function () {
  114. U.UF.EV.stopBubble();
  115. U.MD.U.V.ViewOtherUserInfo(friendinfo[i].UserID);
  116. },
  117. "src": U.MD.C.getHeadImage(friendinfo[i].UserThumbnailImageHead),
  118. "alt": friendinfo[i].UserName
  119. },
  120. _tempfiveel);
  121. $$("div", { "className": "U_MD_F_H_ZROXXOSN U_MD_D_Text_Abbreviation", "innerHTML": friendinfo[i].UserName }, _tempfourel);
  122. $$("div",
  123. { "className": "U_MD_F_H_ZROXXOSR",
  124. "title": "点击追随该用户",
  125. "innerHTML": "追随",
  126. "onclick": function () {
  127. U.MD.F.M.addFriend(friendinfo[i]);
  128. }
  129. },
  130. _tempfourel);
  131. _tempfourel = $$("div", { "className": "U_MD_F_H_ZROXXOX U_MD_HomeSXZLLZOOX" }, _tempthreeel);
  132. $$("div", { "className": "U_MD_F_W_S", "innerHTML": "▲" }, _tempfourel);
  133. $$("div",
  134. { "className": "U_MD_F_W_X",
  135. "innerHTML": function () {
  136. if (friendinfo[i].UserIndividualitysignature) {
  137. friendinfo[i].UserIndividualitysignature.substring(0, 15)
  138. } else {
  139. ("添加我为好友吧,分享我们的信息,让我们距离更近一步").trim()
  140. }
  141. }
  142. },
  143. _tempfourel);
  144. }
  145. //添加内容
  146. el.appendChild(_tempel);
  147. }
  148. //好友推荐变化
  149. U.MD.F.W.recommendFriend = function (el, page) {
  150. var _userinfo = US.userInfo, //登录用户资料
  151. _start = page * 4, //分页的开始
  152. _end = (page + 1) * 4, //分页的结束
  153. _recommendfriend = _userinfo.TJF.slice(_start, _end) //分页获取推荐的用户
  154. ;
  155. //获取的用户存在则打印
  156. if (_recommendfriend.length) {
  157. U.MD.F.W.printRecommendFriend(_recommendfriend, el, page + 1);
  158. }
  159. //否则去数据库取数
  160. else {
  161. U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "RecommendFriends", _userinfo.UserId || US.EMPTYGUID, _userinfo.length, _userinfo.length + 4], U.MD.D.H.AsynSYTJ, [el, el, page]);
  162. }
  163. }
  164. //获取推荐好友
  165. U.MD.F.W.asynRecommendFriend = function (r) {
  166. var _userinfo = US.userInfo, //登录用户资料
  167. _context = r.context, //回调的参数
  168. _el = _context[1], //输出的内容区域
  169. _page = _context[2] //输出的号码
  170. ;
  171. r = r.value; //获取推荐用户的返回值
  172. _userinfo = _userinfo.concat(r); //获取的推荐用户存储到用户推荐用户信息里
  173. U.MD.F.W.printRecommendFriend(r, _el, _page + 1); //打印推荐好友
  174. }
  175. //#endregion
  176. //#region
  177. /**
  178. * 好友聊天器里查看好友聊天
  179. *
  180. * @param {object} 群信息
  181. */
  182. U.MD.F.W.popupFriendsForm = function (friendinfo, el) {
  183. //登录的用户才能弹出窗体
  184. var _close;
  185. if (!U.MD.U.L.isLogin()) {
  186. var _friendform = $("#U_MD_F_H_ZA")[0];
  187. //判断窗体是否创建如果创建直接显示,如果没有则创建
  188. if (!_friendform) {
  189. $("#U_MD_F_H_Z")[0].style.display = "block";
  190. //创建窗体弹出窗体
  191. var _window = new U.UF.UI.form("",
  192. $("#U_MD_F_H_Z")[0],
  193. {
  194. "resize": U.MD.F.W.reSize,
  195. "id": "U_MD_F_H_ZA",
  196. "style": {
  197. "display": "block",
  198. "height": "80%"
  199. }
  200. },
  201. {
  202. isstretching: false,
  203. isnarrow: false
  204. });
  205. _close = $($($($($(_window.content).Parent()).Parent()).Parent()).Child()[3]).Child()[0]; //获取关闭按钮
  206. _close.onclick = function () {
  207. U.MD.F.W.friendDisplayAndNone([{ "display": "none" }, { "display": "block"}], { "left": "auto", "right": "0px" });
  208. }
  209. }
  210. //指定元素
  211. else {
  212. U.UF.F.topWindow($("#U_MD_F_H_ZA")[0]);
  213. }
  214. //隐藏好友右边的显示,显示窗体
  215. U.MD.F.W.friendDisplayAndNone([{ "display": "block" }, { "display": "none"}]);
  216. U.MD.F.W.openFriendChat(friendinfo); //打开指定的好友聊天显示
  217. // U.MD.F.W.reSize(); //好友聊天区域大小初始化
  218. }
  219. }
  220. /**
  221. * 初始化好友聊天区域
  222. *
  223. * @param {object} 群信息
  224. */
  225. U.MD.F.W.openFriendChat = function (friendinfo) {
  226. var _friendfromel = $("#U_MD_F_H_ZR")[0], //整个好友窗体元素
  227. _friendchatfrom = $("#U_MD_F")[0], //好友聊天区域元素
  228. _userid = friendinfo.GroupManageID || friendinfo.UserId, //打开群或者好友的窗体
  229. _chatform = U.MD.F.W.isCreateForm(_userid), //判断窗体是否已经打开创建
  230. _isgroup = friendinfo.GroupManageID != null
  231. ;
  232. _friendchatfrom.style.display = "block"; //默认是隐藏,这些显示
  233. _friendfromel.appendChild(_friendchatfrom); //追加聊天区域
  234. //如果好友聊天框不存在,则创建好友聊天框
  235. if (!_chatform) {
  236. _chatform = U.MD.F.W.createFriendChat(friendinfo);
  237. }
  238. //选择到指定的窗体
  239. U.MD.F.W.switchFriendsChat(_chatform, friendinfo);
  240. //好友聊天查看
  241. U.MD.F.H.getFriendOrGroupNews(_userid, function (r) {
  242. U.MD.F.N.asynReceiveMessages(_isgroup, _chatform[1], r.value);
  243. }, _isgroup);
  244. }
  245. //大小变化处理
  246. U.MD.F.W.reSize = function () {
  247. U.MD.F.W.leftSize(); //左边的处理
  248. U.MD.F.W.chatBoxSize($("#U_MD_F_H_ZA")[0], U.MD.F.W.switchFriendsChat.Ele || $("#U_MD_F")[0].childs[0].element[1]); //右边聊天框处理
  249. }
  250. /**
  251. * 好友聊天左边聊天框显示,主要是好友显示的区域的大小加上上面的导航等于整个左边的高
  252. *
  253. */
  254. U.MD.F.W.leftSize = function () {
  255. //获取容器DIV
  256. var _content = $("#U_MD_F_H_ZA")[0];
  257. if (_content) {
  258. //得到高度
  259. var _height = _content.offsetHeight,
  260. _childs = $(".U_MD_F_H_ZL").Child(); //获取下面的所有的孩子节点
  261. //设置下面的高度等于整个高度-导航的高度
  262. $("#U_MD_F_H_ZLZ")[0].style.height = _height - _childs[0].offsetHeight - _childs[1].offsetHeight - 30 + "px";
  263. }
  264. }
  265. //调整好友聊天框
  266. U.MD.F.W.chatBoxSize = function (el, chatel) {
  267. var i, //用于循环
  268. _childs, //0 聊天区域 1聊天记录区域
  269. _rightchilds = $(chatel).Child(), //获取整个右边好友聊天区域的子元素
  270. _chatchilds = $(chatel.parentNode).Child(), //获取聊天区域的子元素
  271. _height = el.offsetHeight, //右边的高
  272. _width = chatel.offsetWidth; //右边的长
  273. //循环设置
  274. for (i = 0; i < _chatchilds.length; i++) {
  275. //聊天记录和聊天框的大小设置
  276. _childs = $(_chatchilds[i]).Child();
  277. _childs[0].style.width = _width - _childs[1].offsetWidth + "px";
  278. _childs[1].style.height = _height - 90 + "px";
  279. //聊天框的大小设置
  280. $(".U_MD_F_CA", _chatchilds[i]).css("height", _height - 380 + "px");
  281. }
  282. }
  283. /**
  284. * 设置好友窗体打开和关闭的状态
  285. *
  286. * @param {array} 显示隐藏的集合
  287. */
  288. U.MD.F.W.friendDisplayAndNone = function (style) {
  289. var _friendform = $("#U_MD_F_H_ZA"), //好友窗体
  290. _friendright = $("#U_MD_F_H_R"); //好友右侧
  291. _friendform.addAttrArray({ "style": style[0] }); //给窗体设置参入的css值
  292. _friendright.addAttrArray({ "style": style[1] }); //给窗体设置参入的css值
  293. }
  294. //#endregion
  295. //判断是否需要创建
  296. /**
  297. * 根据friendid判断好友窗体是否创建
  298. *
  299. * @param {object} 群信息
  300. */
  301. U.MD.F.W.isCreateForm = function (friendid) {
  302. var i, //用于循环处理
  303. _friendchatform = $("#U_MD_F")[0]; //好友聊天框
  304. if (_friendchatform.childs) { //判断是否打开了聊天
  305. for (i = 0; i < _friendchatform.childs.length; i++) { //循环所有打开的聊天找到已经和friendid对应打开的好友聊天
  306. if (_friendchatform.childs[i].formid == friendid) { //如果找到匹配的好友聊天框或者群聊天框,则直接返回
  307. return _friendchatform.childs[i].element;
  308. }
  309. }
  310. }
  311. }
  312. /**
  313. * 生成统一的好友窗体区域
  314. *
  315. * @param {object} 好友或群信息
  316. */
  317. U.MD.F.W.createFriendChat = function (friendandgroupinfo) {
  318. //变量定义
  319. var _headel,
  320. _headimageel,
  321. _chatel,
  322. _chatleftel,
  323. _chatheadel,
  324. _chatheadimageel,
  325. _chatheadcontentel,
  326. _chatheadpromptel,
  327. _chatcontentel,
  328. _chatcontentnewsel,
  329. _chatnewsel,
  330. _chatnewsoneel,
  331. _chatnewstwoel,
  332. _chateditel,
  333. _chatbuttonel,
  334. _chatbuttonsendel,
  335. _chatrecordel,
  336. _buttondiv,
  337. _userid,
  338. _name,
  339. descript,
  340. _chatformel,
  341. _chatformchilds,
  342. _navichilds;
  343. //群id获取好友id,作为窗体的唯一识别id
  344. _userid = friendandgroupinfo.GroupManageID ||
  345. friendandgroupinfo.UserId;
  346. //显示在聊天框的名字,群名、好友描述、好友名字
  347. _name = friendandgroupinfo.GroupManageName ||
  348. friendandgroupinfo.FriendsDescript ||
  349. friendandgroupinfo.UserNickName;
  350. //群描述、好友签名
  351. descript = friendandgroupinfo.GroupManageDescript ||
  352. friendandgroupinfo.UserIndividualitysignature ||
  353. "暂时没有填写介绍..";
  354. //聊天框元素
  355. _chatformel = $("#U_MD_F")[0];
  356. //聊天区域的还在元素
  357. _chatformchilds = $(_chatformel).Child();
  358. //头部切换导航区域的元素
  359. _navichilds = $(_chatformchilds[0]).Child();
  360. //头部标签
  361. _headel = $$("div", {
  362. "className": "U_MD_F_TO",
  363. "onmousedown": U.UF.EV.stopBubble
  364. }, _navichilds[0], _navichilds[0].firstChild);
  365. _headimageel = $$("div", { "className": "U_MD_F_TOI" }, _headel);
  366. $(_headel).attr("user", _userid);
  367. //好友显示头像
  368. if (friendandgroupinfo.UserId) {
  369. $$("img", { "onerror": U.MD.C.imgError,
  370. "onerror": U.MD.C.imgError,
  371. "title": "点击查看",
  372. "src": U.MD.C.getHeadImage(friendandgroupinfo.UserThumbnailImageHead),
  373. "alt": friendandgroupinfo.UserNickName
  374. }, _headimageel);
  375. }
  376. //群显示头像
  377. else {
  378. U.MD.F.printGroupHeadImage(friendandgroupinfo, _headimageel, 4, [25, 25]);
  379. }
  380. $$("div", { "className": "U_MD_F_TON U_MD_D_Text_Abbreviation", "innerHTML": _name }, _headel);
  381. $$("div", {
  382. "className": "U_MD_F_TOC U_Img",
  383. "onclick": function () {
  384. U.MD.F.W.delteFriendChat(_userid, _chatformel, friendandgroupinfo);
  385. }
  386. }, _headel);
  387. //聊天区
  388. _chatel = $$("div", { "className": "U_MD_F_NA" });
  389. _chatformchilds[1].insertBefore(_chatel, _chatformchilds[1].firstChild);
  390. //左侧
  391. _chatleftel = $$("div", { "className": "U_MD_F_N" }, _chatel);
  392. //头部信息
  393. _chatheadel = $$("div", { "className": "U_MD_F_H" }, _chatleftel);
  394. _chatheadimageel = $$("div", { "className": "U_MD_F_HH" }, _chatheadel);
  395. if (friendandgroupinfo.GroupManageID) {
  396. U.MD.F.printGroupHeadImage(friendandgroupinfo, _chatheadimageel);
  397. $(_chatheadimageel).addAttrArray({ onclick: function () { U.MD.F.J.groupInfoForm(friendandgroupinfo, _chatleftel); }, title: friendandgroupinfo["GroupManageName"] });
  398. }
  399. else {
  400. $$("img", { "onerror": U.MD.C.imgError,
  401. "onerror": U.MD.C.imgError,
  402. "title": "点击查看",
  403. "onclick": function () {
  404. U.UF.EV.stopBubble();
  405. if (U.MD.D.IsUseStudio) {
  406. U.MD.U.V.ViewOtherUserInfo(_userid);
  407. }
  408. },
  409. "src": U.MD.C.getHeadImage(friendandgroupinfo.UserThumbnailImageHead),
  410. "alt": friendandgroupinfo.UserNickName
  411. }, _chatheadimageel);
  412. }
  413. _chatheadcontentel = $$("div", { "className": "U_MD_F_HT U_MD_D_Text_Abbreviation" }, _chatheadel);
  414. $$("div", { "className": "U_MD_F_HTN", "innerHTML": _name }, _chatheadcontentel);
  415. $$("div", { "className": "U_MD_F_HTC", "innerHTML": (friendandgroupinfo.GroupManageDescript || friendandgroupinfo.UserIndividualitysignature || "暂时没有填写介绍..") }, _chatheadcontentel);
  416. _chatheadpromptel = $$("div", { "className": "U_MD_F_HG" }, _chatleftel);
  417. $$("div", { "className": "U_MD_F_GI U_Img" }, _chatheadpromptel);
  418. $$("div", { "className": "U_MD_F_GC", "innerHTML": "交谈中请勿轻信汇款、中奖信息、陌生电话..." }, _chatheadpromptel);
  419. $$("div", { "style": {
  420. "width": "10px",
  421. "height": "10px",
  422. "background-image": "url('/img/YS2017.png')",
  423. "display": "inline-block",
  424. "background-repeat": "no-repeat",
  425. "background-position": "-817px -482px",
  426. "float": "right",
  427. "margin": "8px"
  428. },
  429. "onclick": function () { _chatheadpromptel.style.visibility = "hidden"; }
  430. }, _chatheadpromptel);
  431. //内容发布区
  432. _chatcontentel = $$("div", { "className": "U_MD_F_CA" }, _chatleftel);
  433. _chatcontentnewsel = $$("div", { "className": "U_MD_F_C" }, _chatcontentel);
  434. //发布内容区域
  435. _chatnewsel = $$("div", { "className": "U_MD_F_D", "style": { "position": "relative"} }, _chatleftel);
  436. _chatnewsoneel = $$("div", { "className": "U_MD_F_DA" }, _chatnewsel);
  437. _chatnewstwoel = $$("div", { "className": "U_MD_F_DT" }, _chatnewsoneel);
  438. _chateditel = $$("div", { "className": "U_MD_F_DC", "contentEditable": "true" }, _chatnewsoneel);
  439. $$("div", { "className": "U_MD_F_DJ U_Img" }, _chatnewsoneel);
  440. // 按钮区域
  441. _chatface = $$("div", { "style": { "margin-top": "-194px", "margin-left": "14px"} }, _chatformel);
  442. _chatbuttonel = $$("div", { "className": "U_MD_F_X" }, _chatleftel);
  443. _chatbuttonsendel = $$("div", {
  444. "className": "U_MD_F_XE",
  445. "innerHTML": "发送(Ctrl+Enter)",
  446. "style": {
  447. "marginRight": "15px"
  448. },
  449. "onclick": function () {
  450. U.MD.F.H.sendFriendOrGroupChatMessage(friendandgroupinfo, _chateditel, _chatcontentnewsel, (friendandgroupinfo.UserId == null));
  451. }
  452. }, _chatbuttonel);
  453. $$("div", {
  454. "className": "U_MD_F_XC",
  455. "innerHTML": "关闭(n)",
  456. "onclick": function () {
  457. U.MD.F.W.friendDisplayAndNone([{ "display": "none" }, { "display": "block"}], { "left": "auto", "right": "0px" });
  458. }
  459. }, _chatbuttonel);
  460. //右侧聊天记录
  461. _chatrecordel = $$("div", { "className": "U_MD_F_L" }, _chatel);
  462. $$("div", { "className": "U_MD_F_LA" }, _chatrecordel);
  463. $$("div", { "className": "U_MD_F_LB" }, _chatrecordel);
  464. //事件赋值
  465. _buttondiv = $$("div", {
  466. "className": "U_MD_F_DTF U_MD_F_W_Face",
  467. "title": "发送表情",
  468. "style": {
  469. "margin": "0",
  470. "position": "relative",
  471. "background": "url(/img/face.png) no-repeat 0",
  472. "background-size": "20px"
  473. }
  474. }, _chatnewstwoel);
  475. $$("button", {
  476. "style": {
  477. "opacity": "0",
  478. "width": "28px",
  479. "height": "28px"
  480. },
  481. "onmousedown": function () {
  482. U.MD.UI.face(_chatface, _chateditel);
  483. },
  484. "onclick": U.UF.EV.stopBubble
  485. }, _buttondiv);
  486. _chatheadimageel = $$("div", {
  487. "className": "U_MD_F_UploadPng U_Img",
  488. "title": "添加文件",
  489. "style": { "cssText": "margin-left:5px" },
  490. "onclick": function (e) {
  491. if ($(".U_MD_F_UploadInput")[0]) {
  492. //删除弹出框
  493. $(".U_MD_F_UploadInput").remove();
  494. return;
  495. }
  496. var _firendinfo = friendandgroupinfo;
  497. var _div = $$("div", { "className": "U_MD_F_UploadInput", style: { "cssText": "width:154px;float:none;position:absolute;background-color:#fff;z-Index:999;border:1px solid #ccc;height:80px;text-align:center;top:-78px;left:-12px" }, "fiendInfo": friendandgroupinfo, "place": _chatcontentnewsel }, _chatheadimageel);
  498. var _local = $$("div", { "className": "U_MD_F_LoaclChose", innerHTML: "选择本地上传文件", style: { "cssText": "position:relative;float:none;width:100%;height:32px;margin:8px 0 0 0;line-height:32px" },
  499. onclick: function () {
  500. var _groupid,
  501. _ancestors,
  502. _directoryid = US.disk.Disks[US.userInfo.userid].directoryid,
  503. _dirinfo = U.Json.select(US.disk.Disks[US.userInfo.userid].directoryOrFiles, { "UserDirectoryID": _directoryid })[0];
  504. //获取粘贴到制定目录的群id
  505. _ancestors = U.MD.DK.C.getAncestors(_dirinfo, US.disk.Disks[US.userInfo.userid]); //获取所有的祖先
  506. //如果是ftp目录,那么groupid就是用户id
  507. if (_ancestors[_ancestors.length - 1].UserDirectoryID == US.FTPFOLDERID) {
  508. _groupid = US.disk.Disks[US.userInfo.userid].userInfo.UserId;
  509. }
  510. //否则就是对应的群id,如果不存在那么就是""
  511. else {
  512. _groupid = _ancestors[_ancestors.length - 1].GroupID || "";
  513. }
  514. U.MD.UI.upload(
  515. "http://main.1473.cn/USUpfile.ashx?typename=UploadFlashfile&DirectoryId=" + _directoryid + "&Encrypt=" + _groupid + "&UserId=" + US.userInfo.userid + "&IsF=true", //上传的地址
  516. //上传成功的回调函数
  517. function (r, fileinfo) {
  518. var _data = r.data //获取服务器返回值
  519. ; //根据文件的唯一识别id获取文件的信息
  520. //获取从服务器获取的值,这里加一个错误处理,因为如果后台出现了错误,那么eval的过程就会失败
  521. try {
  522. _data = eval("0," + _data);
  523. }
  524. catch (e) { }
  525. var _fileInfo = {
  526. "UserallDirectoryName": fileinfo.name,
  527. "UserDirectoryExtendType": U.UF.UP.getFileNameAndExtension(fileinfo.name)[1],
  528. "UserDirectorySize": _data[3],
  529. "UserDirectoryID": _data[2],
  530. "UserDirectoryUrl": _data[1]
  531. }
  532. U.MD.F.W.printMessageContent(_fileInfo.UserDirectoryExtendType, _fileInfo, _chatcontentnewsel, true, _firendinfo);
  533. },
  534. //得到md5的回调函数
  535. function (md5, fileinfo, cb) {
  536. //根据用户的md5值判断用户是否需要上传,如果需要上传则需要执行上传处理,如果已经存在后台直接给用户生成文件路径等录入数据库
  537. U.A.Request(US.AUTH, ["IfFileExistInsertDB", US.userInfo.userid, _directoryid, _groupid, fileinfo.size, md5, U.UF.UP.getFileNameAndExtension(fileinfo.name)[1], fileinfo.name],
  538. //判断上传文件是否存在
  539. function (r) {
  540. var _userid = US.userInfo.userid; //当前登录用户的id
  541. r = r.value;
  542. //获取服务器返回的值,如果服务器响应出问题了,eval的时候就会报错。
  543. try {
  544. r = eval(r)[0];
  545. }
  546. catch (e) { }
  547. //当用户想上传的文件已经在数据库里存在了,那么后台会执行复制数据的操作。
  548. if (r) {
  549. var _fileInfo = {
  550. "UserallDirectoryName" : r.UserDirectoryName.addEllipsis(20),
  551. "UserDirectoryExtendType" : U.UF.UP.getFileNameAndExtension(r.UserDirectoryName)[1],
  552. "UserDirectorySize":r.UserDirectorySize,
  553. "UserDirectoryID":r.UserDirectoryID,
  554. "UserDirectoryUrl": r.UserDirectoryUrl
  555. }
  556. U.MD.F.W.printMessageContent(_fileInfo.UserDirectoryExtendType, _fileInfo, _chatcontentnewsel, true, _firendinfo);
  557. cb(false);
  558. }
  559. //否则调用flash里面的函数执行用户的上传操作。
  560. else {
  561. cb(true);
  562. }
  563. });
  564. });
  565. //阻止冒泡
  566. U.UF.EV.stopBubble()
  567. //删除弹出框
  568. $(".U_MD_F_UploadInput").remove();
  569. }
  570. }, _div);
  571. var _localinput = $$('input', { 'type': 'file', style: { "cssText": "position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0;" },
  572. onchange: function () {
  573. if (this.files.length) { //判断是否存在文件
  574. var _range = U.UF.E.getRangeAt(); //获取光标处理
  575. U.UF.UP.inputUpload([this], 'http://main.1473.cn/USUpfile.ashx?typename=UseStudioEditor', function (r) { //调用统一上传处理
  576. var _file, _filetype, _input = r.context[0];
  577. var _imgtype = /.*(jpg|png|gif|jpeg|JPG|PNG|GIF|JPEG|bmp|BMP)$/;
  578. var _filearray = []; //记录上传图片的数组
  579. if (Object.prototype.toString.call(r.value[0]) != "[object Array]") { //根据返回值类型判断是否多图上传
  580. _filearray = [r.value]; //单图用数组则直接记录
  581. } else {
  582. _filearray = r.value; //多图则直接替换即可
  583. }
  584. var _el, _frag = $$('frag');
  585. for (i = 0; i < _filearray.length; i++) { //循环评接拼接
  586. _file = _input.files[i];
  587. _filetype = _file.name.substring(_file.name.lastIndexOf('.') + 1, _file.name.length); //获取文件后缀名
  588. if (_filetype.match(_imgtype)) {//图片类型处理
  589. _el = $$("div", {}, _frag); ;
  590. $$('span', { innerHTML: ' <img src="http://fs.1473.cn/' + _filearray[i][0] + '">' }, _el);
  591. }
  592. else { //其余文件类型处理
  593. _el = U.UF.E.attachment.create(_file, _filearray[i][2], _filetype);
  594. $(_el).appendTo(_frag);
  595. }
  596. }
  597. var _data = [_div.fiendInfo, _div.place]
  598. var _filedata = { 'UserallDirectoryName': _file.name, 'UserDirectoryExtendType': _filetype, 'UserDirectorySize': _file.size, 'UserDirectoryID': r.value[2], 'UserDirectoryUrl': r.value[0] };
  599. U.MD.F.W.printMessageContent(_filetype, _filedata, _data[1], true, _data[0]);
  600. }, [this]);
  601. }
  602. }
  603. }, _local);
  604. var _disk = $$("div", { "className": "U_MD_F_DiskChose", innerHTML: "选择网盘上传文件", style: { "cssText": "float:none;width:100%;height:32px;margin:0 0 0 0;line-height:32px" },
  605. onclick: function () {
  606. //阻止冒泡
  607. U.UF.EV.stopBubble()
  608. U.MD.DK.VW.choseFile(function (data) {
  609. var _data = [$('.U_MD_F_UploadInput')[0].fiendInfo, $('.U_MD_F_UploadInput')[0].place]
  610. //根据选择的文件生成内容
  611. U.MD.F.W.printMessageContent(data.UserDirectoryExtendType, data, _data[1], true, _data[0]);
  612. //删除弹出框
  613. $(".U_MD_F_UploadInput").remove();
  614. })
  615. }
  616. }, _div);
  617. }
  618. }, _chatnewstwoel);
  619. if (friendandgroupinfo.GroupManageID) {
  620. $$("div", {
  621. "className": "U_MD_F_DTS U_Img",
  622. "title": "网盘提交",
  623. "onclick": function () {
  624. U.MD.D.I.openApplication("disk",
  625. {
  626. "userid": US.userInfo.userid,
  627. "directoryid": friendandgroupinfo.GroupManageID
  628. });
  629. }
  630. }, _chatnewstwoel);
  631. }
  632. $$("div", {
  633. "className": "U_MD_F_DTJ U_Img",
  634. "title": "聊天记录",
  635. "onclick": function () {
  636. U.MD.F.H.viewFriendsChatRecords(_chatrecordel, friendandgroupinfo, 1, (friendandgroupinfo.UserId == null));
  637. }
  638. }, _chatnewstwoel);
  639. _chateditel.onkeydown = function () {
  640. if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {
  641. _chatbuttonsendel.onclick(); //发送消息
  642. U.UF.EV.stopDefault(); //回车处理
  643. }
  644. };
  645. U.UF.E.initEditor(_chateditel); //初始化编辑器处理
  646. _headel.onclick = function () {
  647. U.MD.F.W.switchFriendsChat([_headel, _chatel], friendandgroupinfo);
  648. }; //切换事件
  649. //设置光标处理
  650. // U.UF.E.GetSelectionRange(window, _chateditel, { "TF": "Friend" });
  651. //创建的好友窗体记录
  652. if (_chatformel.childs == null) {
  653. _chatformel.childs = [];
  654. }
  655. _chatformel.childs.unshift({ "formid": _userid, "element": [_headel, _chatel], "info": friendandgroupinfo }); //添加记录
  656. return _chatformel.childs[0].element;
  657. }
  658. //
  659. /**
  660. * 好友聊天切换
  661. *
  662. * @param {string} 好友的id
  663. * @param {element} 窗体元素
  664. */
  665. U.MD.F.W.switchFriendsChat = function (elements, friendorgroupinfo) {
  666. var i,
  667. _friendchatel,
  668. _topleftbottom,
  669. _chatel = $(elements[1]).Parent(2),
  670. _topbottom = $($(_chatel).Child()[0]).Child()[2], //右上角功能按钮
  671. _chatchilds = $(_chatel)[0].childs;
  672. //判断右上角功能按钮是否存在
  673. if (_topbottom.children[0]) {
  674. _topbottom.children[0].remove();
  675. }
  676. //显示当前elements的聊天窗体,其他的隐藏
  677. for (i = 0; i < _chatchilds.length; i++) {
  678. _friendchatel = _chatchilds[i].element;
  679. if (_friendchatel[0] == elements[0] && _friendchatel[1] == elements[1]) { //需要显示的聊天框
  680. U.MD.F.W.switchFriendsChat.Ele = elements[1];
  681. $(elements[0]).addClass("U_MD_F_TOT");
  682. $(elements[1]).css("display", "block");
  683. //可编辑区域聚焦
  684. $(".U_MD_F_DC", elements[1])[0].focus();
  685. }
  686. else { //需要隐藏的聊天框
  687. $(_friendchatel[0]).removeClass("U_MD_F_TOT");
  688. $(_friendchatel[1]).css("display", "none");
  689. }
  690. }
  691. //右上角功能点击处理处理
  692. _topbottom.onclick = function () {
  693. U.UF.EV.stopBubble();
  694. U.MD.F.R.popupRightCornerMenu(friendorgroupinfo, _topbottom);
  695. $("#U_MD_F_Add_O")[0].style.display="none";
  696. var _friendmenuel = $('#U_MD_F_G_Group')[0], //右键的菜单
  697. _child = $(_friendmenuel).Child(); //子菜单
  698. //显示菜单,定位
  699. $(_friendmenuel).css({ "display": "block", "zIndex": "999" });
  700. U.UF.C.rightClickMenuLocation(_friendmenuel); //右键菜单定位
  701. new_element=document.createElement("script");
  702. new_element.setAttribute("type","text/javascript");
  703. new_element.setAttribute("src","http://friend.1473.cn/js/Friend/Add.js");// 在这里引入了a.js
  704. document.body.appendChild(new_element);
  705. //按钮功能赋值
  706. _child[0].onclick = function () { $("#U_MD_F_Add_O")[0].style.display="block";/*U.MD.F.R.popupRightCornerMenu(friendorgroupinfo, _topbottom);*/ }; //查看群聊资料
  707. _child[1].onclick = function () { $(".U_MD_F_Add_B")[0].click(); }; //退出/解散群聊
  708. //点击其它区域隐藏右键菜单
  709. $(document).bind("click", function () {
  710. $(_friendmenuel)[0].style.display = "none";
  711. })
  712. if($(".U_MD_F_Add_B")[0].innerHTML=="解散该群"){
  713. _child[1].innerHTML="解散该群";
  714. }else{
  715. _child[1].innerHTML="退出该群";
  716. }
  717. };
  718. if (friendorgroupinfo.UserId) {
  719. _topleftbottom = "个人信息";
  720. } else {
  721. _topleftbottom = "创建群";
  722. }
  723. _topbottom.title = _topleftbottom;
  724. //好友聊天框
  725. U.MD.F.W.chatBoxSize($(elements[1]).Parent(7), elements[1]);
  726. }
  727. /**
  728. * 删除单个好友聊天
  729. *
  730. * @param {string} 好友的id
  731. * @param {element} 窗体元素
  732. */
  733. U.MD.F.W.delteFriendChat = function (friendid, el) {
  734. var i, j, //循环处理
  735. _chatinfo, //好友聊天的好友或者群信息
  736. _elements, //好友聊天信息的框
  737. _childs = $(el)[0].childs; //获取所有的聊天框
  738. U.UF.EV.stopBubble();
  739. //剩下最后一个直接关闭聊天框
  740. if (_childs.length == 1) {
  741. U.MD.F.W.friendDisplayAndNone([{ "display": "none" }, { "display": "block"}], { "left": "auto", "right": "0px" }); //移除
  742. }
  743. else {
  744. //循环找到friendid对应的弹框
  745. for (i = 0; i < _childs.length; i++) {
  746. //判断窗体的id和好友的id是否一致
  747. if (_childs[i].formid == friendid) {
  748. _elements = _childs[i]["element"]; //获取根据friendid创建的所有的元素
  749. for (j = 0; j < _elements.length; j++) { //循环所有的元素,然后全部删除
  750. $(_elements[j]).remove(); //移除元素处理
  751. }
  752. _childs.splice(i, 1); //在所有孩子元素中删除该元素
  753. //判断当前窗体是否在正在进行的聊天窗体,如果是的话,删除了这个窗体后要把下面的窗体显示出来
  754. if (_elements[0].className.indexOf("U_MD_F_TOT") > -1) {
  755. //获取下一个要显示的聊天框
  756. _chatinfo = _childs[i] || _childs[i - 1]; //下一个或者是上一个
  757. //显示该聊天框
  758. U.MD.F.W.switchFriendsChat(_chatinfo["element"], _chatinfo["info"]);
  759. }
  760. break;
  761. }
  762. }
  763. }
  764. }
  765. //生成发表聊天消息和获取聊天消息区域
  766. /**
  767. * 查看聊天好友
  768. * @param {element} 打印的内容区域
  769. * @param {array} 打印消息的数组
  770. * @param {boolean} 判断消息是自己发送的还是获取的
  771. ---------- true 自己发送的
  772. ---------- flase 获取的带的
  773. */
  774. U.MD.F.W.printFriendChatMessage = function (el, newsinfo, issend) {
  775. var i,
  776. _date, //打印的时间
  777. _chatcontentel,
  778. _chatcontentoneel,
  779. _chatcontentwordsel,
  780. _chatel = el.parentNode, //聊天框
  781. _frag = $$("frag");
  782. if (issend) {
  783. _stylearray = ["U_MD_F_CT", " U_MD_F_CTLC U_MD_F_GCTLC", " U_MD_F_COLCOO", " U_MD_F_CTTO", " "];
  784. } else {
  785. _stylearray = ["U_MD_F_CO", "", " U_MD_F_COLCOT", " U_MD_F_CTT"];
  786. } //打印的样式
  787. //打印的消息
  788. var _el;
  789. for (i = 0; i < newsinfo.length; i++) {
  790. _date = U.UF.D.getYearMonthDay(newsinfo[i]["MessageSendTime"]) || U.UF.D.getYearMonthDay(newsinfo[i]["GroupMessageSendTime"]) || newsinfo[i]["Time"], "Array";
  791. _contentBox = $$("div", { "style": { "margin": " 0 10px"} }, _frag);
  792. _time = $$("div", { "className": "U_MD_F_COTO U_MD_F_CTO", "style": { "margin": " 0 10px", "text-align": "center", "color": "#aaaaaa", "font-size": "13px" }, "innerHTML": (_date) }, _contentBox);
  793. _contentel = $$("div", { "className": _stylearray[0], "title": newsinfo[i].GroupMessageSendUsername || newsinfo[i].MessageDescript || newsinfo[i].Name }, _contentBox);
  794. _content = $$("div", {}, _contentel);
  795. _contentoneel = $$("div", { "className": "U_MD_F_COLC" + _stylearray[1] }, _content);
  796. _contentimgel = $$("img",
  797. {
  798. "onerror": U.MD.C.imgError,
  799. "title": "点击查看",
  800. "onclick": function () {
  801. U.MD.U.V.ViewOtherUserInfo(newsinfo[i].GroupMessageSendUser || newsinfo[i].UserId);
  802. },
  803. "src": U.MD.C.getHeadImage((newsinfo[i].IMG || newsinfo[i].UserThumbnailImageHead)),
  804. "className": "U_MD_F_COLCI"
  805. },
  806. _contentel);
  807. //如果消息类型为6
  808. if (newsinfo[i].MessageIsVerify == 6) {
  809. var _filedata = JSON.parse(newsinfo[i].MessageContent),
  810. //生成盒子,并且绑定点击事件
  811. _filebox = $$('div', { style: { cssText: 'position:relative; padding: 10px; background-color: #fff; border:1px solid silver; overflow:hidden; cursor: pointer;'} }, _contentoneel)
  812. U.MD.F.W.printFileContent(_filedata, _filebox)
  813. } else {
  814. _el = newsinfo[i]["MessageContent"] || newsinfo[i]["GroupMessageContent"] || newsinfo[i]["Content"]
  815. if (U.UF.C.isElement(_el)) {
  816. _contentwordsel = $$("div", { "className": "U_MD_F_COLCO " + _stylearray[2] }, _contentoneel);
  817. $(_el).appendTo(_contentwordsel);
  818. } else {
  819. _contentwordsel = $$("div", { "className": "U_MD_F_COLCO " + _stylearray[2], "innerHTML": _el }, _contentoneel);
  820. }
  821. }
  822. if (issend) {
  823. _contentoneimgel = $$("div", { "style": { "width": "6px", "height": "10px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-984px -344px", "margin": "10px 4px 10px 0px"} }, _content);
  824. _content.style.float = "right";
  825. _contentel.insertBefore(_contentimgel, _content);
  826. _contentimgel.style.float = "right";
  827. _content.style.marginRight = "8px";
  828. } else {
  829. _contentoneimgel = $$("div", { "style": { "width": "6px", "height": "10px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-1004px -344px", "margin": "10px 0px 10px 4px"} }, _content);
  830. _content.style.float = "left";
  831. _contentel.insertBefore(_contentimgel, _content);
  832. }
  833. }
  834. el.appendChild(_frag);
  835. //消息定位到底部
  836. _chatel.scrollTop = _chatel.scrollHeight - _chatel.offsetHeight;
  837. }
  838. /**
  839. * 查看聊天 好友或者群
  840. * @param {element} 打印的内容区域
  841. * @param {array} 打印消息的数组
  842. * @param {boolean} 判断消息是自己发送的还是获取的
  843. ---------- true 自己发送的
  844. ---------- flase 获取的带的
  845. */
  846. U.MD.F.W.printGroupChatMessage = function (el, newsinfo, issend) {
  847. var i,
  848. _date,
  849. _contentel,
  850. _contentoneel,
  851. _contentwordsel,
  852. _contentimgel,
  853. _contentnameel,
  854. _stylearray,
  855. _chatcontentel = el.parentNode,
  856. _frag = $$("frag");
  857. //发送消息是自己和他人区别的样式
  858. if (issend) {
  859. _stylearray = ["U_MD_F_CT", " U_MD_F_CTLC U_MD_F_GCTLC", " U_MD_F_COLCOO", " U_MD_F_CTTO", " "];
  860. }
  861. else {
  862. _stylearray = ["U_MD_F_CO", "", " U_MD_F_COLCOT", " U_MD_F_CTT"];
  863. }
  864. //循环打印聊天消息
  865. for (i = 0; i < newsinfo.length; i++) {
  866. var _isFile = true;
  867. // try{
  868. // var _obj = JSON.parse(newsinfo[i].GroupMessageContent);
  869. // if(typeof obj == 'object' && obj )
  870. // _isFile = true;
  871. //
  872. // }catch(e) {
  873. // continue;
  874. // }
  875. _date = newsinfo[i]["Time"] || U.UF.D.getYearMonthDay(newsinfo[i]["GroupMessageSendTime"]), "Array";
  876. _contentBox = $$("div", { "style": { "margin": " 0 10px"} }, _frag);
  877. _time = $$("div", { "className": "U_MD_F_COTO U_MD_F_CTO", "style": { "margin": " 0 10px", "text-align": "center", "color": "#aaaaaa", "font-size": "13px" }, "innerHTML": (_date) }, _contentBox);
  878. _contentel = $$("div", { "className": _stylearray[0], "title": newsinfo[i].GroupMessageSendUsername || newsinfo[i].MessageDescript || newsinfo[i].Name }, _contentBox);
  879. _content = $$("div", {}, _contentel);
  880. _contentoneel = $$("div", { "className": "U_MD_F_COLC" + _stylearray[1] }, _content);
  881. _contentimgel = $$("img",
  882. {
  883. "onerror": U.MD.C.imgError,
  884. "title": "点击查看",
  885. "onclick": function () {
  886. U.MD.U.V.ViewOtherUserInfo(newsinfo[i].GroupMessageSendUser || newsinfo[i].UserId);
  887. },
  888. "src": U.MD.C.getHeadImage((newsinfo[i].IMG || newsinfo[i].UserThumbnailImageHead)),
  889. "className": "U_MD_F_COLCI"
  890. },
  891. _contentel);
  892. if (_isFile) {
  893. _contentwordsel = $$("div", { "className": "U_MD_F_COLCO " + _stylearray[2], "innerHTML": newsinfo[i]["Content"] || newsinfo[i]["GroupMessageContent"] }, _contentoneel);
  894. } else {
  895. // var _filedata = JSON.parse(newsinfo[i].GroupMessageContent),
  896. var _filedata = newsinfo[i].Content,
  897. _filebox = $$('div', { style: { cssText: 'position:relative; padding: 10px; background-color: #fff; border:1px solid silver; overflow:hidden; cursor: pointer;' }, onclick: U.UF.C.closure(function (i, filedata) {
  898. var _type = '';
  899. switch (filedata.fileType) {
  900. case "uw": _type = 'word'; break;
  901. case "ue": _type = 'excel'; break;
  902. }
  903. U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", filedata.fileID]), function (r) {
  904. U.MD.D.I.openApplication(_type, r.value[0])
  905. });
  906. }, [i, _filedata])
  907. }, _contentoneel)
  908. $$('span', { className: 'U_MD_DK_RZOS U_MD_DK_Img U_MD_DK_RZOD' }, _filebox);
  909. $$('span', { style: { cssText: 'vertical-align: top; padding-left: 20px; padding-right: 40px;' }, innerText: _filedata.fileName + '.' + _filedata.fileType }, _filebox);
  910. $$('div', { style: { cssText: 'position: absolute; right: 10px; bottom: 10px;' }, innerText: '查看' }, _filebox)
  911. }
  912. if (issend) {
  913. _contentoneimgel = $$("div", { "style": { "width": "6px", "height": "10px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-984px -344px", "margin": "10px 4px 10px 0px"} }, _content);
  914. _content.style.float = "right";
  915. _contentel.insertBefore(_contentimgel, _content);
  916. _contentimgel.style.float = "right";
  917. _content.style.marginRight="8px";
  918. } else {
  919. _contentoneimgel = $$("div", { "style": { "width": "6px", "height": "10px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-1004px -344px", "margin": "10px 0px 10px 4px"} }, _content);
  920. _content.style.float = "left";
  921. _contentel.insertBefore(_contentimgel, _content);
  922. }
  923. // _contentnameel = $$("div", { "className": "U_MD_F_COT " + _stylearray[3] }, _contentel);
  924. // $$("div", { "className": "U_MD_F_COTOK", "innerHTML": newsinfo[i].GroupMessageSendUsername || newsinfo[i].Name }, _contentnameel);
  925. }
  926. //追加消息
  927. el.appendChild(_frag);
  928. //消息定位到底部
  929. _chatcontentel.scrollTop = _chatcontentel.scrollHeight - _chatcontentel.clientHeight;
  930. }
  931. /**
  932. * 查看聊天好友
  933. * @param {element} 打印的内容区域
  934. * @param {array} 打印消息的数组
  935. * @param {boolean} 判断消息是自己发送的还是获取的
  936. ---------- true 自己发送的
  937. ---------- flase 获取的带的
  938. */
  939. U.MD.F.W.addFile = function (friendinfo, el, thumbnail, fileurl, fileinfo) {
  940. //临时元素变量
  941. var _tempel,
  942. _temponeel,
  943. _temptwoel,
  944. _tempthreeel,
  945. _isgroup = friendinfo.UserId == null;
  946. //图片发送方式
  947. if (U.UF.UP.isImg(fileinfo.UserDirectoryExtendType)) {
  948. //创建一个元素
  949. _tempel = $$("div", {});
  950. //创建一个图片标签,添加图片
  951. $$("img", { "onerror": U.MD.C.imgError, "className": "U_MD_F_CI", "src": U.MD.C.getHeadImage(thumbnail), "title": U.MD.C.getHeadImage(fileurl) },
  952. _messageel).onclick = "U.UF.EV.stopBubble();U.MD.I.Img(US.userInfo, { 'Thm': '" + fileurl + "', 'Img': '" + fileurl + "'})"; //图片内容
  953. //发送图片
  954. U.MD.F.H.sendFriendOrGroupChatMessage(friendinfo, _messageel, el, _isgroup, true);
  955. }
  956. //文件发送方式
  957. else {
  958. _tempthreeel = $$("div");
  959. //发表文章样式
  960. _tempel = $$("div", { "className": "U_MD_F_F" }, _tempthreeel);
  961. _temponeel = $$("div", { "className": "U_MD_F_FS" }, _tempel);
  962. _temptwoel = $$("div", { "className": "U_MD_F_FSS" }, _temponeel);
  963. $$("div", { "innerHTML": fileinfo["UserDirectoryExtendType"] }, _temptwoel);
  964. _temptwoel = $$("div", { "className": "U_MD_F_FSX" }, _temponeel);
  965. $$("div", { "className": "U_MD_F_FSXN", "innerHTML": fileinfo["UserallDirectoryName"] }, _temptwoel);
  966. $$("div", { "className": "U_MD_F_FSXS", "innerHTML": "已成功发送" }, _temptwoel);
  967. _temponeel = $$("div", { "className": "U_MD_F_FX" }, _tempel);
  968. //如果是在1473上看到该信息,则可以直接打开网盘到指定的地方
  969. if (U.MD.D.IsUseStudio) {
  970. _tempel.onclick = "U.UF.EV.stopBubble();YDHJH('disk', ['" + fileinfo.UserId + "', '" + fileinfo.UserDirectoryID + "'])"
  971. _temptwoel = $$("div", { "innerHTML": "打开我的云盘", "title": "打开我的云盘" }, _temponeel);
  972. _temptwoel.onclick = "U.UF.EV.stopBubble();YDHJH('disk', ['" + fileinfo.UserId + "','" + fileinfo.UserDirectoryParentID + "'])";
  973. _temptwoel = $$("div", { "innerHTML": "打开", "title": "打开" }, _temponeel);
  974. _temptwoel.onclick = "U.UF.EV.stopBubble();YDHJH('disk', ['" + fileinfo.UserId + "','" + fileinfo.UserDirectoryID + "'])";
  975. }
  976. //如果是第三方调用我们的好友,则出现下载
  977. else {
  978. _temptwoel = $$("div", { "innerHTML": "下载", "title": "下载" }, _temponeel);
  979. _temptwoel.onclick = "U.UF.EV.stopBubble();U.UF.UP.download('" + fileinfo.UserallDirectoryName + "','" + fileinfo.UserFilesServerName + "')";
  980. }
  981. //显示出文件的样式
  982. U.MD.F.H.sendFriendOrGroupChatMessage(friendinfo, _tempthreeel, el, _isgroup, true);
  983. }
  984. }
  985. //#endregion
  986. //右侧好友定位
  987. U.MD.F.W.rightFormlocation = function () {
  988. $("#U_MD_F_H_R").addAttrArray({
  989. "style":
  990. {
  991. "top": (US.height - 530) / 2,
  992. "right": "0px"
  993. }
  994. }); //
  995. }
  996. /*
  997. 打印消息内容
  998. 参数一:type(string) 消息种类 例如 文件夹folder 图片 jpg 等
  999. 参数二:data(json) 文件数据
  1000. 参数三:parent(element) 生成元素
  1001. 参数五:send(boolean) 发送消息为true ,接受消息为false
  1002. 参数四:friend(json) 好友数据
  1003. */
  1004. U.MD.F.W.printMessageContent = function (type, data, parent, send, friend) {
  1005. var _content = $$('div', {});
  1006. var _folder = $$("div", { style: { "cssText": "padding:8px;background:#fff;border-radius:2px;position:relative"} }, _content);
  1007. //生成发送数据
  1008. var _message = {
  1009. fileName: data.UserallDirectoryName,
  1010. fileType: data.UserDirectoryExtendType,
  1011. fileSize: data.UserDirectorySize,
  1012. fileID: data.UserDirectoryID,
  1013. fileUrl: data.UserDirectoryUrl,
  1014. filetype: fileType = "folder" ? 1 : 0,
  1015. UserDirectoryExtendType: data.UserDirectoryExtendType,
  1016. UserDirectoryID: data.UserDirectoryID,
  1017. UserallDirectoryName: data.UserallDirectoryName
  1018. };
  1019. U.MD.F.W.printFileContent(_message, _folder);
  1020. //生成消息数据
  1021. var _newsinfo = [{
  1022. "UserId": US.userInfo.userid,
  1023. "Time": new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds(),
  1024. "Content": _content,
  1025. "IMG": US.userInfo.UserThumbnailImageHead,
  1026. "Name": US.userInfo.UserNickName
  1027. }];
  1028. //是否发送消息
  1029. if (send) {
  1030. //发送记录到数据库
  1031. U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SentMessageToFriend", US.userInfo.userid, friend.UserId, US.userInfo.UserNickName, JSON.stringify(_message), 6, false], function () { });
  1032. }
  1033. //打印在好友聊天
  1034. U.MD.F.W.printFriendChatMessage(parent, _newsinfo, true);
  1035. }
  1036. /*
  1037. 打印消息文件内容
  1038. 参数一:data(json) 文件数据
  1039. 参数二:parent(element) 生成元素
  1040. */
  1041. U.MD.F.W.printFileContent = function (data, parent) {
  1042. // parent.onclick = function () {
  1043. // U.UF.C.closure(function (filedata) {
  1044. // var _type;
  1045. // var _fileType = '';
  1046. // //获取文件
  1047. // switch (filedata.fileType) {
  1048. // case "uw": case "UW":
  1049. // _type = true;
  1050. // _fileType = 'word';
  1051. // break;
  1052. // case "ue":
  1053. // _type = true;
  1054. // _fileType = 'excel';
  1055. // break;
  1056. // case "folder": _fileType = "disk"; _type = true; break;
  1057. // case "jpg": case "png": case "mp4": case "txt": case "html": _type = false; break;
  1058. // }
  1059. // //获取文件
  1060. // if (_type) {
  1061. // U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", filedata.fileID]), function (r) {
  1062. // U.MD.D.I.openApplication(_fileType, r.value[0])
  1063. // });
  1064. // } else {
  1065. // U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", filedata.fileID]), function (r) {
  1066. // U.MD.DK.LE.openFileDirectory(r.value[0], top.US.userInfo.userid)
  1067. // });
  1068. // }
  1069. // }, [data])();
  1070. // }
  1071. /*$(parent).bind("click", function () {
  1072. U.UF.C.closure(function (filedata) {
  1073. var _type = '';
  1074. //获取文件
  1075. U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", filedata.fileID]), function (r) {
  1076. U.MD.DK.LE.openFileDirectory(r.value[0], top.US.userInfo.userid)
  1077. });
  1078. }, [data])
  1079. })//绑定点击事件*/
  1080. switch (data.fileType) {
  1081. case "folder": //打印文件夹类型的文件
  1082. var _content = $$("div", { style: { "cssText": "width:100%"} }, parent);
  1083. var _icon = $$("div", { "className": "U_MD_DK_RZOS U_MD_DK_Img U_MD_DK_RZOW", style: { "cssText": "float:none;display:inline-block;"} }, _content);
  1084. var _titile = $$("div", { "className": "", style: { "cssText": "display:inline-block;margin:0px 5px;width:155px;vertical-align:top;"} }, _content);
  1085. var _titileContent = $$("div", { innerHTML: data.fileName, style: { "cssText": "color:#000"} }, _titile);
  1086. var _titileSize = $$("div", { innerHTML: "(" + data.fileSize + "MB)", style: { "cssText": "color:#aaaaaa;font-size:10px;line-height:10px"} }, _titile);
  1087. var _open = $$("div", { onclick: function () { U.MD.DK.LE.openFileDirectory(data, US.userInfo.userid) }, innerHTML: "打开", style: { "cssText":"color:#429bfe;margin-top:-20px;text-align: right;cursor: pointer;"} }, parent);
  1088. break;
  1089. case "UW": case "txt": case "html": case "uw": //打印文本文件
  1090. var _content = $$("div", { style: { "cssText": "width:100%"} }, parent);
  1091. var _icon = $$("div", { "className": "U_MD_DK_RZOD U_MD_DK_RZOS", style: { "cssText": "float:none;display:inline-block;"} }, _content);
  1092. var _titile = $$("div", { "className": "", style: { "cssText": "display:inline-block;margin:0px 5px;width:155px;vertical-align:top;"} }, _content);
  1093. var _titileContent = $$("div", { innerHTML: data.fileName, style: { "cssText": "color:#000"} }, _titile);
  1094. var _titileSize = $$("div", { onclick: function(){U.MD.DK.LE.openFileDirectory(data, US.userInfo.userid)}, innerHTML: "查看", style: { "cssText": "color:#429bfe;margin-top:-20px;text-align: right;cursor: pointer;"} }, parent);
  1095. break;
  1096. case "jpg": case "png": //打印图片文件
  1097. _img = $$("img", { "onerror": U.MD.C.imgError, "src": "http://fs.1473.cn/" + data.fileUrl, "style": { "cssText": "width:100%;max-width:300px;min-width:30px;min-height:30px"} }, parent);
  1098. break;
  1099. case "mp4": //打印视频文件
  1100. if (parent.parentElement.className == "U_MD_F_LO") {
  1101. var _content = $$("div", { style: { "cssText": "width:100%"} }, parent);
  1102. var _icon = $$("div", { "className": "U_MD_DK_RZOS U_MD_DK_VIDEO", style: { "cssText": "float:none;display:inline-block;width:40px;height:40px;background-image:url('/img/YS2017.png');background-repeat:no-repeat;background-position:-1081px -527px;"} }, _content);
  1103. var _titile = $$("div", { "className": "", style: { "cssText": "display:inline-block;margin:0px 5px;width:155px;vertical-align:top;"} }, _content);
  1104. var _titileContent = $$("div", { innerHTML: data.fileName, style: { "cssText": "color:#000"} }, _titile);
  1105. var _titileSize = $$("div", { onclick: function () { U.MD.DK.LE.openFileDirectory(data, US.userInfo.userid) }, innerHTML: "查看", style: { "cssText": "color:#429bfe;margin-top:-20px;float:right"} }, parent);
  1106. } else {
  1107. var _video = $$("img", { "onerror": U.MD.C.imgError, "src": "http://fs.1473.cn/" + data.fileUrl, "style": { "cssText": "width:100%;max-width:300px;"} }, parent),
  1108. _videoText = $$("div", {}, parent),
  1109. _videoStart = $$("div", { "style": { "width": "97px", "height": "96px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-1015px -362px", "position": "absolute", "top": "25%", "left": "35%"} }, _videoText),
  1110. _videoName = $$("div", { "innerHTML": data.fileName, "style": { "cssText": "color:white;font-size:16px;position: absolute;top: 137px;margin-left: 10px;"} }, _videoText),
  1111. _videoSize = $$("span", { "innerHTML": data.fileSize, "style": { "cssText": "color:#d4d3d1;font-size:14px;position: absolute;top: 155px;margin-left: 10px;"} }, _videoText),
  1112. _videoState = $$("span", { "innerHTML": "已发送", "style": { "cssText": "color:#d4d3d1;font-size:14px;position: absolute;top: 155px;right:20px"} }, _videoText);
  1113. }
  1114. break;
  1115. default:
  1116. var _content = $$("div", { style: { "cssText": "width:100%"} }, parent);
  1117. var _icon = $$("div", { "className": "U_MD_DK_RZOS U_MD_DK_Img downel_content_a_r", style: { "cssText": "float:none;display:inline-block;"} }, _content);
  1118. var _iconContent = $$("div", { "className": "U_MD_DK_RZOSZ", 'innerHTML': data.fileType }, _icon);
  1119. var _titile = $$("div", { "className": "", style: { "cssText": "display:inline-block;margin:0px 5px;width:155px;vertical-align:top;"} }, _content);
  1120. var _titileContent = $$("div", { innerHTML: data.fileName, style: { "cssText": "color:#000"} }, _titile);
  1121. var _titileSize = $$("div", { innerHTML: "(" + data.fileSize + "MB)", style: { "cssText": "color:#aaaaaa;font-size:10px;line-height:10px"} }, _titile);
  1122. var _open = $$("div", { innerHTML: "打开", style: { "cssText": "color:#429bfe;margin-top:-20px;text-align: right;cursor: pointer;"} }, parent);
  1123. _open.onclick = function () {
  1124. U.MD.DK.LE.openFileDirectory(data, US.userInfo.userid);
  1125. }
  1126. break;
  1127. };
  1128. }