1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189 |
- Namespace.register("U.MD.F.J"); //好友加群加好友的命名空间
- //#region 创建群组
- //听见群用户的信息
- U.MD.F.J.selectUserInfo = {
- NeedUser: [], //需要添加的群用户
- SelectUser: [], //已经选择过的用户
- CallBack: null //添加后的回调
- };
- /**
- * 显示添加群窗口
- *
- * @param {object} 群信息
- * @param {element} 元素处理
- * @param {boolean}
- */
- U.MD.F.J.groupInfoForm = function (groupinfo, chatel) {
- var _formel, //窗体
- _groupuserinfo, //获取所有的群好友
- _determinebottom,
- _closebottom,
- _isgroupmain,
- _isdeletegroup,
- _groupinfoel = $("#U_MD_F_Add"), //添加群的窗体
- _addgroupuserel = $("#U_MD_F_RC_C")[0], //内容区域
- _groupinfochildsel = _groupinfoel.Child(), //群信息窗体子元素
- _inputel = $("input,textarea", _groupinfochildsel[0]); //内容输出
- //清空群用户
- U.MD.F.J.selectUserInfo.NeedUser.splice(0, U.MD.F.J.selectUserInfo.NeedUser.length);
- //设置该联系人进入群
- _groupinfochildsel[1].innerHTML = "";
- //如果群存在的处理
- if (groupinfo) {
- //是否是新建群或者是群主,
- if ($('.U_MD_F_Add_TNM_ADD2')[0]) {
- $('.U_MD_F_Add_TNM_ADD2')[0].style.display = "none";
- }
- if ($('.U_MD_F_Add_TNMO')[0]) {
- $('.U_MD_F_Add_TNMO')[0].style.display = "block";
- }
- if ($('.U_MD_F_Add_C_D')[0]) {
- $('.U_MD_F_Add_C_D')[0].style.display = "block";
- }
- if ($('.U_MD_F_Add_C')[0]) {
- $('.U_MD_F_Add_C')[0].style.display = "block";
- }
- if (groupinfo) {
- _isgroupmain = groupinfo.GroupManageCreateUserID == US.userInfo.userid; //群主
- } else {
- _isgroupmain = !groupinfo; //新建群
- }
- //判断是否是群主还是群成员
- if (_isgroupmain) {
- _isdeletegroup = "解散该群"; //群主
- } else {
- _isdeletegroup = "退出该群"; //群成员
- }
- //设置是否显示解散该群还是退出该群
- $(_groupinfoel[0]).Child()[2].style.display = "block";
- //设置群名,群描述等
- _inputel[0].value = groupinfo.GroupManageName;
- _inputel[1].value = groupinfo.GroupManageDescript;
- //获取群用户的信息
- _groupuserinfo = U.Json.select(US.friend.groupusers, { "GroupManageID": groupinfo.GroupManageID });
- //设置已经选择过的用户
- U.MD.F.J.selectUserInfo.SelectUser = _groupuserinfo;
- //打印当前群的用户
- U.MD.F.J.printGroupUserInfo(_groupinfochildsel[1], _groupuserinfo, groupinfo);
- //点击退出按钮事件设置
- $(_groupinfochildsel[2]).addAttrArray({
- "onclick": function () {
- U.MD.F.J.groupExit(groupinfo, U.Json.selectOne(_groupuserinfo, { "UserId": US.userInfo.userid }), _groupinfoel);
- },
- "innerHTML": _isdeletegroup
- });
- }
- //创建新群,清空数据
- else {
- //设置群名,群描述等
- _inputel[0].value = "";
- _inputel[1].value = "";
- $(_groupinfoel[0]).Child()[2].style.display = "none";
- $('.U_MD_F_Add_TNMO')[0].style.display = "none";
- $('.U_MD_F_Add_C_D')[0].style.display = "none";
- $('.U_MD_F_Add_C')[0].style.display = "none";
- $('.U_MD_F_Add_TNM_ADD2')[0].style.display = "block";
- }
- _groupinfoel[0].style.display = "block";
- //弹出窗体
- _formel = new U.UF.UI.form("群聊信息",
- _groupinfoel[0],
- {
- "id": "U_MD_F_Add_O",
- "style": {
- "width": "480px"
- }
- },
- {
- isnarrow: false,
- isenlarge: false
- }).form;
- U.UF.EV.scrollLoad(_formel, function () { U.MD.D.PB.Re.FGRPMHBK(_formel); })
- if (!groupinfo) {
- $($(_formel).Child()[2]).Child()[0].style.MaxHeight = "650px";
- $(_formel)[0].style.Maxheight = "650px";
- }
- //确定添加群处理
- _determinebottom = $(_groupinfochildsel[3]).Child()[0];
- _determinebottom.onclick = function () {
- U.MD.F.J.determineCreateGroupAndAddGroupUser(groupinfo ? groupinfo.GroupManageID : null, _groupinfochildsel[0], chatel);
- };
- //邀请好友处理
- _invitationbottom = $($(_groupinfochildsel[0]).Child()[1]).Child()[1];
- _invitationbottom.onclick = function () {
- U.MD.F.J.selectFriendForm(function () {
- U.MD.F.J.determineCreateGroupAndAddGroupUser(groupinfo ? groupinfo.GroupManageID : null, _groupinfochildsel[0], chatel, true);
- }, 'friend', "", 1);
- }
- $('#U_MD_F_Add_TNM_ADD2_add')[0].onclick = function () {
- U.MD.F.J.selectFriendForm(function () {
- U.MD.F.J.determineCreateGroupAndAddGroupUser(groupinfo ? groupinfo.GroupManageID : null, _groupinfochildsel[0], chatel, true);
- }, 'friend', "", 0);
- }
- //确定取消群处理
- _closebottom = $(_groupinfochildsel[3]).Child()[1];
- _closebottom.onclick = function () {
- U.UF.F.windowMinimize(_formel);
- }
- //添加新用户进去群的窗体显示了,那么则重新点击刷新
- // if (_addgroupuserel.style.display == "block") {
- // U.MD.F.J.selectFriendForm();
- // }
- return _formel;
- }
- /**
- * 显示添加群窗口
- *
- * @param {element} 添加进入的元素
- * @param {object} 添加的用户信息
- */
- U.MD.F.J.printGroupUserInfo = function (el, groupuserinfo, groupinfo) {
- var i,
- //临时元素变量
- _tempel,
- _temponeel,
- _temptwoel,
- _tempname,
- _frag = $$("frag"),
- _childsel = $(el).Child(),
- _isgroupmain;
- //判断是否是群主
- if (groupinfo) {
- _isgroupmain = groupinfo.GroupManageCreateUserID == US.userInfo.userid;
- } else {
- _isgroupmain = !groupuserinfo;
- }
- //获取不同的classname
- if (_isgroupmain) {
- _tempname = "U_MD_F_Add_R" + " U_MD_F_Add_RS"
- } else {
- _tempname = "U_MD_F_Add_R" + ""
- }
- //打印群用户显示的样式
- for (i = 0; i < groupuserinfo.length; i++) { //循环添加
- _tempel = $$("div", { "className": "U_MD_F_Add_CO" }, _frag);
- _tempell = $$("div", { "style": { "width": "32%", "height": "30px", "float": "left" } }, _tempel);
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "src": U.MD.C.getHeadImage(groupuserinfo[i].UserThumbnailImageHead)
- },
- _tempell);
- $$("div", { "className": "U_MD_F_Add_COM U_MD_D_Text_Abbreviation", "innerHTML": groupuserinfo[i].UserName }, _tempell);
- _temponeel = $$("div", { "className": "U_MD_F_Add_COM U_MD_D_Text_Abbreviation UD_UserName", "style": { "width": "32%", "margin-left": "2%" }, "innerHTML": groupuserinfo[i].GroupUsersDescript || groupuserinfo[i].UserNickName || groupuserinfo[i].UserName }, _tempel);
- _temptwoel = $$("div",
- {
- "className": _tempname
- },
- _tempel);
- //这有已经新建的群
- if (groupinfo) {
- //只有本人或者群主才能修改群名片
- if (_isgroupmain || groupuserinfo[i].UserId == US.userInfo.userid) {
- $$("img",
- {
- "src": "/img/Edit1.png",
- "title": "修改群名片",
- "onclick": (function (i) {
- return U.UF.C.closure(U.MD.F.J.upateGroupUserDescriptForm, [groupuserinfo[i], _temponeel]);
- })(i)
- },
- _temptwoel);
- }
- $$("img",
- {
- "src": "/img/personalCard1.png", "title": "查看用户资料",
- "onclick": (function (i) {
- return U.UF.C.closure(U.MD.U.V.ViewOtherUserInfo, [groupuserinfo[i].UserId]);
- })(i)
- },
- _temptwoel);
- $$("img",
- {
- "src": "/img/Add1.png", "title": "添加好友",
- "onclick": (function (i) {
- return U.UF.C.closure(U.MD.F.M.addFriend, [groupuserinfo[i], null, _tempel]);
- })(i)
- },
- _temptwoel);
- }
- //如果是群主有移除权限
- if (_isgroupmain) {
- $$("img",
- {
- "src": "/img/exit1.png", "title": "移除",
- "onclick": (function (i) {
- return U.UF.C.closure(U.MD.F.J.groupExit, [groupinfo, groupuserinfo[i], _tempel]);
- })(i)
- },
- _temptwoel);
- }
- }
- //判断元素是否存在,如果存在则,追加元素,如果不存在则添加到最后面
- if (_childsel.length) {
- el.insertBefore(_frag, _childsel[_childsel.length - 1]);
- }
- else {
- el.appendChild(_frag);
- }
- }
- /**
- * 显示添加群窗口
- *
- * @param {object} 群好友信息
- */
- U.MD.F.J.upateGroupUserDescriptForm = function (groupuserinfo, el) {
- var _tempel,
- _temponeel,
- _temptwoel,
- _groupname = groupuserinfo.GroupUsersDescript || groupuserinfo.UserName
- ;
- if (groupuserinfo) {
- //创建好友分组的样式
- _tempel = $$("div", { "className": "U_MD_U_L_Box_I U_MD_F_Add_TNL U_MD_F_G" });
- _temponeel = $$("div", {}, _tempel)
- _temptwoel = $$("input",
- {
- "value": _groupname,
- "onfocus": function () {
- U.UF.MR.inputPlaceholder(this, _groupname, "");
- },
- "onblur": function () {
- U.UF.MR.inputPlaceholder(this, "", _groupname);
- }
- }, _temponeel);
- //弹出好友对话框
- U.UF.UI.confirm(_tempel, function () {
- U.MD.F.J.determineUpateGroupUserDescript(groupuserinfo, _temptwoel, el);
- });
- }
- else {
- U.alert("暂无群信息");
- }
- }
- /**
- * 弹出设置
- *
- * @param {object} 群好友信息
- */
- U.MD.F.J.determineUpateGroupUserDescript = function (groupuserinfo, inputel, el) {
- //判断用户是否输入正确的备注名
- if (inputel.value && U.UF.S.NickName.test(inputel.value)) {
- U.A.Request(US.FRIEND, ["UpdateGroupMemberInfo", US.userInfo.userid, groupuserinfo.GroupManageID, groupuserinfo.UserId, inputel.value],
- U.MD.F.J.asynDetermineUpateGroupUserDescript, [null, groupuserinfo, inputel.value, el]);
- }
- else {
- U.alert("备注名格式不对");
- return true;
- }
- }
- /**
- * 修改群备注
- *
- * @param {object} 群好友信息
- */
- U.MD.F.J.asynDetermineUpateGroupUserDescript = function (r) {
- var _context = r.context,
- _groupuserinfo = _context[1], //群用户信息
- _descriptname = _context[2], //修改后的备注名
- _el = _context[3]; //元素
- //修改groupuserinfo里面的用户备注的变量和修改显示给用户看到的备注
- _el.innerText = _groupuserinfo.GroupUsersDescript = _descriptname;
- U.alert("修改备注成功!");
- }
- /**
- * 退出或者踢人
- *
- * @param {object} 群信息
- * @param {object} 好友信息
- */
- U.MD.F.J.groupExit = function (groupinfo, userinfo, el) {
- var _userid = US.userInfo.userid, //用户id
- _isgroupmain = groupinfo.GroupManageCreateUserID == _userid //判断用户是否是群主
- ;
- //如果推出群的是群主处理
- if (_isgroupmain) {
- //如果群主自己推出,则解散群
- if (userInfo.userid == _userid) {
- U.UF.UI.confirm("是否解散该群", function () {
- U.MD.F.J.enterGroupExit(groupinfo, userinfo, true, el);
- }); //创建提示框 提示是否删除备份
- }
- //否则则移除群好友
- else {
- //创建提示框 提示是否删除备份
- U.UF.UI.confirm("是否移除该群用户", function () {
- U.MD.F.J.enterGroupExit(groupinfo, userinfo, false, el);
- });
- }
- }
- //不是群主的处理
- else {
- U.UF.UI.confirm("是否确定退出该群", function () { U.MD.F.J.enterGroupExit(groupinfo, userinfo, false, el); }); //创建提示框 提示是否删除备份
- }
- }
- /**
- * 移除群异步
- *
- * @param {object} 群信息
- * @param {object} 好友信息
- * @param {bool} 是否为删除群
- */
- U.MD.F.J.enterGroupExit = function (groupinfo, userinfo, isdelete, el) {
- if (isdelete === true) {
- U.A.Request(US.FRIEND,
- ["DeleteGroup", US.userInfo.userid, groupinfo.GroupManageID], U.MD.F.J.asynGroupExit, ["", groupinfo, userinfo, isdelete, el]); //解散群
- }
- else {
- U.A.Request(US.FRIEND, ["ExitGroup", US.userInfo.userid, groupinfo.GroupManageID, userInfo.userid], U.MD.F.J.asynGroupExit, ["", groupinfo, userinfo, isdelete, el]);
- }
- }
- /**
- * 群移除异步
- *
- * @param {object} 群信息
- * @param {object} 好友信息
- * @param {bool} 是否为删除群
- */
- U.MD.F.J.asynGroupExit = function (r) {
- var _context = r.context,
- _chatfrom,
- _groupinfo = _context[1], //群信息
- _friendinfo = _context[2], //自己在群里的信息
- _isdelete = _context[3], //是解散群还是退出(移除)群用户
- _el = _context[4], //弹出的群窗体
- _chatformel = $("#U_MD_F")[0]; //聊天框元素
- //删除群处理 或者退出群
- if (_isdelete) {
- //清空用户在群的数据
- U.Json.del(US.friend.group, { "GroupManageID": _friendinfo.GroupManageID }); //删除群
- U.Json.del(US.friend.groupusers, { "GroupManageID": _friendinfo.GroupManageID }); //删除群用户
- //用户面板里是否存在用户,存在删除
- $("#U_MD_F_H_ZLZ").find("[TID=\"" + _groupinfo.GroupManageID + "\"]").remove(); //删除群
- //判断好友是否出现在聊天框里,如果是则移除聊天框
- _chatfrom = U.MD.F.W.isCreateForm(_friendinfo.GroupManageID)[0]; //
- if (U.MD.F.W.isCreateForm(_friendinfo.GroupManageID)[0]) {
- U.MD.F.W.delteFriendChat(_friendinfo.GroupManageID, _chatformel);
- }
- //弹出群消息的弹窗
- if (_el) {
- _el = $(_el).Parent({ usform: "true" });
- _el.close();
- }
- U.alert('解散群成功');
- }
- //群主删除好友处理
- else if (_groupinfo.GroupManageUserID == US.userInfo.userid && _isdelete == false) {
- $(_el).remove(); //删除好友
- U.Json.del(US.friend.groupusers, { "GroupManageID": _friendinfo.GroupManageID, "UserId": _friendinfo.UserId }); //删除群指定的用户
- U.Json.del(U.MD.F.J.selectUserInfo.SelectUser, { "UserId": _friendinfo.UserId }); //删除群指定的用户
- U.alert('已将成员移除群聊');
- }
- //自己退出群处理
- else {
- //移除群好友
- U.MD.F.W.delteFriendChat(_friendinfo.GroupManageID, _chatformel);
- $("#U_MD_F_H_ZLZ").find("[TID=\"" + _groupinfo.GroupManageID + "\"]").remove(); //删除群
- U.Json.del(US.friend.group, { "GroupManageID": _friendinfo.GroupManageID, "UserId": _friendinfo.UserId }); //删除群指定的用户
- //弹出群消息的弹窗
- if (_el) {
- _el = $(_el).Parent({ usform: "true" });
- _el.close();
- }
- U.alert('已退出群聊');
- }
- }
- /**
- * 选择联系人弹框
- *
- * @param {object} 添加进入的元素
- * @param {function} 添加的用户信息
- * @param {number} 0 新创群 1邀请好友
- */
- U.MD.F.J.selectFriendForm = function (cb, type, fileinfo, group) {
- //添加好友弹框调用,用户必须登录和已经加载了好友数据
- if (!U.MD.U.L.isLogin() && US.friend.friends) {
- var i, //用于循环所有的是否在群里的人
- _formel, //用于存储创建群选择好友的弹框
- _gel = $("#U_MD_F_RC_G_C")[0], //获取组元素
- _fel = $("#U_MD_F_RC_F_C")[0], //获取好友元素
- _elparent = $("#U_MD_F_RC")[0], //获取存放该元素的父级元素
- _clone = _elparent.cloneNode(true), //克隆元素
- _allfriendinfo = U.Json.select(US.friend.friends.concat([])), //所有的联系人
- _addfriendinfo = U.MD.F.J.selectUserInfo, //选择用户的信息
- _selectfriend = _addfriendinfo.SelectUser, //添加好友信息
- _clickEl = $('#U_MD_F_RC_Friend')[0],
- _groupEl = $('#U_MD_F_RC_Group')[0],
- _joinEl = $('#U_MD_F_RC_Join')[0]
- if (group == 1) {
- //已经在群里的就不添加了
- for (i = 0; i < _selectfriend.length; i++) {
- U.Json.del(_allfriendinfo, { "UserId": _selectfriend[i].UserId }); //删除所有在群里的用户id
- }
- }
- //弹出创建群选择好友的框
- var _form = new U.UF.UI.form("选择联系人",
- _elparent,
- {
- "id": "U_MD_F_RC_O",
- "style": {
- "width": "480px",
- "height": "530px",
- "min-width": "480px"
- }
- },
- {
- isnarrow: false,
- isenlarge: false
- });
- //_formel = _form.form;
- _addfriendinfo.CallBack = cb; //回调函数
- if (US.friend.friends.length) {
- //打印可以选择的联系人
- if (!type || type == 'friend') {
- U.MD.F.J.printSelectFriend(_fel, _allfriendinfo, _elparent);
- _clickEl.onclick = function () {
- _clickEl = U.MD.F.J.alterNately($(_elparent).find('#U_MD_F_RC_F_C')[0], $(_elparent).find('#U_MD_F_RC_G_C')[0], _elparent, _clickEl, this)
- }
- }
- //打印可以选择的群
- if (!type || type == 'group') {
- U.MD.F.J.printSelectGroupUser(_gel, US.friend.group, _elparent);
- _groupEl.onclick = function () {
- _clickEl = U.MD.F.J.alterNately($(_elparent).find('#U_MD_F_RC_G_C')[0], $(_elparent).find('#U_MD_F_RC_F_C')[0], _elparent, _clickEl, this)
- }
- }
- if (type == 'friend' || type == 'group') {
- _clickEl.style.display = 'none';
- _groupEl.style.display = 'none';
- } else {
- _clickEl.style.display = 'block';
- _groupEl.style.display = 'block';
- }
- } else {
- _clickEl.style.display = 'none';
- _groupEl.style.display = 'none';
- _joinEl.style.display = 'block';
- $('.U_MD_F_RC_Join_btn')[0].onclick = function () {
- var _input = $$('input', {}, _joinEl),
- _fileType = fileinfo.UserDirectoryExtendType == 'uw' ? 'word' : 'execl';
- _input.value = "/" + _fileType + '/join/' + fileinfo.UserDirectoryID;
- _input.select();
- document.execCommand("Copy");
- $(_input).remove();
- U.Alert('复制成功,赶快分享给小伙伴吧!');
- }
- }
- _addfriendinfo.NeedUser = [];
- _elparent.parentNode.style.backgroundColor = "#f3f3f3"
- $(_elparent)[0].style.display = "block"; //显示出添加好友的信息
- $("#U_MD_Home")[0].appendChild(_clone); //把克隆的元素打印出来
- return _formel; //返回窗体元素
- }
- }
- /**
- * 打印可以添加的用户
- *
- * @param {object} 添加联系人的元素
- * @param {function} 选择的好友
- */
- U.MD.F.J.printSelectFriend = function (el, friendinfo, boxele) {
- var i, //用于循环所有联系人打印
- _tempel, //用于创建元素
- _temponeel, //用于创建元素
- _frag = $$("frag"); //创建新的元素
- //联系人打印,循环所有还有信息的长度
- for (i = 0; i < friendinfo.length; i++) {
- _tempel = $$("div",
- {
- "className": "U_MD_F_RC_CO",
- "FID": friendinfo[i].UserId,
- "onclick": U.UF.C.closure(function (firendinfo) {
- U.MD.F.J.clickSelectFriend(this, firendinfo); //选择后的点击事件
- U.MD.F.J.showChoose(firendinfo, $(this).find('.U_MD_F_RC_COC ')[0], boxele, 'friend')
- }, [friendinfo[i]])
- },
- _frag);
- $$("div", { "className": "U_MD_F_RC_COI U_Img" }, _tempel); //创建元素
- _temponeel = $$("div", { "className": "U_MD_F_RC_COC U_MD_D_Text_Abbreviation" }, _tempel); //创建元素
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "onclick": function (n) {
- return function () {
- U.UF.EV.stopBubble(); //阻止冒泡时间
- U.MD.U.V.ViewOtherUserInfo(friendinfo[n].UserId); //打印个人用户信息
- }
- }(i),
- "src": U.MD.C.getHeadImage(friendinfo[i].UserThumbnailImageHead), //获取好友头像img
- "alt": friendinfo[i].FriendsDescript//获取好友描述
- },
- _temponeel);
- $$("div", { "className": "U_MD_F_RC_COCN", "innerHTML": friendinfo[i].UserNickName }, _temponeel); //创建元素,获取好友用户名
- }
- //显示到框
- el.innerHTML = ""; //清空数据
- el.appendChild(_frag); //获取所有的打印的用户到显示框内
- }
- /**
- * 打印可以添加的群用户
- *
- * @param {object} 添加联系人的元素
- * @param {function} 选择的好友
- */
- U.MD.F.J.printSelectGroupUser = function (el, groupinfo, boxele) {
- var i, //获取循环的元素
- _tempel, //创建元素
- _temponeel, //创建元素
- _frag = $$("frag"); //创建元素的父级元素
- //循环打印,循环所有群信息的长度
- for (i = 0; i < groupinfo.length; i++) {
- _tempel = $$("div",
- {
- "className": "U_MD_F_RC_CO",
- "FID": groupinfo[i].GroupManageID, //fid为群的群id
- "onclick": function (n) {
- return function () {
- U.MD.F.J.showChoose(firendinfo, $(this).find('.U_MD_F_RC_COC ')[0], boxele, 'group', this)
- U.MD.F.J.clickSelectGroup(this, groupinfo[n]); //选择群后的点击事件
- }
- }(i)
- }, _frag);
- $$("div", { "className": "U_MD_F_RC_COI U_Img" }, _tempel); //创建元素
- _temponeel = $$("div", { "className": "U_MD_F_RC_COC U_MD_D_Text_Abbreviation" }, _tempel); //创建元素
- $$("img",
- {
- "title": "点击查看",
- "onclick": function (n) {
- return function () {
- U.UF.EV.stopBubble(); //阻止冒泡事件
- U.MD.U.V.GroupInfo(groupinfo[n]); //打印群的所有信息
- }
- }(i),
- "src": "/img/chatgroup.png"//显示群的群头像
- }, _temponeel);
- $$("div", { "className": "U_MD_F_RC_COCN", "innerHTML": groupinfo[i].GroupManageName }, _temponeel); //获取群的群名
- }
- el.appendChild(_frag); //打印群信息
- }
- /**
- * 搜索联系人
- *
- * @param {object} 用户信息
- */
- U.MD.F.J.searchSelectFriend = function (groupinfo) {
- var _searchel = $("#U_MD_F_RC_C")[0],
- _UDTD = $("div@FID=" + groupinfo.UserId)[0]; //获取选中的添加的元素
- if (_UDTD) {
- _UDTD.onclick();
- U.UF.EV.scrollToPosition(_UDTD); //滚动到指定的位置
- }
- else { U.alert("好友已经添加到群组里~"); }
- }
- /**
- * 选择添加后的效果
- *
- * @param {element} 添加好友的元素
- * @param {object} 好友信息
- */
- U.MD.F.J.clickSelectFriend = function (el, friendinfo) {
- var _selectel = $("div", el)[0]; //选择的元素
- //如果元素没有给选择,那么点击选择
- if (_selectel.className == "U_MD_F_RC_COI U_Img") {
- _selectel.className += " U_MD_F_RC_COIO"; //设置点击后的效果样式
- U.MD.F.J.selectUserInfo.NeedUser.push(friendinfo); //最后需要添加的用户
- }
- //如果元素已经是选择的状态,那么点击后则取消选择
- else {
- _selectel.className = "U_MD_F_RC_COI U_Img"; //设置点击后的效果样式
- U.Json.del(U.MD.F.J.selectUserInfo.NeedUser, { "UserId": friendinfo.UserId }); //删除最后需要添加的用户
- }
- }
- /**
- * 选择添加群后的效果
- *
- * @param {element} 添加群的元素
- * @param {object} 群的信息 U.Json()
- */
- U.MD.F.J.clickSelectGroup = function (el, groupinfo) {
- var i,
- _selectel = $("div", el)[0], //点击的元素
- _needuser = U.MD.F.J.selectUserInfo.NeedUser, //最后需要添加的用户
- _groupuser = U.Json.select(US.friend.groupusers, { "GroupManageID": groupinfo.GroupManageID }); //选择群里所有的群用户
- //如果元素没有给选择,那么点击选择
- if (_selectel.className == "U_MD_F_RC_COI U_Img") {
- _selectel.className += " U_MD_F_RC_COIO"; //设置点击后的效果样式
- _needuser = _needuser.concat(_groupuser); //把群用户添加到需要添加的用户集合里
- }
- //如果元素已经是选择的状态,那么点击后则取消选择
- else { //添加删除效果
- _selectel.className = "U_MD_F_RC_COI U_Img"; //设置点击后的效果样式
- //移除群里的每一个用户
- for (i = 0; i < _groupuser.length; i++) {
- U.Json.del(_needuser, { "UserId": _groupuser[i].UserId });
- }
- }
- }
- /**
- * 创建群取消按钮
- *
- * @param {element} 添加好友窗体
- */
- U.MD.F.J.closeSelectFriendForm = function (el) {
- U.UF.F.closeWindow($(el).Parent({ usform: "true" }), "remove"); //移除创建群的弹窗
- }
- /**
- * 确定添加按钮
- *
- * @param {element} 添加好友窗体
- */
- U.MD.F.J.determineSelectFriend = function (el) {
- var _selectuserinfo = U.MD.F.J.selectUserInfo, //获取所有选择信息
- _groupid = $(el).find('.U_MD_F_RC_COIO')[0] && $(el).find('.U_MD_F_RC_COIO')[0].parentNode.getAttribute('fid');
- _groupid = U.Json.select(US.friend.group, { "GroupManageID": _groupid })[0] ? _groupid : false;
- //回调函数处理
- if (_selectuserinfo.CallBack) {
- _selectuserinfo.CallBack(_groupid);
- _selectuserinfo.CallBack = null;
- }
- U.UF.F.closeWindow(el, "remove"); //取消窗口
- }
- /**
- * 显示输入文档名对话框
- *
- */
- U.MD.F.J.inputDocName = function () {
- var _confirmEl = $('#U_UF_UI_confirm')
- U.UF.F.topWindow(_confirmEl[0])
- $(_confirmEl).find('#U_MD_DK_RE_localDoc')[0].click()
- }
- /**
- * 确定添加按钮
- * 点击好友添加确定按钮,去数据库创建一个群
- * @param {element} 添加好友窗体
- * @param {string} 群id
- * @param {boolean} 是否是新建
- */
- U.MD.F.J.determineCreateGroupAndAddGroupUser = function (groupid, el, chatel, update, groupname, groupdescript, cb) {
- var i,
- _groupinfo, //群信息
- _inputs = $("input,textarea", el), //输入的群信息
- _adduserinfo = U.MD.F.J.selectUserInfo.NeedUser, //需要添加用户的集合
- _userid = US.userInfo.userid, //用户的id
- _groupname = groupname == undefined ? _inputs[0].value : groupname, //创建的群名
- _groupdescript = groupdescript == undefined ? _inputs[1].value : groupdescript, //创建的群描述
- _groupuserids = U.Json.toKeyArray(_adduserinfo, "UserId").join(",") //添加进入群所有好友的id
- ;
- //如果群不存在则创建
- if (!groupid) {
- if (_groupname == "") {
- for (var i = 0; i < _adduserinfo.length; i++) {
- _groupname = _groupname + "、" + _adduserinfo[i].UserNickName;
- }
- _groupname = _groupname + "、" + US.userInfo.UserNickName;
- _groupname = _groupname.substr(1, _groupname.length);
- }
- groupid = Guid.newGuid(); //新建一个群id
- _groupinfo = new U.MD.F.T.groupEntity(groupid, _groupname, new Date(), _userid, _groupdescript, null); //添加群实体
- //获取创建群后,拉进群用户里包括自己
- _adduserinfo.push(US.userInfo);
- if (_groupuserids) {
- _groupuserids = _userid + "," + _groupuserids;
- } else {
- _groupuserids = _userid;
- }
- //关闭弹框
- U.UF.F.closeWindow($(el).Parent({ usform: "true" }), "remove");
- }
- //群存在操作
- else {
- _groupinfo = U.Json.select(US.friend.group, { "GroupManageID": groupid })[0]; //获取群
- }
- // _adduserinfo = _adduserinfo.splice(0, _adduserinfo.length); //移除全局变量,把需要添加的用户删除
- //创建群成员,给每个群成员发送一条建立群给拉入群的消息
- U.A.Request(US.FRIEND, ["CreateGroupAndAddUser", _userid, groupid, _groupname, _groupdescript, _groupuserids],
- U.MD.F.J.asynDetermineCreateGroupAndAddGroupUser, ["", _groupinfo, _adduserinfo, groupid, _groupname, _groupdescript, el, chatel, _groupuserids, update, cb]); //添加到数据库
- }
- /**
- * 异步创建群
- * @param {object} 服务器返回的值
- */
- U.MD.F.J.asynDetermineCreateGroupAndAddGroupUser = function (r) {
- var i,
- _alert,
- _context = r.context, //回调函数的值
- _directory,
- _groupuser,
- _userinfo = US.userInfo, //回调的用户信息
- _diskinfo = US.disk.Disks[_userinfo.UserId],
- _groupinfo = _context[1], //当前群信息
- _groupuserinfo = _context[2], //用户信息集合
- _groupid = _context[3], //群id
- _groupname = _context[4], //群名
- _groupdescript = _context[5], //群描述
- _el = _context[6],
- _chatel = _context[7],
- _groupuserids = _context[8].split(','),
- _update = _context[9],
- _cb = _context[10]
- ;
- r = r.value; //获取服务器的返回值
- //创建群或者修改群成功o
- if (r !== false) {
- //如果新建的群不存在全局变量中,则新建一个
- if (!U.Json.select(US.friend.group, { "GroupManageID": _groupid })[0]) {
- US.friend.group.unshift(_groupinfo); //把群插入全局变量中
- var _directory = new U.MD.DK.M.entity(_groupinfo.GroupManageID, 0, null, _groupinfo.GroupManageName, _groupinfo.GroupManageName,
- "folder", null, new Date(), U.MD.DK.C.getIcon("folder")[1], 1, null, null, 0, "", _groupinfo.GroupManageID);
- _diskinfo && U.MD.DK.RE.addFileOrFolder([_directory], _diskinfo, _diskinfo.directoryOrFiles[1]) //添加文件或者文件夹
- _alert = "群" + _groupname + "已创建成功";
- }
- //如果群已经存在了,那么修改群名和群描述
- else {
- var _rightname = $('.U_MD_F_H_ZLZOCO[tid="0d3a87bf-40a1-9a77-3d5f-152032a9ddf0"]').find('.U_MD_F_H_ZLZOCORN')[0];
- var _rightdesc = $('.U_MD_F_H_ZLZOCO[tid="0d3a87bf-40a1-9a77-3d5f-152032a9ddf0"]').find('.U_MD_F_H_ZLZOCORT')[0];
- var _headname = $(_chatel).find('.U_MD_F_HTN')[0];
- var _headdesc = $(_chatel).find('.U_MD_F_HTC')[0];
- if (_rightname) {
- _rightname.innerHTML = _groupname;
- _rightdesc.innerHTML = _groupdescript
- }
- if (_headname) {
- _headname.innerHTML = _groupname;
- $('.U_MD_F_TOT')[0].childNodes[1].innerHTML = _groupname;
- _headdesc.innerHTML = _groupdescript
- }
- _groupinfo.GroupManageName = _groupname; //群名
- _groupinfo.GroupManageDescript = _groupdescript; //群描述
- _alert = "群资料已修改成功";
- }
- //把群的用户添加到群用户数组里
- if (_groupuserinfo.length) {
- for (i = 0; i < _groupuserinfo.length; i++) {
- _groupuser = new U.MD.F.T.groupUserEntity(_groupuserinfo[i].UserId, U.MD.C.getHeadImage(_groupuserinfo[i].UserImageHead),
- _groupuserinfo[i].UserNickName || _groupuserinfo[i].UserName, _groupuserinfo[i].UserName, U.MD.C.getHeadImage(_groupuserinfo[i].UserThumbnailImageHead),
- _groupuserinfo[i].GroupUsersDescript || _groupuserinfo[i].UserNickName, _groupid, 1); //新建一个群用户
- US.friend.groupusers.push(_groupuser); //添加到群用户里
- U.MD.F.J.selectUserInfo.SelectUser.push(_groupuser);
- }
- _alert = "成功邀请" + _groupuserinfo.length + "名好友加入群聊";
- }
- //创建群成功后,直接点击查看群。
- // if (_update) {
- // var _userinfo, _userinfos = [];
- // for (i = 0; i < _groupuserids.length; i++) {
- // _userinfo = U.Json.select(US.friend.friends, { UserId: _groupuserids[i] })[0];
- // if (_userinfo) {
- // _userinfos.push(_userinfo);
- // }
- // }
- // U.MD.F.J.printGroupUserInfo($(_el).next()[0], _userinfos, _groupinfo); //打印选择好友
- // }
- if (_cb) {
- _cb(_groupid, r);
- }
- //切换群聊按钮
- $($("#U_MD_F_H_ZLTA").Child()[1]).Child()[0].onclick();
- //聊天界面自动切换新创群
- $("#U_MD_F_H_ZLZ").Child()[0].onclick();
- //自动弹出群聊信息
- $(".U_MD_F_TI.U_Img")[0].onclick();
- //提示语
- U.alert(_alert);
- }
- //创建失败的提示
- else {
- U.alert("服务器繁忙,请从新创建!!");
- }
- if (!_update && _el) {
- U.UF.F.closeWindow($(_el).Parent({ usform: "true" }), "remove");
- }
- // _groupuserinfo = _groupuserinfo.splice(0, _groupuserinfo.length); //移除全局变量,把需要添加的用户删除
- }
- /*
- * 弹框询问用户是否创建这个群
- * @param groupid 群的id
- * @param groupname 群名
- * @param groups 群的描述
- * @param fileid 文件id
- * @param cb 回调函数 点击确定后的回调函数
- */
- U.MD.F.J.isCreateGroup = function (groupid, groupname, groupds, fileid, cb) {
- _isgroup = U.Json.select(US.friend.group, { "GroupManageID": groupid })[0]; //判断群是否已经存在在列表中
- //判断是否存在这个群
- if (!_isgroup) {
- var _elparent = $$("div", {}); //创建父级元素
- var _elcontent = $$("div",
- {
- "className": "U_MD_F_A_T",
- "innerHTML": "您的文档将移至新建群里(" + groupds + "),是否新建群组?"
- }, //创建弹窗内容
- _elparent);
- var _elall = $$("div",
- {
- "className": "U_MD_F_A_T_All"
- }, //创建信息父级元素
- _elparent);
- var _elbutton = $$("div",
- {
- "className": "U_MD_F_A_T_OFF",
- "innerHTML": "取消"
- }, //取消按钮
- _elall);
- $$("div",
- {
- "className": "U_MD_F_A_T_OUT",
- "innerHTML": "确认",
- "onclick": function () {
- U.MD.F.J.changeInfo(groupid, groupname, groupds, fileid, cb); //点击确定后的点击事件
- }
- }, //确定按钮
- _elall);
- _elbutton.onclick = function () {
- $("#U_MD_D_emp_CK")[0].close()
- } //点击取消按钮后关闭窗口
- new U.UF.UI.form("提示",
- _elparent,
- {
- "id": "U_MD_D_emp_CK",
- "style": {
- "width": "250px",
- "height": "170px"
- }
- },
- {
- istop: true,
- isdrag: false,
- isnarrow: false,
- isenlarge: false
- }).form;
- } else {
- U.MD.F.J.changeInfo(groupid, groupname, groupds, fileid, cb)//判断群存在时,默认执行点击确定后的点击事件
- }
- }
- /*
- * 获取所选择的联系人,发送消息
- * @param groupid 群id
- * @param grouopname 群名
- * @param groupds 群描述
- * @param fileid 文件id
- * @param cb 回调函数
- */
- U.MD.F.J.changeInfo = function (groupid, groupname, groupds, fileid, cb) {
- var i, _isgroup,
- // _UCB = U.MD.F.J.asynDetermineCreateGroupAndAddGroupUser, //创建群异步回调
- _groupsign = 1, //判断是否已经创建。如果没有创建,就把_UTF的值设置为0,0在存储过程的传参作用是创建群, 1是不创建直接修改群名
- _userid = US.userInfo.userid, //当前用户id 也是群主id
- _groupinfo = [groupname, groupds], //群名和群描述的数组 [0]群名 [1]群描述
- _groupfriend = U.MD.F.J.selectUserInfo.NeedUser, //需要添加用户的集合(群用户)
- _grouparr = new Array(); //创建一个新的数组
- //循环所有需要添加用户的集合
- for (var i = 0; i < _groupfriend.length; i++) {
- var pd = 0;
- //循环群数组里是否有内容
- for (var u = 0; u < _grouparr.length; u++) {
- if (_grouparr[u].UserId == _groupfriend[i].UserId || _groupfriend[i].UserId == US.userInfo.userid) {//判断群数组是否存有需要添加到群的用户
- pd++
- }
- }
- if (pd == 0) {
- _grouparr.push(_groupfriend[i]); //把需要添加的用户信息存入数组中
- }
- }
- _frienduser = U.Json.toKeyArray(_grouparr, "UserId").join(","), //用,分割群用户的id 例: userid,userid
- _useridarr = U.Json.toKeyArray(_grouparr, "UserId").join(","); //用,分割群用户的id 例: userid,userid
- _isgroup = U.Json.select(US.friend.group, { "GroupManageID": groupid })[0]; //判断群是否已经存在在列表中
- if (!_isgroup) { //判断群是否存在
- _groupsign = 0;
- groupid = groupid || Guid.newGuid(); //没有群id创建一个群id
- //创建群的实体,主要是用于添加到US.friend[2]这个群集合里面
- _isgroup = new U.MD.F.T.groupEntity((groupid = groupid || Guid.newGuid()), _groupinfo[0], new Date(), _userid, _groupinfo[1], null); //拼接群用户id 把本人也添加到这个群里
- //判断是否有分割群用户的id,如果有,就拼接起来
- if (_useridarr) {
- _useridarr = _userid + "," + _useridarr
- } else { //如果没有,就直接添加
- _useridarr = _userid + "" + _useridarr
- }
- }
- // _groupfriend.splice(0, _groupfriend.length); //添加成功后移除用户
- //创建群成员,给每个群成员发送一条建立群给拉入群的消息
- U.A.Request(US.FRIEND, ["CreateGroupAndAddUser", _userid, groupid, _groupinfo[0], _groupinfo[1], _useridarr], U.MD.F.J.asynChangeInfo, ["", _isgroup, _grouparr.splice(0, _grouparr.length), groupid, _groupinfo[0], _groupinfo[1], cb, _frienduser, groupid, _groupinfo[0]]); //添加到数据库
- // U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "CreateGroupAndAddUser", _userid, _groupinfo[0], _groupinfo[1], groupid, _useridarr, _groupsign], U.MD.F.J.asynChangeInfo, ["", _isgroup, _grouparr.splice(0, _grouparr.length), groupid, _groupinfo[0], _groupinfo[1], cb, _frienduser, groupid, _groupinfo[0]]); //添加到数据库
- //给每个群成员发送一条有关于这个uw文件的消息
- // U.A.Request(US.CD, ([US.DB, "UseStudio_Friends", "SentMessageToFriend", US.userInfo.userid, _frienduser, US.userInfo.UserNickName || US.userInfo.username, '' + groupid + ',' + _groupinfo[0] + ',' + _isgroup.GroupManageCreateDate + ',' + fileid + ',' + _isgroup.GroupManageName + '.UW', 5, false]), function(){}, [""]);
- $("#U_MD_D_emp_CK").hide()//隐藏元素
- }
- /**
- * 确定添加按钮
- *点击好友添加确定按钮,去数据库创建一个群
- * @param {object} 添加好友窗体
- */
- U.MD.F.J.asynChangeInfo = function (r) {
- U.MD.F.J.asynDetermineCreateGroupAndAddGroupUser(r); //回调原本创建群的流程函数 这里地方不调用的话 会导致原本在好友聊天中创建群成员和群用不了
- var _context = r.context; //获取信息
- _context[6](_context[1], _context[7], _context[8], _context[9]); //回调群id
- }
- /**
- * 无认证直接加入群
- *
- * @param {object} 群信息
- * @param {function} 群id
- */
- U.MD.F.J.addUsersToGroup = function (groupinfo, cb) {
- if (!U.MD.U.L.isLogin()) {//判断是否登录
- var _userinfo = US.userInfo, //用户信息表
- _userid = _userinfo.UserId, //用户id
- _groups = US.friend.group, //用户群
- _group = U.Json.select(_groups, { "GroupManageID": groupinfo.GroupManageID })[0]; //用户群
- //判断用户是否已经加入群组
- if (!_group) {
- U.alert("正在加入,请稍等..");
- //加入群组处理
- U.A.Request(US.FRIEND, ["AddUsersToGroup", US.userInfo.userid, groupinfo.GroupManageID, _userid], U.MD.F.J.asynAddUsersToGroup, ["", { MessageContent: groupinfo.GroupManageID, MessageDescript: groupinfo.GroupManageName, UserId: groupinfo.UserId },]);
- }
- //否则直接查看群消息
- else {
- if (cb) {
- cb();
- }
- else { U.MD.F.W.viewFriend(_group); }
- }
- }
- }
- //用户直接进入群异步
- U.MD.F.J.asynAddUsersToGroup = function (r) {
- var _context = r.context,
- _cb = _context[2], //回调函数
- _userid = US.userInfo.userid, //用户id
- _diskinfo = US.disk.Disks[_userid], //网盘信息
- _groupinfo = U.MD.F.N.asynPulledIntoGroups(r); //添加群文件
- //回调函数处理
- if (_cb) {
- U.UF.C.apply(this, _cb)();
- }
- //查看用户信息
- else {
- U.MD.F.W.viewFriend(_groupinfo);
- }
- U.alert("成功加入该群");
- }
- //#endregion
- /**
- * 弹出好友添加使用
- *
- * @param {object} 群信息
- */
- U.MD.F.J.addPopup = function () {
- var _el;
- _el = $$("div", { "className": "U_MD_F_A" });
- $$("div", { "className": "U_MD_F_RA", "onclick": U.MD.F.M.createFriendGroupPopup, "innerHTML": "添加分组" }, _el); //添加分组按钮
- $$("div", { "className": "U_MD_F_RA_E", "onclick": "U.MD.F.S.popSearchFriendsOrGroupForm(0);", "innerHTML": "添加/<br>查找好友" }, _el); //查找好友
- $$("div", { "className": "U_MD_F_RA", "onclick": "U.MD.F.S.popSearchFriendsOrGroupForm(1)", "innerHTML": "加入群组" }, _el); //加入群聊 U.MD.F.S.popupsSearchGroups
- $$("div", { "className": "U_MD_F_RA", "onclick": "U.MD.F.J.groupInfoForm();", "innerHTML": "创建群组" }, _el); //创建群聊
- new U.UF.UI.form("添加好友/群聊", _el, { 'id': 'U_MD_F_addFriendorGroup', "style": { "width": "390px", "height": "220px" } }, { isenlarge: false, });
- };
- /**
- *
- * @param el 准备隐藏的元素
- * @param nel 准备显示的元素
- * @param elparent 准备隐藏的元素的父亲元素
- * @param clickel 上一次点击的元素
- * @param thisel 点击的元素
- * @returns {*} 返回这次点击的元素
- */
- U.MD.F.J.alterNately = function (el, nel, elparent, clickel, thisel) {
- if (thisel != clickel) {
- nel.style.display = 'none';
- nel.previousElementSibling.children[0].src = "/img/arrowR.png";
- var con = $(nel).find('.U_MD_F_RC_COIO');
- for (var i = 0; i < con.length; i++) {
- con[i].className = "U_MD_F_RC_COI U_Img"
- }
- U.MD.F.J.selectUserInfo.NeedUser = [];
- $(elparent).find('.U_MD_F_RC_C_C')[0].innerHTML = "";
- $(elparent).find('.U_MD_F_RC_C_T')[0].innerText = 0;
- }
- if (el.style.display == 'none') {
- el.style.display = 'block';
- el.previousElementSibling.children[0].src = "/img/arrowB.png";
- } else {
- el.style.display = 'none';
- el.previousElementSibling.children[0].src = "/img/arrowR.png";
- }
- return thisel
- }
- /**
- * 选择联系人选择功能
- * @param el 用户信息元素
- * @param boxele 选择联系人大元素
- * @param type 点击的类型 分为'group'和'friend'
- * @param cthis 选中的元素
- */
- U.MD.F.J.showChoose = function (firendinfo, el, boxele, type, cthis) {
- var _fel = $($(boxele).find('.U_MD_F_RC_C_C')[0]).find("div[fid='" + $(el.parentNode).attr('fid') + "']")[0],
- _leftShowEl = $(boxele).find('.U_MD_F_RC_C_C')[0],
- _cNam = cthis && $(cthis.parentNode).find('.U_MD_F_RC_COIO') || []
- if (_cNam.length && _cNam[0].parentNode.getAttribute('fid') != $(cthis).attr('fid')) {
- var _delElFid = $($(_cNam)[0].parentNode).attr('fid')
- _cNam[0].className = _cNam[0].className.replace(' U_MD_F_RC_COIO', '');
- $($(boxele).find("div[fid='" + _delElFid + "']")[1]).remove()
- U.MD.F.J.selectUserInfo.NeedUser = []
- }
- if (!_fel) {
- var addel = $$('div', { className: "U_MD_F_RC_C_C_A", fid: $(el.parentNode).attr('fid') });
- $$('img', { "onerror": U.MD.C.imgError, src: el.firstElementChild.src }, addel);
- $$('span', { innerText: el.lastElementChild.innerText }, addel)
- addel.onclick = function () {
- U.MD.F.J.clearDefaultStyle();
- addel.className += " U_MD_F_A_AddNewGrouper";
- $$("div", {
- "id": "U_MD_F_A_XX",
- "style": {
- "width": "19px",
- "height": "19px",
- "background-image": "url('/img/YS2017.png')",
- "display": "inline-block",
- "background-repeat": "no-repeat",
- "background-position": "-984px -407px",
- "float": "right",
- "margin": "12px",
- "cursor": "pointer"
- },
- "onclick": function () {
- U.MD.F.J.xxClick(this, firendinfo, boxele);
- }
- }, addel);
- }
- if (type == "friend") {
- $(boxele).find('.U_MD_F_RC_C_C')[0].appendChild(addel);
- } else if (type == "group") {
- _leftShowEl.innerHTML = "";
- if (!cthis.firstChild.className.match('U_MD_F_RC_COIO')) {
- var _groupFid = $(el.parentNode).attr('fid'),
- _groupFriends = U.Json.select(US.friend.groupusers, { "GroupManageID": _groupFid })
- _newEl = $$('div');
- for (var i = 0; i < _groupFriends.length; i++) {
- var _cloneEl = addel.cloneNode(true);
- _cloneEl.setAttribute('fid', _groupFriends[i].UserId)
- _cloneEl.fid = _groupFriends[i].UserId;
- _cloneEl.firstChild.src = U.MD.C.getHeadImage(_groupFriends[i].UserImageHead) || "/img/UserHead/UseHead.jpg";
- _cloneEl.lastChild.innerText = _groupFriends[i].UserName;
- _newEl.appendChild(_cloneEl);
- }
- _leftShowEl.appendChild(_newEl);
- U.MD.F.J.selectUserInfo.NeedUser = _groupFriends;
- }
- $(boxele).find('.U_MD_F_RC_C_T')[0].innerText = _leftShowEl.children[0] ? _leftShowEl.children[0].children.length : 0;
- return;
- }
- } else {
- $(_fel).remove()
- }
- U.MD.F.J.clearDefaultStyle();
- var _lastChild = $(".U_MD_F_RC_C_C.U_MD_F_RC_C")[1].lastChild;
- _lastChild.className += " U_MD_F_A_AddNewGrouper";
- $$("div", {
- "id": "U_MD_F_A_XX",
- "style": {
- "width": "19px",
- "height": "19px",
- "background-image": "url('/img/YS2017.png')",
- "display": "inline-block",
- "background-repeat": "no-repeat",
- "background-position": "-984px -407px",
- "float": "right",
- "margin": "12px"
- },
- "onclick": function () {
- U.MD.F.J.xxClick(this, firendinfo, boxele);
- }
- }, _lastChild);
- $(boxele).find('.U_MD_F_RC_C_T')[0].innerText = _leftShowEl.children.length;
- }
- U.MD.F.J.clearDefaultStyle = function () {
- var targerList = $(".U_MD_F_RC_C_C.U_MD_F_RC_C")[1].children
- for (var i = 0; i < targerList.length; i++) {
- targerList[i].className = "U_MD_F_RC_C_C_A";
- $("#U_MD_F_A_XX")[0] ? $("#U_MD_F_A_XX")[0].remove() : "";
- };
- }
- U.MD.F.J.xxClick = function (div, firendinfo, boxele) {
- window.event ? window.event.cancelBubble = true : e.stopPropagation();
- var _fid = div.parentNode.fid;
- U.Json.del(U.MD.F.J.selectUserInfo.NeedUser, { "UserId": firendinfo.UserId });
- div.parentNode.remove();
- $(boxele).find('.U_MD_F_RC_C_T')[0].innerText = $(boxele).find('.U_MD_F_RC_C_C')[0].children.length;
- var _list = $(".U_MD_F_RC_CO");
- for (var x = 0; x < _list.length; x++) {
- if (_list[x].FID == _fid) {
- _list[x].children[0].className = "U_MD_F_RC_COI U_Img";
- }
- }
- }
|