123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- Namespace.register("U.MD.F.H");
- U.MD.F.H.viewFriendsChatRecords = function (el, friendandgroupinfo, page, isgroup) {
-
- if (el.style.display == "block") {
- el.style.display = "none";
- U.MD.F.W.chatBoxSize($(el).Parent(3), $(el).Parent());
- }
-
- else {
- $(el).Child()[1].innerHTML = "";
- U.MD.F.H.chatRecord(el, friendandgroupinfo, page, isgroup);
- el.style.display = "block";
- }
- U.MD.F.W.chatBoxSize($(el).Parent(8), $(el).Parent());
- }
- U.MD.F.H.chatRecord = function (el, friendandgroupinfo, page, isgroup) {
- var _end = page * 20,
- _start = _end - 20;
-
- if (isgroup) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetGroupChatHistory",
- friendandgroupinfo.GroupManageID, _start, _end], U.MD.F.H.asynChatRecord, ["", el, friendandgroupinfo, page, isgroup]);
- }
-
- else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetFriendChatHistory",
- US.userInfo.userid, friendandgroupinfo.UserId, _start, _end], U.MD.F.H.asynChatRecord, ["", el, friendandgroupinfo, page, isgroup]);
- }
- }
- U.MD.F.H.asynChatRecord = function (r) {
- var _context = r.context,
- _recentcontactsel = _context[1],
- _friendandgroupinfo = _context[2],
- _page = _context[3],
- _isgroup = _context[4],
- _childs = $(_recentcontactsel).Child();
- r = r.value;
- _childs[0].innerText = "";
- if (r.length) {
-
- U.MD.F.H.printChatRecord(_childs[0], r, _friendandgroupinfo);
-
- _childs[0].scrollTop = _childs[0].scrollHeight;
-
-
-
-
-
-
-
- if (!$("div", _childs[1]).length) {
- var _calendar = $$("div", { "id": "U_MD_F_H_calendar", "style": { "width": "16px", "height": "17px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-855px -481px", "margin": "5px 0 5px 13px"} }, _childs[1]),
- _firstPage = $$("div", { "id": "U_MD_F_H_firstPage", "style": { "width": "13px", "height": "18px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-891px -481px", "margin": "5px 20px 4px 127px"} }, _childs[1]),
- _previousPage = $$("div", { "id": "U_MD_F_H_previousPage", "style": { "width": "11px", "height": "18px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-924px -481px", "margin": "5px 20px 4px 0px"} }, _childs[1]),
- _nextPage = $$("div", { "id": "U_MD_F_H_nextPage", "style": { "width": "10px", "height": "17px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-957px -481px", "margin": "5px 20px 4px 0px"} }, _childs[1]),
- _lastPage = $$("div", { "id": "U_MD_F_H_lastPage", "style": { "width": "13px", "height": "18px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-987px -481px", "margin": "5px 13px 4px 0px"} }, _childs[1]),
- _calendarPlace = $$('div', { "style": { cssText: "position:absolute; margin-bottom: 297px;"} }, _calendar)
- $("#U_MD_F_H_firstPage")[0].onclick = function () {
- _page = 1;
- U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _page, _isgroup);
- }
- $("#U_MD_F_H_previousPage")[0].onclick = function () {
- _page--;
- U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _page, _isgroup);
- }
- $("#U_MD_F_H_nextPage")[0].onclick = function () {
- _page++;
- U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _page, _isgroup);
- }
- $("#U_MD_F_H_lastPage")[0].onclick = function () {
- _page = Math.ceil(r[0].AllC / 20);
- U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _page, _isgroup);
- }
-
- }
- }
- else {
- U.alert("服务器繁忙,请稍后获取聊天记录");
- }
- }
- U.MD.F.H.printChatRecord = function (el, recordinfo, friendandgroupinfo) {
- var _tempel,
- _temponeel,
- _temptwoel,
- i = recordinfo.length,
- _frag = $$("frag");
-
- while (i--) {
-
- if (recordinfo[i].MessageContent? recordinfo[i].MessageContent.indexOf("fileName") != -1 : recordinfo[i].GroupMessageContent.indexOf("fileName") != -1) {
- _tempel = $$("div", { "className": "U_MD_F_LO" }, _frag);
- _temponeel = $$("div", { "className": "U_MD_F_LOT" }, _tempel);
- $$("div", { "className": "U_MD_F_LOTN", "innerHTML": recordinfo[i].MessageDescript || recordinfo[i].GroupMessageSendUsername || friendandgroupinfo.FriendsDescript || friendandgroupinfo.GroupManageName }, _temponeel);
- $$("div", { "className": "U_MD_F_LOTT", "innerHTML": U.UF.D.getDateInterval(recordinfo[i].MessageSendTime || recordinfo[i].GroupMessageSendTime) }, _temponeel);
- var _data = JSON.parse(recordinfo[i].MessageContent);
- if (_data.fileType == "jpg" || _data.fileType == "png" || _data.fileType == "mp4") {
- var _content = $$("div", { "style": { "cssText": "padding:8px 8px 8px 8px;background:#fff;border-radius:2px;margin-top:12px;position:relative"} }, _tempel);
- }else{
- var _content = $$("div", { "style": { "cssText": "padding:8px 8px 8px 8px;background:#fff;border-radius:2px;margin-top:12px;border:1px #d3d3d3 solid;background:#f9f9f9;"} }, _tempel);
- }
- U.MD.F.W.printFileContent(_data, _content);
- } else {
- _tempel = $$("div", { "className": "U_MD_F_LO" }, _frag);
- _temponeel = $$("div", { "className": "U_MD_F_LOT" }, _tempel);
- $$("div", { "className": "U_MD_F_LOTN", "innerHTML": recordinfo[i].MessageDescript || recordinfo[i].GroupMessageSendUsername || friendandgroupinfo.FriendsDescript || friendandgroupinfo.GroupManageName }, _temponeel);
- $$("div", { "className": "U_MD_F_LOTT", "innerHTML": U.UF.D.getDateInterval(recordinfo[i].MessageSendTime || recordinfo[i].GroupMessageSendTime) }, _temponeel);
- $$("div", { "className": "U_MD_F_LOD", "innerHTML": recordinfo[i].MessageContent || recordinfo[i].GroupMessageContent }, _tempel);
- }
- }
- el.appendChild(_frag);
- }
- U.MD.F.H.sendFriendOrGroupChatMessage = function (friendandgroupinfo, chateditel, chatcontentnewsel, isgroup, isupload) {
- var _newsinfo,
- _chatcontent = chateditel.innerHTML,
- _friendid = friendandgroupinfo.UserId || friendandgroupinfo.GroupManageID;
-
- if (_chatcontent.isHtmlNull()) {
- U.MD.F.H.sendChatMessageToDb(_friendid, _chatcontent, null, isgroup);
-
- _newsinfo = [{
- "UserId": US.userInfo.userid,
- "Time": new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds(),
- "Content": _chatcontent,
- "IMG": US.userInfo.UserThumbnailImageHead,
- "Name": US.userInfo.UserNickName
- }]
-
- if (isgroup) {
- U.MD.F.W.printGroupChatMessage(chatcontentnewsel, _newsinfo, true);
- }
- else {
- U.MD.F.W.printFriendChatMessage(chatcontentnewsel, _newsinfo, true);
- }
-
- if (!isupload) {
- chateditel.innerText = ""
- }
- }
- }
- U.MD.F.H.sendChatMessageToDb = function (friendid, message, cb, isgroup) {
- var _friendorgroupinfo,
- _userinfo = US.userInfo;
-
- if (isgroup) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SendMessageToGroup", friendid, Guid.newGuid(), _userinfo.UserId, message, _userinfo.UserNickName], function () { }, [""]);
- }
-
- else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SentMessageToFriend", _userinfo.UserId, friendid, _userinfo.UserNickName, message, 0, false], function () { }, [""]);
- }
-
-
- if (isgroup) {
- _friendorgroupinfo = U.Json.select(US.friend.group, { "GroupManageID": friendid })[0];
- }
-
- else {
-
- _friendorgroupinfo = U.Json.select(US.friend.recentcontacts, { "UserId": friendid })[0];
-
- if (_friendorgroupinfo) {
-
- _friendorgroupinfo = U.Json.select(US.friend.friends, { "UserId": friendid })[0];
- }
- }
-
- if (_friendorgroupinfo) {
- U.MD.F.H.recentContacts(_friendorgroupinfo);
- }
- }
- U.MD.F.H.getFriendOrGroupNews = function (friendid, cb, isgroup) {
- var _userinfo = US.userInfo;
-
- if (isgroup) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetGroupUnreadMessage", _userinfo.UserId, friendid], cb, ["", friendid, isgroup]);
- }
-
- else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetFriendUnreadMessage", _userinfo.UserId, friendid], cb, ["", friendid, isgroup]);
- }
- }
- U.MD.F.H.recentContacts = function (userinfo) {
- var _recentcontactsel,
- _num,
- _recentcontactsinfo,
- _contentel = $("#U_MD_F_H_ZLZ")[0];
- if (US.friend.recentcontacts) {
-
- _num = US.friend.recentcontacts.objIndexOf({ "UserId": userInfo.userid || userinfo.GroupManageID });
-
- if (_num > -1) {
- _recentcontactsinfo = US.friend.recentcontacts.splice(_num, 1)[0];
- }
-
- else {
-
- _recentcontactsinfo = new U.MD.F.T.recentContactsEntity(userinfo.GroupManageID || userInfo.userid,
- userinfo.GroupManageName || userinfo.UserName, userinfo.UserImageHead || "", userinfo.UserNickName || "",
- userinfo.UserThumbnailImageHead || "", userinfo.maxMessageSendTime || new Date(),
- userinfo.GroupManageDescript || userinfo.FriendsDescript, userinfo.GroupManageRemark || userinfo.UserIndividualitysignature || "",
- userinfo.IsLogin || 3, userinfo.GroupManageID ? 1 : 0);
- }
-
- US.friend.recentcontacts.unshift(_recentcontactsinfo);
-
- _recentcontactsel = $("#U_MD_F_H_ZLTA").childs()[2];
- _recentcontactsel = $(_recentcontactsel).Child()[0];
-
- if (_recentcontactsel.className.indexOf("U_MD_F_H_ZLTSO") > -1) {
- _recentcontactsel = $("div@TID=" + (userinfo.GroupManageID || userInfo.userid), $("#U_MD_F_H_ZLZ")[0])[0];
-
- if (_recentcontactsel) {
- ($(_recentcontactsel).appendTo(_contentel, 0, _contentel.firstChild));
- }
-
- else {
- U.MD.F.printFriendOrGroup(_contentel, US.friend.recentcontacts[0], true);
- }
- }
- }
- }
|