123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- /*
- 问题:
- 1、整套好友的功能流程图
- 2、设计缺少流程 只有大流程 没有那个按钮的细节流程
- */
- Namespace.register("U.MD.F"); //好友主命名空间
- //#region 初始化好友
- //初始化好友函数
- /**
- * 初始化加载好友
- */
- U.MD.F.initFriend = U.MD.F.CSHFG = function () {
- //如果第三方应用1473,包含了好友窗体。
- if ($("#U_MD_F_H_Z")[0]) {
- var i,
- _friendinfo,
- _selectbottomel,
- _childsel,
- _chatform = $("#U_MD_F_H_Z")[0], //好友窗体
- _userinfoel = $("#U_MD_F_H_ZLTI", _chatform)[0]; //多好友分栏
- //初始化出现右边的好友聊天
- U.MD.F.W.friendDisplayAndNone([{
- "display": "none",
- "left": "auto"
- },
- {
- "display": "block",
- "top": (US.height - 530) / 2,
- "right": "0px"
- }],
- true);
- //添加当前使用用户的头像
- $($("img", _userinfoel)[0] || $$("img")).addAttrArray({
- "onerror": U.MD.C.imgError,
- "src": U.MD.C.getHeadImage(US.userInfo.UserThumbnailImageHead),
- "onclick": U.MD.U.P.userDataSet
- }).appendTo(_userinfoel);
- if (US.friend.recentcontacts.length) {
- _friendinfo = US.friend.recentcontacts;
- }
- else {
- _friendinfo = US.friend.friends;
- }
- //右侧好友最近联系人
- U.MD.F.printRightFormFriend(_friendinfo, $("#U_MD_F_H_RC")[0]);
- //我的好友、我的群组等按钮,默认显示我的好友 所以找到我的好友的按钮,并且默认调用onclick
- _selectbottomel = $("#U_MD_F_H_ZLTA").Child()[0];
- $(_selectbottomel).Child()[0].onclick();
- }
- }
- /**
- * 初始化右边好友出现
- *
- * @param {object} 好友头像处理
- * @param {element} 元素处理
- */
- U.MD.F.printRightFormFriend = function (friendinfo, el) {
- var i,
- _tempel,
- _temponeel,
- _frag = $$("frag"),
- _childs = $(el).Child();
- //如果是用户登录多次,移除之前残留的信息
- for (i = 1; i < _childs.length; i++) {
- el.removeChild(_childs[i]);
- }
- //如果有好友资料输出
- if (friendinfo.length) {
- //循环打印好友资料
- for (i = 0; (i < friendinfo.length && i < 11); i++) {
- if (friendinfo[i].tf == 1) {
- friendinfo[i] = U.Json.select(US.friend.group, { "GroupManageID": friendinfo[i].UserId })[0];
- _friendoneel = $$("div", { "className": "U_MD_F_H_ZLZOCOI", "style": { "margin": "9px 0 0 10px" }, "title": friendinfo[i].GroupManageName, "onclick": U.UF.C.closure(function (friendinfo) {
- U.UF.EV.stopBubble();
- U.MD.F.N.CanelMarkMessage(friendinfo.GroupManageID);
- U.MD.F.W.popupFriendsForm(friendinfo);
- }, [friendinfo[i]])
- }, _frag);
- U.MD.F.printGroupHeadImage(friendinfo[i], _friendoneel, 4, [35, 35]);
- } else {
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "title": friendinfo[i]["FriendsDescript"],
- "className": "U_MD_F_H_RCI",
- "src": U.MD.C.getHeadImage(friendinfo[i].UserThumbnailImageHead),
- "alt": friendinfo[i].FriendsDescript || friendinfo[i].UserNickName,
- "onclick": U.UF.C.closure(function (friendinfo) {
- U.UF.EV.stopBubble();
- U.MD.F.W.popupFriendsForm(friendinfo);
- U.MD.F.N.CanelMarkMessage(friendinfo.UserID);
- }, [friendinfo[i]])
- }, _frag);
- }
- }
- }
- //暂无好友追随
- else {
- _tempel = $$("div", { "className": "U_MD_F_H_RCT" }, _frag);
- _temponeel = $$("div", { "className": "U_MD_F_H_RCTS" }, _tempel);
- $$("img", { "onerror": U.MD.C.imgError, "src": "/img/YSUN.png" }, _temponeel);
- $$("div", { "className": "U_MD_F_H_RCTZ U_Img" }, _tempel);
- $$("div", { "className": "U_MD_F_H_RCTX", "innerHTML": "暂时无追随" }, _tempel);
- }
- var _tipsicon = $$("div", { className: "U_MD_D_NewsTipsIcon" }, _frag);
- el.appendChild(_frag);
- }
- /**
- * 用户列表好友打印
- *
- * @param {elem_frag元素11
- */
- U.MD.F.printFriendGroupOrFriend = function (el) {
- var i,
- _tempel,
- _temponeel,
- _classinfo,
- _friendinfo = US.friend.allclass,
- _frag = $$("frag");
- el.innerText = "";
- //如果用户有好友则打印
- if (US.friend.friends.length) {
- //循环打印好友分组
- for (i = 0; i < _friendinfo.length; i++) {
- _classinfo = U.Json.select(US.friend.friends, { "FriendsGroupID": _friendinfo[i].FriendsGroupID }); //根据好友分组获取好友
- //打印好友分组
- _tempel = $$("div",
- {
- id: "g" + _friendinfo[i].FriendsGroupID,
- "TID": _friendinfo[i].FriendsGroupID,
- "className": "U_MD_F_H_ZLZO"
- },
- _frag);
- $$("div",
- {
- "className": "U_MD_F_H_ZLZOT",
- "innerHTML": _friendinfo[i].FriendsGroupName + "(" + _classinfo.length + ")",
- "onclick": U.UF.C.closure(function (i) {
- U.MD.F.openOrCloseFriendClass(this);
- }, [i]),
- "oncontextmenu": U.UF.C.closure(function (i) {
- U.MD.F.R.friendClassRightClickMenu(US.friend.allclass[i], this);
- }, [i])
- },
- _tempel);
- _temponeel = $$("div", { "className": "U_MD_F_H_ZLZOC" }, _tempel);
- //打印好友
- U.MD.F.printFriendOrGroup(_temponeel, _classinfo);
- }
- }
- //无好友打印提示
- else {
- U.MD.F.printHasNoFriend(_frag);
- }
- el.appendChild(_frag);
- }
- /**
- * 好友和群样式输出
- *
- * @param {element} 元素
- * @param {array} 好友数组
- */
- U.MD.F.printFriendOrGroup = function (el, friendorgroupinfo, isinsert) {
- var i,
- _isfront,
- _friendel,
- _friendoneel,
- _friendtwoel,
- _onlinefrag = $$("frag"),
- _offlinefrag = $$("frag");
- //循环所有的好友或者群,打印到左边好友或群面板中
- if (friendorgroupinfo.length == 0) {
- $$("div", { "class": "U_MD_F_H_ZLZOCO_under", "style": { "margin": "9px 0 0 10px" }, "innerHTML": "最近暂无任何聊天" }, el);
- } else {
- for (i = 0; i < friendorgroupinfo.length; i++) {
- if (friendorgroupinfo[i].tf == 1) {
- friendorgroupinfo[i] = U.Json.select(US.friend.group, { "GroupManageID": friendorgroupinfo[i].UserId })[0]
- }
- _friendel = $$("div",
- {
- "className": "U_MD_F_H_ZLZOCO",
- "onclick": U.UF.C.closure(function (friendorgroupinfo) {
- U.MD.F.N.CanelMarkMessage(friendorgroupinfo);
- U.MD.F.W.popupFriendsForm(friendorgroupinfo, this);
- }, [friendorgroupinfo[i]]),
- "TID": friendorgroupinfo[i].GroupManageID || friendorgroupinfo[i].UserId,
- "oncontextmenu": U.UF.C.closure(function (friendorgroupinfo) {
- alert();
- if (friendorgroupinfo.UserId) {
- U.MD.F.R.friendsRightClickMenu(this, friendorgroupinfo);
- } else if (friendorgroupinfo.GroupManageID) {
- U.MD.F.R.GroupRightClickMenu(this, friendorgroupinfo);
- }
- }, [friendorgroupinfo[i]])
- });
- _friendoneel = $$("div", { "className": "U_MD_F_H_ZLZOCOI" }, _friendel);
- //如果是群的处理,群的头像输出
- if (friendorgroupinfo[i].GroupManageID) {
- U.MD.F.printGroupHeadImage(U.Json.select(US.friend.group, { "GroupManageID": friendorgroupinfo[i].GroupManageID || friendorgroupinfo[i].UserId })[0], _friendoneel, 4, [35, 35]);
- }
- //好友头像输出
- else {
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "src": U.MD.C.getHeadImage(friendorgroupinfo[i].UserThumbnailImageHead)
- },
- _friendoneel);
- }
- _friendtwoel = $$("div", { "className": "U_MD_F_H_ZLZOCOR U_MD_D_Text_Abbreviation" }, _friendel);
- $$("div", { "className": "U_MD_F_H_ZLZOCORN U_MD_D_Text_Abbreviation", "innerHTML": friendorgroupinfo[i].FriendsDescript || friendorgroupinfo[i].UserNickName || friendorgroupinfo[i].GroupManageName }, _friendtwoel);
- $$("div", { "className": "U_MD_F_H_ZLZOCORT U_MD_D_Text_Abbreviation", "innerHTML": friendorgroupinfo[i].UserIndividualitysignature || (friendorgroupinfo[i].GroupManageDescript == friendorgroupinfo[i].GroupManageName ? "" : friendorgroupinfo[i].GroupManageDescript) || "" }, _friendtwoel);
- //如果用户在线那么插入到最前面
- if (friendorgroupinfo[i].IsLogin == 1) {
- _onlinefrag.appendChild(_friendel);
- }
- //否则插入到后面
- else {
- _offlinefrag.appendChild(_friendel);
- }
- }
- el.insertBefore(_onlinefrag, el.firstChild); //在线用户插入到最前面
- //如果需要插入到最前面,那么则不管在不在线的用户都插入到最前面
- if (isinsert) {
- el.insertBefore(_offlinefrag, el.firstChild); //用户插入到最前面
- }
- else {
- el.appendChild(_offlinefrag); //非在线用户插入到最后米娜
- }
- }
- }
- /**
- * 打开分组展开好友
- *
- * @param {element} 展开好友的区域
- */
- U.MD.F.openOrCloseFriendClass = function (el) {
- var _firendel = $($(el).Parent()).Child()[1]; //获取好友分组对应的好友元素
- //如果现在隐藏了则打开
- if (_firendel.style.display == "none") {
- _firendel.style.display = "block";
- }
- //如果是显示则隐藏
- else {
- _firendel.style.display = "none";
- }
- }
- /**
- * 打印空好友
- *
- * @param {element} 打印的区域
- */
- U.MD.F.printHasNoFriend = function (el) {
- var _tempel,
- _temponeel
- ;
- _tempel = $$("div", { "className": "U_MD_F_H_ZLZT" }, el);
- _temponeel = $$("div", { "className": "U_MD_F_H_ZLZTS" }, _tempel);
- $$("img", { "onerror": U.MD.C.imgError, "src": "/img/YSUN.png" }, _temponeel);
- $$("div", { "className": "U_MD_F_H_ZLZTZ U_Img" }, _tempel);
- $$("div", { "className": "U_MD_F_H_ZLZTX", "innerHTML": "暂时没有添加追随!!" }, _tempel);
- }
- //#endregion
- //#region 好友功能
- /**
- * 打印空好友
- *
- * @param {string} 切换类型
- * @param {element} 点钱点击的区域
- * @param {element} 变化的样式
- */
- U.MD.F.switchFriendOrGroup = function (typename, el, classname) {
- var i,
- _chatform = $("#U_MD_F_H_ZLZ")[0], //打印内容区域
- _childsel = $(el).parentElement(2).Child(), //所有参与切换的元素
- _classarray = ["U_MD_F_H_ZLTO", "U_MD_F_H_ZLTT", "U_MD_F_H_ZLTS", "U_MD_F_H_ZLTF"]; //切换样式数组
- //切换按钮的样式,把样式改成用户默认按钮的样式
- for (i = 0; i < _childsel.length; i++) {
- $(_childsel[i]).Child()[0].className = _classarray[i] + " U_Img U_MD_F_H_ZLTOK";
- }
- //设置选中的按钮样式
- el.className = classname + " U_Img U_MD_F_H_ZLTOK";
- //点击好友添加按钮
- if (typename == "A") {
- U.MD.F.M.createFriendGroupPopup(); //调用创建群弹框
- }
- else {
- //群成员
- if (typename == "H") {
- var _grouparr = US.friend.group; //获取用户或有群信息
- _chatform.innerText = ""; //清空展示区域的内容
- U.MD.F.printFriendOrGroup(_chatform, _grouparr); //打印
- }
- //最近联系人
- else if (typename == "G") {
- var _recentcontacts = US.friend.recentcontacts;
- _chatform.innerText = ""; //清空展示区域的内容
- U.MD.F.printFriendOrGroup(_chatform, _recentcontacts); //打印
- }
- //打印好友,由于好友有好友分组,所以不能直接调用U.MD.F.printFriendOrGroup输出
- else {
- U.MD.F.printFriendGroupOrFriend(_chatform); //打印
- }
- }
- }
- /*
- if (j == _value.length) {
- U.MD.F.printFriendOrGroup(_chatform, _grouparr); //打印
- _grouparr.splice(0, _grouparr.length);
- }
- */
- /**
- * 获取群里头像集
- *
- * @param {object} 群信息
- * @param {element} 添加指定的元素
- * @param {element} 变化的样式
- * @param {element} 最大长度
- */
- U.MD.F.printGroupHeadImage = function (groupinfo, el, num, size) {
- var i, j,
- _groupnameel,
- _horizontal,
- _vertical,
- _imageel,
- _groupuserinfo = U.Json.select(US.friend.groupusers, { "GroupManageID": groupinfo.GroupManageID }, (num || 9)); //获取当前群
- if (_groupuserinfo.length < 3) {
- _horizontal = _groupuserinfo.length;
- } else {
- if (_groupuserinfo.length > 6) {
- _horizontal = 3;
- } else {
- _horizontal = 2;
- }
- } //每排几个
- if (_groupuserinfo.length > 4) {
- _vertical = 3
- } else {
- if (_groupuserinfo.length > 1) {
- _vertical = 2
- } else {
- _vertical = 1
- }
- } //一共多少行
- size = size || [el.offsetHeight || 40, el.offsetWidth || 40]; //最大长宽
- _groupnameel = $$("div", { "className": "U_MD_HomeSSZFZAIO", "title": groupinfo.GroupManageName }); //群名
- //打印所有群成员头像 横排打印
- for (i = 0; i < _horizontal; i++) {
- _imageel = $$("div", { "style": { "width": "100%", "height": Math.floor(size[0] / _horizontal) + "px"} }, _groupnameel);
- //竖排打印
- for (j = i * _vertical; j < i * _vertical + _vertical && j < _groupuserinfo.length; j++) {
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "src": U.MD.C.getHeadImage(_groupuserinfo[j].UserThumbnailImageHead),
- "style":
- {
- "width": Math.floor(size[1] / _vertical) + "px",
- "height": Math.floor(size[0] / _vertical) + "px"
- }
- }, _imageel);
- }
- };
- //追加
- el.appendChild(_groupnameel);
- }
- //#endregion
|