U.F.W.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. 好友初始化区域 此文件为好友窗体使用初始化窗体
  3. */
  4. Namespace.register("U.F.W"); //好友和群窗口区域命名空间
  5. //#region 好友聊天
  6. /**
  7. * 弹出好友窗体处理
  8. *
  9. * @param {object} 群信息
  10. */
  11. U.F.W.ViewFriend = U.F.W.SLHCK = function (friendinfo) {
  12. var _childs, //所有的好友元素
  13. _friendel //好友的信息元素
  14. ;
  15. //如果有传入好友的信息,则查看指定的好友的信息,否则弹出默认的好友窗体
  16. if (friendinfo) {
  17. //如果用户是和自己聊天,那么直接提示不允许,否则弹出好友聊天框
  18. if (friendinfo.UserId == US.userInfo.userid) {
  19. U.Alert("无法与本人聊天!");
  20. }
  21. else {
  22. //获取制定好友的点击元素
  23. _friendel = $("#UD_SYHRCO").find("[tid=" + friendinfo.UserId + "]")[0];
  24. //如果查看的好友在好友列表里
  25. if (_friendel) {
  26. _friendel.onclick();
  27. }
  28. //弹出好有窗体
  29. else {
  30. U.F.W.PopupFriendsForm(friendinfo);
  31. }
  32. }
  33. }
  34. //弹出默认的好友窗体
  35. else {
  36. _childs = $("#UD_SYHRCO").Child(); //右侧栏
  37. friendinfo = (US.Friend[4][0] || US.Friend[1][0]); //最近联系人、 我的好友列表
  38. //如果有显示的好友,则弹出第一个好友聊天
  39. if (_childs.length) {
  40. _childs[0].onclick();
  41. }
  42. //查看好友
  43. else {
  44. //这里判断如果弹出的是群聊天框,则选择群信息,需要修改
  45. if (friendinfo && friendinfo.tf) {
  46. friendinfo = _$(US.Friend[2]).Select({ "GroupManageID": friendinfo.UserId })[0];
  47. }
  48. //弹出好友信息
  49. U.F.W.PopupFriendsForm(friendinfo);
  50. //如果用户没有好友和群,那么则直接弹出推荐好友
  51. if (!friendinfo || (!friendinfo.UserId && !friendinfo.GroupManageID)) {
  52. U.F.W.RecommendFriend();
  53. }
  54. }
  55. }
  56. }
  57. //#region 空好友提示
  58. /**
  59. * 空好友的提示
  60. *
  61. */
  62. U.F.W.RecommendFriend = function () {
  63. U.F.W.PrintRecommendFriend(US.userInfo.TJF.slice(0, 8), $("#UD_SYHZR")[0], 1); //推荐好友提示
  64. U.F.W.FriendDisplayAndNone([{ "display": "block" }, { "display": "none"}], true); //弹出好友窗体,隐藏右边好友栏
  65. }
  66. /**
  67. * 空用户的提示
  68. *
  69. */
  70. U.F.W.PrintRecommendFriend = function (friendinfo, el, page) {
  71. //变量定义
  72. var _tempel, //临时元素变量
  73. _temponeel, //临时元素变量
  74. _temptwoel, //临时元素变量
  75. _tempthreeel, //临时元素变量
  76. _tempfourel, //临时元素变量
  77. _tempfiveel //临时元素变量
  78. ;
  79. //清空内容
  80. el.innerText = "";
  81. //创建显示
  82. _tempel = $$("div", { "className": "UD_SYHZRO", "onmousedown": U.M.StopBubble });
  83. _temponeel = $$("div", { "className": "UD_SYHZROS" }, _tempel);
  84. $$("div", { "className": "UD_SYHZROSS", "innerHTML": "这里暂时没有任何内容哦" }, _temponeel);
  85. $$("div", { "className": "UD_SYHZROSZ", "innerHTML": "Nothing!!" }, _temponeel);
  86. _temptwoel = $$("div", { "className": "UD_SYHZROSX" }, _temponeel);
  87. $$("div", { "className": "UD_SYHZROSXL", "innerHTML": "可尝试点击左边的头像,或追随一下的用户!" }, _temptwoel);
  88. $$("div", { "className": "UD_SYHZROSXR UD_SYI" }, _temptwoel);
  89. _temponeel = $$("div", { "className": "UD_SYHZROX" }, _tempel);
  90. _temptwoel = $$("div", { "className": "UD_SYHZROXT" }, _temponeel);
  91. $$("div", { "className": "UD_SYSXLTTO UD_SYSXROHTO", "innerHTML": "推荐追随" }, _temptwoel);
  92. $$("div", { "className": "UD_SYSXLTTI UD_SYI", "onclick": [[U.F.W.RecommendFriend, [el, page]]] }, _temptwoel);
  93. _temptwoel = $$("div", { "className": "UD_SYHZROXX" }, _temponeel);
  94. //推荐好友循环打印区域
  95. for (i = 0; i < friendinfo.length; i++) {
  96. _tempthreeel = $$("div", { "className": "UD_SYHZROXXO", "style": { "marginLeft": "65px"} }, _temptwoel);
  97. _tempfourel = $$("div", { "className": "UD_SYHZROXXOS" }, _tempthreeel);
  98. _tempfiveel = $$("div", { "className": "UD_SYHZROXXOSL" }, _tempfourel);
  99. $$("img", { "onerror": U.M.ImgError, "title": "点击查看", "onclick": [[U.M.StopBubble], [U.U.I.ViewOtherUserInfo, [friendinfo[i].UserID]]],
  100. "src": U.M.GetImgU(friendinfo[i].UserThumbnailImageHead), "alt": friendinfo[i].UserName
  101. }, _tempfiveel);
  102. $$("div", { "className": "UD_SYHZROXXOSN UTDF", "innerHTML": friendinfo[i].UserName }, _tempfourel);
  103. $$("div", { "className": "UD_SYHZROXXOSR", "title": "点击追随该用户", "innerHTML": "追随", "onclick": [[U.F.M.AddFriend, [friendinfo[i]]]] }, _tempfourel);
  104. _tempfourel = $$("div", { "className": "UD_SYHZROXXOX UD_SYSXZLLZOOX" }, _tempthreeel);
  105. $$("div", { "className": "UD_SYSXRATOCS", "innerHTML": "▲" }, _tempfourel);
  106. $$("div", { "className": "UD_SYSXRATOCX", "innerHTML": (friendinfo[i].UserIndividualitysignature ? friendinfo[i].UserIndividualitysignature.substring(0, 15) : "添加我为好友吧,分享我们的信息,让我们距离更近一步").trim() }, _tempfourel);
  107. }
  108. //添加内容
  109. el.appendChild(_tempel);
  110. }
  111. //好友推荐变化
  112. U.F.W.RecommendFriend = function (el, page) {
  113. var _userinfo = US.userInfo, //登录用户资料
  114. _start = page * 4, //分页的开始
  115. _end = (page + 1) * 4, //分页的结束
  116. _recommendfriend = _userinfo.TJF.slice(_start, _end) //分页获取推荐的用户
  117. ;
  118. //获取的用户存在则打印
  119. if (_recommendfriend.length) {
  120. U.F.W.PrintRecommendFriend(_recommendfriend, el, page + 1);
  121. }
  122. //否则去数据库取数
  123. else {
  124. U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "RecommendFriends", _userinfo.UserId || US.NU, _userinfo.length, _userinfo.length + 4]), U.D.SY.AsynSYTJ, [el, el, page];
  125. }
  126. }
  127. //获取推荐好友
  128. U.F.W.AsynRecommendFriend = function (r) {
  129. var _userinfo = US.userInfo, //登录用户资料
  130. _context = r.context, //回调的参数
  131. _el = _context[1], //输出的内容区域
  132. _page = _context[2] //输出的号码
  133. ;
  134. r = r.value; //获取推荐用户的返回值
  135. _userinfo = _userinfo.concat(r); //获取的推荐用户存储到用户推荐用户信息里
  136. U.F.W.PrintRecommendFriend(r, _el, _page + 1); //打印推荐好友
  137. }
  138. //#endregion
  139. //#region
  140. /**
  141. * 好友聊天器里查看好友聊天
  142. *
  143. * @param {object} 群信息
  144. */
  145. U.F.W.PopupFriendsForm = function (friendinfo, el) {
  146. //登录的用户才能弹出窗体
  147. if (!U.U.L.isLogin(3)) {
  148. var _friendform = $("#UD_SYHZA")[0];
  149. //判断窗体是否创建如果创建直接显示,如果没有则创建
  150. if (!_friendform) {
  151. //创建窗体弹出窗体
  152. U.UI.Form({
  153. "min": false,
  154. "resize": U.F.W.ReSize, //resize事件处理
  155. "style": { display: "block", height: "80%" },
  156. "id": "UD_SYHZA",
  157. "content": $("#UD_SYHZ")[0],
  158. "title": "<div class='UD_SYF_STI'></div>",
  159. "hst": { "style": { "padding": "0"} },
  160. "SO": false, //不允许拉伸
  161. "close": { //关闭点击事件处理
  162. "onclick": U.M.apply(null, [[U.F.W.FriendDisplayAndNone, [[{ "display": "none" }, { "display": "block"}], { "left": "auto", "right": "0px"}]]])
  163. }
  164. }).be;
  165. }
  166. //隐藏好友右边的显示,显示窗体
  167. U.F.W.FriendDisplayAndNone[{ "display": "block" }, { "display": "none"}];
  168. U.F.W.OpenFriendChat(friendinfo); //打开指定的好友聊天显示
  169. U.F.W.ReSize(); //好友聊天区域大小初始化
  170. }
  171. }
  172. /**
  173. * 初始化好友聊天区域
  174. *
  175. * @param {object} 群信息
  176. */
  177. U.F.W.OpenFriendChat = function (friendinfo) {
  178. var _friendfromel = $("#UD_SYHZR")[0], //整个好友窗体元素
  179. _friendchatfrom = $("#UD_SYF")[0], //好友聊天区域元素
  180. _userid = friendinfo.GroupManageID || friendinfo.UserId, //打开群或者好友的窗体
  181. _chatform = U.F.W.IsCreateForm(_userid), //判断窗体是否已经打开创建
  182. _isgroup = friendinfo.GroupManageID != null
  183. ;
  184. _friendchatfrom.style.display = "block"; //默认是隐藏,这些显示
  185. _friendfromel.appendChild(_friendchatfrom); //追加聊天区域
  186. //如果好友聊天框不存在,则创建好友聊天框
  187. if (!_chatform) {
  188. _chatform = U.F.W.CreateFriendChat(friendinfo);
  189. }
  190. //选择到指定的窗体
  191. U.F.W.SwitchFriendsChat(_chatform, friendinfo);
  192. //好友聊天查看
  193. U.F.FM.GetFriendOrGroupNews(_userid, U.M.apply(this, [[U.F.FM.AsynReceiveMessages, [_isgroup, _chatform[1]]]]), _isgroup);
  194. }
  195. //大小变化处理
  196. U.F.W.ReSize = function () {
  197. U.F.W.LeftSize(); //左边的处理
  198. U.F.W.ChatBoxSize($("#UD_SYF")[0], $("#UD_SYF")[0].childs[0].element[1]); //右边聊天框处理
  199. }
  200. /**
  201. * 好友聊天左边聊天框显示,主要是好友显示的区域的大小加上上面的导航等于整个左边的高
  202. *
  203. */
  204. U.F.W.LeftSize = function () {
  205. var _leftcontent = $("#UD_SYHZLT").Parent(), //获取左边好友区域
  206. _childs = $(_leftcontent).Child(), //获取下面的所有的孩子节点
  207. _height = _leftcontent.offsetHeight; //得到高度
  208. //设置下面的高度等于整个高度-导航的高度
  209. $("#UD_SYHZLZ")[0].style.height = _height - _childs[0].offsetHeight - _childs[1].offsetHeight + "px";
  210. }
  211. //调整好友聊天框
  212. U.F.W.ChatBoxSize = function (el, chatel) {
  213. var i, //用于循环
  214. _childs, //0 聊天区域 1聊天记录区域
  215. _rightchilds = $(el).Child(), //获取整个右边好友聊天区域的子元素
  216. _chatchilds = $(chatel.parentNode).Child(), //获取聊天区域的子元素
  217. _height = el.offsetHeight, //右边的高
  218. _width = el.offsetWidth; //右边的长
  219. //循环设置
  220. for (i = 0; i < _chatchilds.length; i++) {
  221. //聊天记录和聊天框的大小设置
  222. _childs = $(_chatchilds[i]).Child();
  223. _childs[0].style.width = _width - _childs[1].offsetWidth + "px";
  224. //聊天框的大小设置
  225. $(".UD_SYFCA", _chatchilds[i]).css("height", _height - 350 + "px");
  226. }
  227. }
  228. /**
  229. * 设置好友窗体打开和关闭的状态
  230. *
  231. * @param {array} 显示隐藏的集合
  232. */
  233. U.F.W.FriendDisplayAndNone = function (style) {
  234. var _friendform = $("#UD_SYHZA"), //好友窗体
  235. _friendright = $("#UD_SYHR"); //好友右侧
  236. _friendform.addAttrArray({ "style": style[0] }); //给窗体设置参入的css值
  237. _friendright.addAttrArray({ "style": style[1] }); //给窗体设置参入的css值
  238. }
  239. //#endregion
  240. //判断是否需要创建
  241. /**
  242. * 根据friendid判断好友窗体是否创建
  243. *
  244. * @param {object} 群信息
  245. */
  246. U.F.W.IsCreateForm = function (friendid) {
  247. var i, //用于循环处理
  248. _friendchatform = $("#UD_SYF")[0]; //好友聊天框
  249. if (_friendchatform.childs) { //判断是否打开了聊天
  250. for (i = 0; i < _friendchatform.childs.length; i++) { //循环所有打开的聊天找到已经和friendid对应打开的好友聊天
  251. if (_friendchatform.childs[i].formid == friendid) { //如果找到匹配的好友聊天框或者群聊天框,则直接返回
  252. return _friendchatform.childs[i].element;
  253. }
  254. }
  255. }
  256. }
  257. /**
  258. * 生成统一的好友窗体区域
  259. *
  260. * @param {object} 好友或群信息
  261. */
  262. U.F.W.CreateFriendChat = function (friendandgroupinfo) {
  263. //变量定义
  264. var _headel,
  265. _headimageel,
  266. _chatel,
  267. _chatleftel,
  268. _chatheadel,
  269. _chatheadimageel,
  270. _chatheadcontentel,
  271. _chatheadpromptel,
  272. _chatcontentel,
  273. _chatcontentnewsel,
  274. _chatnewsel,
  275. _chatnewsoneel,
  276. _chatnewstwoel,
  277. _chateditel,
  278. _chatbuttonel,
  279. _chatbuttonsendel,
  280. _chatrecordel,
  281. //群id获取好友id,作为窗体的唯一识别id
  282. _userid = friendandgroupinfo.GroupManageID ||
  283. friendandgroupinfo.UserId,
  284. //显示在聊天框的名字,群名、好友描述、好友名字
  285. _name = friendandgroupinfo.GroupManageName ||
  286. friendandgroupinfo.FriendsDescript ||
  287. friendandgroupinfo.UserNickName,
  288. //群描述、好友签名
  289. descript = friendandgroupinfo.GroupManageDescript ||
  290. friendandgroupinfo.UserIndividualitysignature ||
  291. "暂时没有填写介绍..",
  292. //聊天框元素
  293. _chatformel = $("#UD_SYF")[0],
  294. //聊天区域的还在元素
  295. _chatformchilds = $(_chatformel).Child(),
  296. //头部切换导航区域的元素
  297. _navichilds = $(_chatformchilds[0]).Child();
  298. //头部标签
  299. _headel = $$("div", { "className": "UD_SYFTO", "onmousedown": U.M.StopBubble }, _navichilds[0], _navichilds[0].firstChild);
  300. _headimageel = $$("div", { "className": "UD_SYFTOI" }, _headel);
  301. //好友显示头像
  302. if (friendandgroupinfo.UserId) {
  303. $$("img", { "onerror": U.M.ImgError, "title": "点击查看", "src": U.M.GetImgU(friendandgroupinfo.UserThumbnailImageHead),
  304. "alt": friendandgroupinfo.UserNickName
  305. }, _headimageel);
  306. }
  307. //群显示头像
  308. else {
  309. U.F.PrintGroupHeadImage(friendandgroupinfo, _headimageel, 4, [25, 25]);
  310. }
  311. $$("div", { "className": "UD_SYFTON UTDF", "innerHTML": _name }, _headel);
  312. $$("div", { "className": "UD_SYFTOC UD_SYI", "onclick": [[U.F.W.DelteFriendChat, [_userid, _chatformel, friendandgroupinfo]]] }, _headel);
  313. //聊天区
  314. _chatel = $$("div", { "className": "UD_SYFNA" });
  315. _chatformchilds[1].insertBefore(_chatel, _chatformchilds[1].firstChild);
  316. //左侧
  317. _chatleftel = $$("div", { "className": "UD_SYFN" }, _chatel);
  318. //头部信息
  319. _chatheadel = $$("div", { "className": "UD_SYFH" }, _chatleftel);
  320. _chatheadimageel = $$("div", { "className": "UD_SYFHH" }, _chatheadel);
  321. if (friendandgroupinfo.GroupManageID) {
  322. U.F.PrintGroupHeadImage(friendandgroupinfo, _chatheadimageel); $(_chatheadimageel).addAttrArray({ onclick: [[U.F.J.GroupInfoForm, [friendandgroupinfo]]], title: friendandgroupinfo["GroupManageName"] });
  323. }
  324. else {
  325. $$("img", { "onerror": U.M.ImgError, "title": "点击查看", "onclick": [[U.M.StopBubble], U.D.IsUseStudio ? [U.U.I.ViewOtherUserInfo, [_userid]] : []], "src": U.M.GetImgU(friendandgroupinfo.UserThumbnailImageHead), "alt": friendandgroupinfo.UserNickName }, _chatheadimageel);
  326. }
  327. _chatheadcontentel = $$("div", { "className": "UD_SYFHT UTDF" }, _chatheadel);
  328. $$("div", { "className": "UD_SYFHTN", "innerHTML": _name }, _chatheadcontentel);
  329. $$("div", { "className": "UD_SYFHTC", "innerHTML": (friendandgroupinfo.GroupManageDescript || friendandgroupinfo.UserIndividualitysignature || "暂时没有填写介绍..") }, _chatheadcontentel);
  330. _chatheadpromptel = $$("div", { "className": "UD_SYFG" }, _chatleftel);
  331. $$("div", { "className": "UD_SYFGI UD_SYI" }, _chatheadpromptel);
  332. $$("div", { "className": "UD_SYFGC", "innerHTML": "交谈中请勿轻信汇款、中奖信息、陌生电话..." }, _chatheadpromptel);
  333. //内容发布区
  334. _chatcontentel = $$("div", { "className": "UD_SYFCA" }, _chatleftel);
  335. _chatcontentnewsel = $$("div", { "className": "UD_SYFC" }, _chatcontentel);
  336. //发布内容区域
  337. _chatnewsel = $$("div", { "className": "UD_SYFD", "style": { "position": "relative"} }, _chatleftel);
  338. _chatnewsoneel = $$("div", { "className": "UD_SYFDA" }, _chatnewsel);
  339. _chatnewstwoel = $$("div", { "className": "UD_SYFDT" }, _chatnewsoneel);
  340. _chateditel = $$("div", { "className": "UD_SYFDC", "contentEditable": "true" }, _chatnewsoneel);
  341. $$("div", { "className": "UD_SYFDJ UD_SYI" }, _chatnewsoneel);
  342. //按钮区域
  343. _chatbuttonel = $$("div", { "className": "UD_SYFX" }, _chatleftel);
  344. _chatbuttonsendel = $$("div", { "className": "UD_SYFXE", "innerHTML": "发送(Enter)", "style": { "marginRight": "15px" },
  345. "onclick": [[U.F.FM.SendFriendOrGroupChatMessage, [friendandgroupinfo, _chateditel, _chatcontentnewsel, (friendandgroupinfo.UserId == null)]]]
  346. }, _chatbuttonel);
  347. $$("div", { "className": "UD_SYFXC", "innerHTML": "关闭(n)",
  348. "onclick": [[U.F.W.FriendDisplayAndNone, [[{ "display": "none" }, { "display": "block"}], { "left": "auto", "right": "0px"}]]]
  349. }, _chatbuttonel);
  350. //右侧聊天记录
  351. _chatrecordel = $$("div", { "className": "UD_SYFL" }, _chatel);
  352. $$("div", { "className": "UD_SYFLA" }, _chatrecordel);
  353. $$("div", { "className": "UD_SYFLB" }, _chatrecordel);
  354. //事件赋值
  355. $$("div", { "classNmae": "UD_SYFDTF UD_SYI", "id": "UD_SFB", "title": "发送表情", "style": { "margin": "0", "position": "relative" },
  356. "onmousedown": [[U.UI.face, [_chatnewsel, U.F.W.PrintEmoticon]]], "onclick": U.M.StopBubble
  357. }, _chatnewstwoel);
  358. _chatheadimageel = $$("div", { "className": "UD_SYFDTZ UD_SYI", "title": "添加文件",
  359. "onclick": [[U.Dk.HP.FileSwitch, [US.NU, null, { "CB": U.M.apply(null, [[U.F.W.AddFile, [friendandgroupinfo, _chatcontentnewsel]]])}]]]
  360. }, _chatnewstwoel);
  361. if (friendandgroupinfo.GroupManageID) {
  362. $$("div", { "className": "UD_SYFDTS UD_SYI", "title": "网盘提交", "onclick": [[U.D.DT.YYDK, ["Disk", { "userid": US.userInfo.userid, "directoryid": friendandgroupinfo.GroupManageID}]]] }, _chatnewstwoel);
  363. }
  364. $$("div", { "className": "UD_SYFDTJ UD_SYI", "title": "聊天记录", "onclick": [[U.F.FM.ViewFriendsChatRecords, [_chatrecordel, friendandgroupinfo, 1, (friendandgroupinfo.UserId == null)]]] }, _chatnewstwoel);
  365. _chateditel.onkeydown = U.M.apply(_chateditel, [[U.M.returnkeylogin, [[{ "obj": _chatbuttonsendel, "event": 'onclick'}]]]]);
  366. _headel.onclick = U.M.apply(this, [[U.F.W.SwitchFriendsChat, [[_headel, _chatel, friendandgroupinfo], friendandgroupinfo]]]); //切换事件
  367. //设置光标处理
  368. U.D.E.GetSelectionRange(window, _chateditel, { "TF": "Friend" });
  369. //创建的好友窗体记录
  370. if (_chatformel.childs == null) {
  371. _chatformel.childs = [];
  372. }
  373. _chatformel.childs.unshift({ "formid": _userid, "element": [_headel, _chatel], "info": friendandgroupinfo }); //添加记录
  374. return _chatformel.childs[0].element;
  375. }
  376. //
  377. /**
  378. * 好友聊天切换
  379. *
  380. * @param {string} 好友的id
  381. * @param {element} 窗体元素
  382. */
  383. U.F.W.SwitchFriendsChat = function (elements, friendorgroupinfo) {
  384. var i,
  385. _friendchatel,
  386. _chatel = $(elements[1]).Parent(2),
  387. _topbottom = $($(_chatel).Child()[0]).Child()[2], //右上角功能按钮
  388. _chatchilds = _chatel.childs;
  389. //显示当前elements的聊天窗体,其他的隐藏
  390. for (i = 0; i < _chatchilds.length; i++) {
  391. _friendchatel = _chatchilds[i].element;
  392. if (_friendchatel == elements) { //需要显示的聊天框
  393. $(elements[0]).addClass("UD_SYFTOT");
  394. $(elements[1]).css("display", "block");
  395. //可编辑区域聚焦
  396. $(".UD_SYFDC", elements[1])[0].focus();
  397. }
  398. else { //需要隐藏的聊天框
  399. $(_friendchatel[0]).removeClass("UD_SYFTOT");
  400. $(_friendchatel[1]).css("display", "none");
  401. }
  402. }
  403. //右上角功能点击处理处理
  404. _topbottom.onclick = U.M.apply(_topbottom, [[U.F.R.PopupRightCornerMenu, [friendorgroupinfo, _topbottom]]]);
  405. _topbottom.title = friendorgroupinfo.UserId ? "个人信息" : "创建群";
  406. //好友聊天框
  407. U.F.W.ChatBoxSize(_chatel, elements[1]);
  408. }
  409. /**
  410. * 删除单个好友聊天
  411. *
  412. * @param {string} 好友的id
  413. * @param {element} 窗体元素
  414. */
  415. U.F.W.DelteFriendChat = function (friendid, el) {
  416. var i, j, //循环处理
  417. _chatinfo, //好友聊天的好友或者群信息
  418. _elements, //好友聊天信息的框
  419. _childs = el.childs; //获取所有的聊天框
  420. //剩下最后一个直接关闭聊天框
  421. if (_childs.length == 1) {
  422. U.F.W.FriendDisplayAndNone([{ "display": "none" }, { "display": "block"}], { "left": "auto", "right": "0px" }); //移除
  423. }
  424. else {
  425. //循环找到friendid对应的弹框
  426. for (i = 0; i < _childs.length; i++) {
  427. //判断窗体的id和好友的id是否一致
  428. if (_childs[i].formid == friendid) {
  429. _elements = _childs[i]["element"]; //获取根据friendid创建的所有的元素
  430. for (j = 0; j < _elements.length; j++) { //循环所有的元素,然后全部删除
  431. $(_elements[i]).remove(); //移除元素处理
  432. }
  433. _childs.splice(i, 1); //在所有孩子元素中删除该元素
  434. //判断当前窗体是否在正在进行的聊天窗体,如果是的话,删除了这个窗体后要把下面的窗体显示出来
  435. if (_elements[0].className.indexOf("UD_SYFTOT") > -1) {
  436. //获取下一个要显示的聊天框
  437. _chatinfo = _childs[i] || _childs[i - 1]; //下一个或者是上一个
  438. //显示该聊天框
  439. U.F.W.SwitchFriendsChat(_chatinfo["element"], _chatinfo["info"]);
  440. }
  441. break;
  442. }
  443. }
  444. }
  445. }
  446. //生成发表聊天消息和获取聊天消息区域
  447. /**
  448. * 查看聊天好友
  449. * @param {element} 打印的内容区域
  450. * @param {array} 打印消息的数组
  451. * @param {boolean} 判断消息是自己发送的还是获取的
  452. ---------- true 自己发送的
  453. ---------- flase 获取的带的
  454. */
  455. U.F.W.PrintFriendChatMessage = function (el, newsinfo, issend) {
  456. var i,
  457. _date, //打印的时间
  458. _chatcontentel,
  459. _chatcontentoneel,
  460. _chatcontentwordsel,
  461. _chatel = el.parentNode, //聊天框
  462. _frag = $$("frag"),
  463. _stylearray = issend ? ["UD_SYFCT", "UD_SYFCTL", " UD_SYFCTTO", " UD_SYFCTO"] : ["UD_SYFCO", "UD_SYFCOL", " UD_SYFCTT", ""]; //打印的样式
  464. //打印的消息
  465. for (i = 0; i < newsinfo.length; i++) {
  466. _date = U.MT.getYearMonthDay(newsinfo[i]["Time"] || newsinfo[i]["MessageSendTime"], "Array");
  467. _chatcontentel = $$("div", { "className": _stylearray[0] }, _frag);
  468. _chatcontentoneel = $$("div", { "className": _stylearray[1] }, _chatcontentel);
  469. //自己发的消息样式打印
  470. if (issend) {
  471. $$("div", { "className": "UD_SYFCOLC UD_SYFCTLC", "innerHTML": newsinfo[i]["Content"] }, _chatcontentoneel);
  472. $$("div", { "className": "UD_SYFCOLT UD_SYFCTLT UD_SYI" }, _chatcontentoneel);
  473. }
  474. //其他人发的消息打印
  475. else {
  476. $$("div", { "className": "UD_SYFCOLT UD_SYI" }, _chatcontentoneel);
  477. $$("div", { "className": "UD_SYFCOLC", "innerHTML": newsinfo[i]["MessageContent"] }, _chatcontentoneel);
  478. }
  479. _chatcontentwordsel = $$("div", { "className": "UD_SYFCOT" + _stylearray[2] }, _chatcontentel);
  480. $$("div", { "className": "UD_SYFCOTO" + _stylearray[3], "innerHTML": (_date[3] + ":" + _date[4] + ":" + _date[5]) }, _chatcontentwordsel);
  481. }
  482. el.appendChild(_frag);
  483. //消息定位到底部
  484. _chatel.scrollTop = _chatel.scrollHeight - _chatel.offsetHeight;
  485. }
  486. /**
  487. * 查看聊天 好友或者群
  488. * @param {element} 打印的内容区域
  489. * @param {array} 打印消息的数组
  490. * @param {boolean} 判断消息是自己发送的还是获取的
  491. ---------- true 自己发送的
  492. ---------- flase 获取的带的
  493. */
  494. U.F.W.PrintGroupChatMessage = function (el, newsinfo, issend) {
  495. var i,
  496. _date,
  497. _contentel,
  498. _contentoneel,
  499. _contentwordsel,
  500. _contentimgel,
  501. _contentnameel,
  502. _stylearray,
  503. _chatcontentel = el.parentNode,
  504. _frag = $$("frag");
  505. //发送消息是自己和他人区别的样式
  506. if (issend) {
  507. _stylearray = ["UD_SYFCT", " UD_SYFCTLC UD_SYGCTLC", " UD_SYFCOLCOO", " UD_SYFCTTO", " "];
  508. }
  509. else {
  510. _stylearray = ["UD_SYFCO", "", " UD_SYFCOLCOT", " UD_SYFCTT"];
  511. }
  512. //循环打印聊天消息
  513. for (i = 0; i < newsinfo.length; i++) {
  514. _date = U.MT.getYearMonthDay(newsinfo[i]["Time"] || newsinfo[i]["GroupMessageSendTime"], "Array");
  515. _contentel = $$("div", { "className": _stylearray[0], "title": newsinfo[i].GroupMessageSendUsername || newsinfo[i].Name }, _frag);
  516. _contentoneel = $$("div", { "className": "UD_SYFCOLC" + _stylearray[1] }, _contentel);
  517. _contentimgel = $$("img", { "onerror": U.M.ImgError, "title": "点击查看", "onclick": [[U.U.I.ViewOtherUserInfo, [newsinfo[i].GroupMessageSendUser || newsinfo[i].UserId]]], "src": U.M.GetImgU((newsinfo[i].IMG || newsinfo[i].UserThumbnailImageHead)), "className": "UD_SYFCOLCI" }, _contentoneel);
  518. _contentwordsel = $$("div", { "className": "UD_SYFCOLCO " + _stylearray[2], "innerHTML": newsinfo[i]["Content"] || newsinfo[i]["GroupMessageContent"] }, _contentoneel);
  519. (issend) && (_contentoneel.insertBefore(_contentwordsel, _contentimgel));
  520. _contentnameel = $$("div", { "className": "UD_SYFCOT " + _stylearray[3] }, _contentel);
  521. $$("div", { "className": "UD_SYFCOTOK", "innerHTML": newsinfo[i].GroupMessageSendUsername || newsinfo[i].Name }, _contentnameel);
  522. $$("div", { "className": "UD_SYFCOTO UD_SYFCTO", "style": { "bottom": "0px" }, "innerHTML": (_date[3] + ":" + _date[4] + ":" + _date[5]) }, _contentnameel);
  523. }
  524. //追加消息
  525. el.appendChild(_frag);
  526. //消息定位到底部
  527. _chatcontentel.scrollTop = _chatcontentel.scrollHeight - _chatcontentel.clientHeight;
  528. }
  529. /**
  530. * 查看聊天好友
  531. * @param {element} 打印的内容区域
  532. * @param {array} 打印消息的数组
  533. * @param {boolean} 判断消息是自己发送的还是获取的
  534. ---------- true 自己发送的
  535. ---------- flase 获取的带的
  536. */
  537. U.F.W.AddFile = function (friendinfo, el, thumbnail, fileurl, fileinfo) {
  538. //临时元素变量
  539. var _tempel,
  540. _temponeel,
  541. _temptwoel,
  542. _tempthreeel,
  543. _isgroup = friendinfo.UserId == null;
  544. //图片发送方式
  545. if (U.UP.IsImg(fileinfo.UserDirectoryExtendType)) {
  546. //创建一个元素
  547. _tempel = $$("div", {});
  548. //创建一个图片标签,添加图片
  549. $$("img", { "className": "UD_SYFCI", "src": U.M.GetImgU(thumbnail),
  550. "title": U.M.GetImgU(fileurl)
  551. }, _messageel).onclick = "U.M.StopBubble();U.D.Img.Img(US.userInfo, { 'Thm': '" + fileurl + "', 'Img': '" + fileurl + "'})"; //图片内容
  552. //发送图片
  553. U.F.FM.SendFriendOrGroupChatMessage(friendinfo, _messageel, el, _isgroup, true);
  554. }
  555. //文件发送方式
  556. else {
  557. _tempthreeel = $$("div");
  558. //发表文章样式
  559. _tempel = $$("div", { "className": "UD_SYWF" }, _tempthreeel);
  560. _temponeel = $$("div", { "className": "UD_SYWFS" }, _tempel);
  561. _temptwoel = $$("div", { "className": "UD_SYWFSS" }, _temponeel);
  562. $$("div", { "innerHTML": fileinfo["UserDirectoryExtendType"] }, _temptwoel);
  563. _temptwoel = $$("div", { "className": "UD_SYWFSX" }, _temponeel);
  564. $$("div", { "className": "UD_SYWFSXN", "innerHTML": fileinfo["UserallDirectoryName"] }, _temptwoel);
  565. $$("div", { "className": "UD_SYWFSXS", "innerHTML": "已成功发送" }, _temptwoel);
  566. _temponeel = $$("div", { "className": "UD_SYWFX" }, _tempel);
  567. //如果是在1473上看到该信息,则可以直接打开网盘到指定的地方
  568. if (U.D.IsUseStudio) {
  569. _tempel.onclick = "U.M.StopBubble();YDHJH('disk', ['" + fileinfo.UserId + "', '" + fileinfo.UserDirectoryID + "'])"
  570. _temptwoel = $$("div", { "innerHTML": "打开我的云盘", "title": "打开我的云盘" }, _temponeel);
  571. _temptwoel.onclick = "U.M.StopBubble();YDHJH('disk', ['" + fileinfo.UserId + "','" + fileinfo.UserDirectoryParentID + "'])";
  572. _temptwoel = $$("div", { "innerHTML": "打开", "title": "打开" }, _temponeel);
  573. _temptwoel.onclick = "U.M.StopBubble();YDHJH('disk', ['" + fileinfo.UserId + "','" + fileinfo.UserDirectoryID + "'])";
  574. }
  575. //如果是第三方调用我们的好友,则出现下载
  576. else {
  577. _temptwoel = $$("div", { "innerHTML": "下载", "title": "下载" }, _temponeel);
  578. _temptwoel.onclick = "U.M.StopBubble();U.UP.FileDL('" + fileinfo.UserallDirectoryName + "','" + fileinfo.UserFilesServerName + "')";
  579. }
  580. //显示出文件的样式
  581. U.F.FM.SendFriendOrGroupChatMessage(friendinfo, _tempthreeel, el, _isgroup, true);
  582. }
  583. }
  584. //#endregion
  585. //#region 好友聊天扩展
  586. /**
  587. * 点击表情框处理
  588. *
  589. * @param {el} 表情框元素
  590. * @param {number} 第几个 i
  591. 对应路径 /img/ChatingFaceGif/[face](i).gif
  592. */
  593. U.F.W.PrintEmoticon = function (el, i) {
  594. var _imageurl = "/img/ChatingFaceGif/[face](" + i + ").gif", //表情路径
  595. _range = U.D.E.SORange.OE["Friend"]; //光标
  596. _range.Replace(" " + $$("img", { "src": _imageurl, "contentEditable": "true" }).outerHTML + " ", null, true);
  597. }
  598. //#endregion
  599. //右侧好友定位
  600. U.F.W.RightFormlocation = function () {
  601. $("#UD_SYHR").addAttrArray({ "style": { "top": (US.Height - 530) / 2, "right": "0px"} }); //
  602. }