123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754 |
- Namespace.register("U.F.J"); //好友加群加好友的命名空间
- //#region 创建群组
- //听见群用户的信息
- U.F.J.SelectUserInfo = {
- NeedUser: [], //需要添加的群用户
- SelectUser: [], //已经选择过的用户
- CallBack: null //添加后的回调
- };
- /**
- * 显示添加群窗口
- *
- * @param {object} 群信息
- * @param {element} 元素处理
- * @param {boolean}
- */
- U.F.J.GroupInfoForm = function (groupinfo) {
- var _formel, //窗体
- _groupuserinfo, //获取所有的群好友
- _determinebottom,
- _closebottom,
- _groupinfoel = $("#UD_SYA"), //添加群的窗体
- _addgroupuserel = $("#UD_SYTC")[0], //内容区域
- _groupinfochildsel = _groupinfoel.Child(), //群信息窗体子元素
- _inputel = $("input,textarea", _groupinfochildsel[0]), //内容输出
- _isgroupmain = !groupinfo && groupinfo.GroupManageCreateUserID == US.userInfo.userid //是否是新建群或者是群主,
- ;
- //清空群用户
- U.F.J.SelectUserInfo.NeedUser.splice(0, U.F.J.SelectUserInfo.NeedUser.length);
- //设置该联系人进入群
- _groupinfochildsel[1].innerHTML = "";
- //如果群存在的处理
- if (groupinfo) {
- //设置群名,群描述等
- _inputel[0].value = groupinfo.GroupManageName;
- _inputel[1].value = groupinfo.GroupManageDescript;
- //获取群用户的信息
- _groupuserinfo = _$(US.Friend[3]).Select({ "GroupManageID": groupinfo.GroupManageID });
- //设置已经选择过的用户
- U.F.J.SelectUserInfo.SelectUser = _groupuserinfo;
- //打印当前群的用户
- U.F.J.PrintGroupUserInfo(_groupinfochildsel[1], _groupuserinfo, groupinfo);
- //点击退出按钮事件设置
- $(_groupinfochildsel[2]).addAttrArray({
- "onclick": [[U.F.J.GroupExit, [groupinfo, _$(groupinfo).FindOne({ "UserId": US.userInfo.userid }), _groupinfoel]]],
- "innerHTML": _UTF ? "解散改群" : "退出该群"
- });
- }
- //创建新群,清空数据
- else {
- //设置群名,群描述等
- _inputel[0].value = "";
- _inputel[1].value = "";
- }
- //弹出窗体
- _formel = U.UI.Form({
- "min": false,
- "max": false,
- "id": "UD_SYAO",
- "style": { "width": "480px", "height": "" },
- "content": _groupinfoel[0],
- "title": "<div class='UD_SYF_STI'>添加群聊</div>",
- "hst": { style: { "padding": "0" } }
- });
- //确定添加群处理
- _determinebottom = $(_groupinfochildsel[3]).Child()[0];
- _determinebottom.onclick = U.M.apply(_determinebottom, [[U.F.J.DetermineCreateGroupAndAddGroupUser, [_groupinfochildsel[0], groupinfo.GroupManageID]]]);
- //确定取消群处理
- _closebottom = $(_groupinfochildsel[3]).Child()[1];
- _closebottom.onclick = U.M.apply(_formel, [[_formel.shut]]);
- //添加新用户进去群的窗体显示了,那么则重新点击刷新
- if (_addgroupuserel.style.display == "block") {
- U.F.J.SelectFriendForm();
- }
- return _formel;
- }
- /**
- * 显示添加群窗口
- *
- * @param {element} 添加进入的元素
- * @param {object} 添加的用户信息
- */
- U.F.J.PrintGroupUserInfo = function (el, groupuserinfo, groupinfo) {
- var i,
- //临时元素变量
- _tempel,
- _temponeel,
- _temptwoel,
- _frag = $$("frag"),
- _childsel = $(el).Child(),
- //判断是否是群主
- _isgroupmain = !groupuserinfo || groupinfo.GroupManageCreateUserID == US.userInfo.userid //判断是否是群主,或者是在新建群
- ;
- //打印群用户显示的样式
- for (i = 0; i < groupuserinfo.length; i++) { //循环添加
- _tempel = $$("div", { "className": "UD_SYACO" }, _frag);
- $$("img", {
- "onerror": U.M.ImgError, "title": "点击查看",
- "src": U.M.GetImgU(groupuserinfo[i].UserThumbnailImageHead)
- }, _tempel);
- $$("div", { "className": "UD_SYACOM UTDF", "style": { "width": "25%" }, "innerHTML": groupuserinfo[i].UserName }, _tempel);
- _temponeel = $$("div", { "className": "UD_SYACOM UTDF", "innerHTML": groupuserinfo[i].GroupUsersDescript || groupuserinfo[i].UserName }, _tempel);
- _temptwoel = $$("div", { "className": "UD_HERDUSER" + (_isgroupmain ? " UD_HERDUSERS" : "") }, _tempel);
- //这有已经新建的群
- if (groupinfo) {
- //只有本人或者群主才能修改群名片
- if (_isgroupmain || groupuserinfo[i].UserId == US.userInfo.userid) {
- $$("img", {
- "src": "/img/Edit.png", "title": "修改群名片",
- "onclick": [[U.F.J.UpateGroupUserDescriptForm, [groupuserinfo[i], _temponeel]]]
- }, _temptwoel);
- }
- $$("img", {
- "src": "/img/personalCard.png", "title": "查看用户资料",
- "onclick": [[U.U.I.ViewOtherUserInfo, [groupuserinfo[i].UserId]]]
- }, _temptwoel);
- $$("img", {
- "src": "/img/Add.png", "title": "添加好友",
- "onclick": [[U.F.M.AddFriend, [groupuserinfo[i], groupinfo, _tempel]]]
- }, _temptwoel);
- }
- //如果是群主有移除权限
- if (_isgroupmain) {
- $$("img", {
- "src": "/img/exit.png", "title": "移除",
- "onclick": [[U.F.J.GroupExit, [groupuserinfo[i], groupinfo, _tempel]]]
- }, _temptwoel);
- }
- }
- //判断元素是否存在,如果存在则,追加元素,如果不存在则添加到最后面
- if (_childsel.length) {
- el.insertBefore(_frag, _childsel[_childsel.length - 1]);
- }
- else {
- el.appendChild(_frag);
- }
- }
- /**
- * 显示添加群窗口
- *
- * @param {object} 群好友信息
- */
- U.F.J.UpateGroupUserDescriptForm = function (groupuserinfo, el) {
- var _tempel,
- _temponeel,
- _temptwoel,
- _groupname = groupuserinfo.GroupUsersDescript || groupuserinfo.UserName
- ;
- if (groupuserinfo) {
- //创建好友分组的样式
- _tempel = $$("div", { "className": "UD_SYSSZS UD_SYATNL UD_SYSOU" });
- _temponeel = $$("div", {}, _tempel)
- _temptwoel = $$("input", {
- "value": _groupname, "onfocus": [[U.MR.InputTip, ["this", [_groupname, ""]]]],
- "onblur": [[U.MR.InputTip, ["this", ["", _groupname]]]]
- }, _temponeel);
- //弹出好友对话框
- U.UI.Confirm("群备注修改", { "width": "300px" }, null, U.M.apply(null, [[U.F.J.DetermineUpateGroupUserDescript, [groupuserinfo, _temptwoel, el]]]),
- _tempel, $("#UD_SY")[0]);
- }
- else { U.Alert("暂无群信息"); }
- }
- /**
- * 弹出设置
- *
- * @param {object} 群好友信息
- */
- U.F.J.DetermineUpateGroupUserDescript = function (groupuserinfo, inputel, el) {
- //判断用户是否输入正确的备注名
- if (inputel.value && U.MS.NickName.test(inputel.value)) {
- U.A.Request(US.Auth, ["UpdateGroupMemberInfo", groupuserinfo.GroupManageID, US.userInfo.userid, inputel.value],
- U.F.J.AsynDetermineUpateGroupUserDescript, [null, groupuserinfo, inputel.value, el]);
- }
- else {
- U.Alert("备注名格式不对");
- return true;
- }
- }
- /**
- * 修改群备注
- *
- * @param {object} 群好友信息
- */
- U.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.F.J.GroupExit = function (groupinfo, userinfo, el) {
- var _userid = US.userInfo.userid, //用户id
- _isgroupmain = groupinfo.GroupManageCreateUserID == _userid //判断用户是否是群主
- ;
- //如果推出群的是群主处理
- if (_isgroupmain) {
- //如果群主自己推出,则解散群
- if (userInfo.userid == _userid) {
- U.UI.Confirm("是否解散该群", [U.F.J.EnterGroupExit, [groupinfo, userinfo, true, el]]); //创建提示框 提示是否删除备份
- }
- //否则则移除群好友
- else {
- U.UI.Confirm("是否移除该群用户", [U.F.J.EnterGroupExit, [groupinfo, userinfo, false, el]]); //创建提示框 提示是否删除备份
- }
- }
- //不是群主的处理
- else {
- U.UI.Confirm("是否确定退出该群", [U.F.J.EnterGroupExit, [groupinfo, userinfo, false, el]]); //创建提示框 提示是否删除备份
- }
- }
- /**
- * 移除群异步
- *
- * @param {object} 群信息
- * @param {object} 好友信息
- * @param {bool} 是否为删除群
- */
- U.F.J.EnterGroupExit = function (groupinfo, userinfo, isdelete, el) {
- if (isdelete === 1) {
- U.A.Request(US.Auth, ["DeleteGroup", groupinfo.GroupManageID], U.F.J.AsynGroupExit,
- ["", groupinfo, userinfo, isdelete, el]); //解散群
- }
- else {
- U.A.Request(US.Auth, ["ExitGroup", groupinfo.GroupManageID, userInfo.userid], U.F.J.AsynGroupExit,
- ["", groupinfo, userinfo, isdelete, el]);
- }
- }
- /**
- * 群移除异步
- *
- * @param {object} 群信息
- * @param {object} 好友信息
- * @param {bool} 是否为删除群
- */
- U.F.J.AsynGroupExit = function (r) {
- var context = r.context,
- _chatfrom,
- _groupinfo = context[1], //群信息
- _friendinfo = context[2], //自己在群里的信息
- _isdelete = context[3], //是解散群还是退出(移除)群用户
- _el = context[4]; //弹出的群窗体
- //删除群处理 或者退出群
- if (_isdelete) {
- //清空用户在群的数据
- _$(US.Friend[2]).Delete({ "GroupManageID": _friendinfo.GroupManageID }); //删除群
- _$(US.Friend[3]).Delete({ "GroupManageID": _friendinfo.GroupManageID }); //删除群用户
- //用户面板里是否存在用户,存在删除
- $("#UD_SYHZLZ").find("[TID=\"" + _groupinfo.GroupManageID + "\"]").remove(); //删除群
- //判断好友是否出现在聊天框里,如果是则移除聊天框
- _chatfrom = U.F.W.IsCreateForm(_friendinfo.GroupManageID)[0]; //
- if (U.F.W.IsCreateForm(_friendinfo.GroupManageID)[0]) {
- U.F.W.DelteFriendChat(_friendinfo.GroupManageID, _UDTD)
- }
- //弹出群消息的弹窗
- _el = $(_el).Parent({ usform: "true" });
- _el.close()
- }
- //删除好友处理
- else {
- $(_el).remove(); //移除群好友
- _$(US.Friend[2]).Delete({ "GroupManageID": _friendinfo.GroupManageID, "UserId": _friendinfo.UserId }); //删除群指定的用户
- }
- }
- /**
- * 选择联系人弹框
- *
- * @param {object} 添加进入的元素
- * @param {function} 添加的用户信息
- */
- U.F.J.SelectFriendForm = function (cb) {
- //添加好友弹框调用,用户必须登录和已经加载了好友数据
- if (!U.U.L.isLogin() && US.Friend[1]) {
- var i,
- _formel,
- _el = $("#UD_SYTC")[0],
- _allfriendinfo = _$(US.Friend[1].concat([])), //所有的联系人
- _addfriendinfo = U.F.J.SelectUserInfo, //选择用户的信息
- _selectfriend = _addfriendinfo.SelectUser; //添加好友信息
- //已经在群里的就不添加了
- for (i = 0; i < _selectfriend.length; i++) {
- _allfriendinfo.Delete({ "UserId": _selectfriend[i].UserId });
- }
- //打印可以选择的联系人
- U.F.J.PrintSelectFriend(el, _allfriendinfo.Value);
- //打印可以选择的群
- U.F.J.PrintSelectGroupUser(el, US.Friend[2]);
- //弹出创建群选择好友的框
- _formel = U.UI.Form({
- "min": false,
- "max": false,
- "id": "UD_SYTO",
- "style": { width: "250px", height: "480px" }, //弹框
- "content": $("#UD_SYT")[0],
- "title": "添加好友",
- "hst": { style: { "padding": "0 0 0 5px" } }
- });
- _addfriendinfo.CallBack = cb; //回调函数
- return _formel;
- }
- }
- /*
- 把群成员添加进 _UGE["CAD"]里面
- */
- U.F.J.ChanCAD = function (groupid) {
- var groupuser = _$(US.Friend[3]).Select({ "GroupManageID": groupid });
- var _UGE = U.D.SY.ET["UL"];
- _UGE["CAD"] = groupuser;
- }
- /**
- * 打印可以添加的用户
- *
- * @param {object} 添加联系人的元素
- * @param {function} 选择的好友
- */
- U.F.J.PrintSelectFriend = function (el, groupinfo) {
- var i,
- _tempel,
- _temponeel,
- _frag = $$("frag");
- //联系人打印
- for (i = 0; i < friendinfo.length; i++) {
- _tempel = $$("div", {
- "className": "UD_SYTCO", "FID": friendinfo[i].UserId,
- "onclick": [[U.F.J.ClickSelectFriend, ["this", friendinfo[i]]]]
- }, _frag);
- $$("div", { "className": "UD_SYTCOI UD_SYI" }, _tempel);
- _temponeel = $$("div", { "className": "UD_SYTCOC UTDF" }, _tempel);
- $$("img", {
- "onerror": U.M.ImgError, "title": "点击查看", "onclick": [[U.M.StopBubble], [U.U.I.ViewOtherUserInfo, [friendinfo[i].UserId]]],
- "src": U.M.GetImgU(friendinfo[i].UserThumbnailImageHead), "alt": friendinfo[i].FriendsDescript
- }, _temponeel);
- $$("div", { "className": "UD_SYTCOCN", "innerHTML": friendinfo[i].FriendsDescript }, _temponeel);
- }
- //显示到框
- el.innerHTML = "";
- el.appendChild(_frag);
- }
- /**
- * 打印可以添加的群用户
- *
- * @param {object} 添加联系人的元素
- * @param {function} 选择的好友
- */
- U.F.J.PrintSelectGroupUser = function (el, groupinfo) {
- var i,
- _tempel,
- _temponeel,
- _frag = $$("frag");
- //循环打印
- for (i = 0; i < groupinfo.length; i++) {
- _tempel = $$("div", {
- "className": "UD_SYTCO", "FID": groupinfo[i].GroupManageID,
- "onclick": [[U.F.J.ClickSelectGroup, ["this", groupinfo[i]]]]
- }, _frag);
- $$("div", { "className": "UD_SYTCOI UD_SYI" }, _tempel);
- _temponeel = $$("div", { "className": "UD_SYTCOC UTDF" }, _tempel);
- $$("img", {
- "title": "点击查看", "onclick": [[U.M.StopBubble], [U.U.I.ViewOtherUserInfo, [groupinfo[i].UserId]]],
- "src": "/img/chatgroup.png"
- }, _temponeel);
- $$("div", { "className": "UD_SYTCOCN", "innerHTML": groupinfo[i].GroupManageName }, _temponeel);
- }
- el.appendChild(_frag);
- }
- /**
- * 搜索联系人
- *
- * @param {object} 用户信息
- */
- U.F.J.SearchSelectFriend = function (groupinfo) {
- var _searchel = $("#UD_SYTC")[0],
- _UDTD = $("div@FID=" + groupinfo.UserId)[0]; //获取选中的添加的元素
- if (_UDTD) {
- _UDTD.onclick();
- U.M.SCT(_UDTD); //滚动到指定的位置
- }
- else { U.Alert("好友已经添加到群组里~"); }
- }
- /**
- * 选择添加后的效果
- *
- * @param {element} 添加好友的元素
- * @param {object} 好友信息
- */
- U.F.J.ClickSelectFriend = function (el, friendinfo) {
- var _selectel = $("div", el)[0]; //选择的元素
- //如果元素没有给选择,那么点击选择
- if (_selectel.className == "UD_SYTCOI UD_SYI") {
- _selectel.className += " UD_SYTCOIO"; //设置点击后的效果样式
- U.F.J.SelectUserInfo.NeedUser.push(friendinfo); //最后需要添加的用户
- }
- //如果元素已经是选择的状态,那么点击后则取消选择
- else {
- _selectel.className = "UD_SYTCOI UD_SYI"; //设置点击后的效果样式
- _$(U.F.J.SelectUserInfo.NeedUser).Delete({ "UserId": friendinfo.UserId }); //删除最后需要添加的用户
- }
- }
- /**
- * 选择添加群后的效果
- *
- * @param {element} 添加群的元素
- * @param {object} 群的信息 _$()
- */
- U.F.J.ClickSelectGroup = function (el, groupinfo) {
- var i,
- _selectel = $("div", el)[0], //点击的元素
- _needuser = U.F.J.SelectUserInfo.NeedUser, //最后需要添加的用户
- _groupuser = _$(US.Friend[3]).Select({ "GroupManageID": groupinfo.GroupManageID }); //选择群里所有的群用户
- //如果元素没有给选择,那么点击选择
- if (_selectel.className == "UD_SYTCOI UD_SYI") {
- _selectel.className += " UD_SYTCOIO"; //设置点击后的效果样式
- _needuser = _needuser.concat(_groupuser); //把群用户添加到需要添加的用户集合里
- }
- //如果元素已经是选择的状态,那么点击后则取消选择
- else { //添加删除效果
- _selectel.className = "UD_SYTCOI UD_SYI"; //设置点击后的效果样式
- //移除群里的每一个用户
- for (i = 0; i < _groupuser.length; i++) {
- _$(_needuser).Delete({ "UserId": _groupuser[i].UserId });
- }
- }
- }
- /**
- * 创建群取消按钮
- *
- * @param {element} 添加好友窗体
- */
- U.F.J.CloseSelectFriendForm = function (el) {
- U.D.CloseWindow($(el).Parent({ usform: "true" }));
- }
- /**
- * 确定添加按钮
- *
- * @param {element} 添加好友窗体
- */
- U.F.J.DetermineSelectFriend = function (el) {
- var _selectuserinfo = U.F.J.SelectUserInfo,
- _groupinfoel = $("#UD_SYAC"),
- _needuser = _selectuserinfo.NeedUser; //需要添加好友的集合
- //回调函数处理
- if (_selectuserinfo.CallBack) {
- _selectuserinfo.CallBack();
- _selectuserinfo.CallBack = null;
- }
- //普通添加群处理 在好友界面操作
- else {
- U.F.J.PrintGroupUserInfo(_groupinfoel[0], _needuser); //打印选择好友
- }
- _needuser.splice(0, _needuser.length);
- U.D.CloseWindow(el); //取消窗口
- }
- /**
- * 确定添加按钮
- * 点击好友添加确定按钮,去数据库创建一个群
- * @param {element} 添加好友窗体
- * @param {string} 群id
- * @param {boolean} 是否是新建
- */
- U.F.J.DetermineCreateGroupAndAddGroupUser = function (el, groupid) {
- var i,
- _groupinfo, //群信息
- _inputs = $("input,textarea", el), //输入的群信息
- _adduserinfo = U.F.J.SelectUserInfo.NeedUser, //需要添加用户的集合
- _userid = US.userInfo.userid, //用户的id
- _groupname = _inputs[0].value, //创建的群名
- _groupdescript = _inputs[1].value, //创建的群描述
- _groupuserids = _$(_adduserinfo).pluck("UserId").join(",") //添加进入群所有好友的id
- ;
- //如果群不存在则创建
- if (!groupid) {
- groupid = Guid.newGuid(); //新建一个群id
- _groupinfo = new U.F.T.GroupEntity(groupid, _groupname, new Date(), _userid, _groupdescript, null); //添加群实体
- //获取创建群后,拉进群用户里包括自己
- _adduserinfo.push(US.userInfo);
- _groupuserids = _userid + "," + _groupuserids;
- }
- //群存在操作
- else {
- _groupinfo = _$(US.Friend[2]).Select({ "GroupManageID": groupid })[0]; //获取群
- }
- //关闭弹框
- U.D.CloseWindow($(el).Parent({ usform: "true" }));
- _adduserinfo = _adduserinfo.splice(0, _adduserinfo.length); //移除全局变量,把需要添加的用户删除
- //创建群成员,给每个群成员发送一条建立群给拉入群的消息
- U.A.Request(US.Auth, ["CreateGroupAndAddUser", _userid, groupid, _groupname, _groupdescript, _groupuserids],
- U.F.J.AsynDetermineCreateGroupAndAddGroupUser, ["", _groupinfo, _adduserinfo, groupid, _groupname, _groupdescript]); //添加到数据库
- }
- /**
- * 异步创建群
- * @param {object} 服务器返回的值
- */
- U.F.J.AsynDetermineCreateGroupAndAddGroupUser = function (r) {
- var i,
- context = r.context, //回调函数的值
- _directory,
- _diskinfo,
- _groupuser,
- _userinfo = US.userInfo, //回调的用户信息
- _groupinfo = context[1], //当前群信息
- _groupuserinfo = context[2], //用户信息集合
- _groupid = context[3], //群id
- _groupname = context[4], //群名
- _groupdescript = context[5] //群描述
- ;
- r = r.value; //获取服务器的返回值
- //创建群或者修改群成功o
- if (r !== false) {
- //如果新建的群不存在全局变量中,则新建一个
- if (!_$(US.Friend[2]).Select({ "GroupManageID": _groupid })[0]) {
- US.Friend[2].unshift(_groupinfo); //把群插入全局变量中
- //新建一个群目录
- _directory = new U.Dk.M.Entity(_groupinfo.GroupManageID, 0, US.userInfo.userid, _groupinfo.GroupManageName, _groupinfo.GroupManageName,
- "folder", null, new Date(), U.UP.FFT("folder")[1], 1, null, null, 0, "", _groupinfo.GroupManageID);
- //调用添加文件到disk全局的方法
- _diskinfo = U.Dk.DiskOperatingSwitch(_userinfo.UserId); //根据userid获取网盘的信息
- U.Dk.M.Entity.Add([_directory], _diskinfo); //添加到disk全局里
- }
- //如果群已经存在了,那么修改群名和群描述
- else {
- _groupinfo.GroupManageName = _groupname; //群名
- _groupinfo.GroupManageDescript = _groupdescript; //群描述
- }
- //把群的用户添加到群用户数组里
- for (i = 0; i < _groupuserinfo.length; i++) {
- _groupuser = new U.F.T.GroupUserEntity(_groupuserinfo[i].UserId, _groupuserinfo[i].UserImageHead,
- _groupuserinfo[i].UserNickName, _groupuserinfo[i].UserName, _groupuserinfo[i].UserThumbnailImageHead,
- _groupuserinfo[i].UserNickName, _groupid, 1); //新建一个群用户
- US.Friend[3].push(_groupuser); //添加到群用户里
- }
- //创建群成功后,直接点击查看群。
- $($("#UD_SYHZLTA").Child()[2]).Child()[0].onclick();
- //提示语
- if (_groupinfo) {
- U.Alert(_groupinfo ? _groupname + "邀请成功" : "邀请好友请入群成功~");
- }
- }
- //创建失败的提示
- else {
- U.Alert("服务器繁忙,请从新创建!!");
- }
- }
- /*
- 弹框询问用户是否创建这个群
- */
- U.F.J.CXNEWTJ = function (groupid, groupname, groupds, fileid, cb) {
- _UGE = _$(US.Friend[2]).Select({ "GroupManageID": groupid })[0]; //判断群是否已经存在在列表中
- if (!_UGE) {
- var UDGD = $$("div", {});
- //var UDGD_xz = $$("div", { "className": "UDGD_xz", "innerHTML": "下载", "onclick": [[U.Dk.RE.WPXZWJZJO, [UDWW["id"], "file"]]] }, UDGD);
- var UDGD_yj = $$("div", { "className": "UD_ALLTs", "innerHTML": "您的文档将移至新建群里(" + groupds + "),是否新建群组?" }, UDGD);
- var UDGDO = $$("div", { "className": "UD_ALLTs_All" }, UDGD);
- var UDGD_yjs = $$("div", { "className": "UD_ALLTs_OFF", "innerHTML": "取消" }, UDGDO);
- $$("div", { "className": "UD_ALLTs_OUT", "innerHTML": "确认", "onclick": [[U.F.J.ChangeY, [groupid, groupname, groupds, fileid, cb]]] }, UDGDO);
- UDGD_yjs.onclick = function () { $("#UD_Temp_CK")[0].close() }
- U.UI.Form({//创建更多窗体
- draw: false,
- max: false,
- min: false,
- isTop: true,
- id: "UD_Temp_CK",
- style: {
- width: "250px",
- height: "170px"
- },
- content: UDGD,
- title: "提示",
- hst: {}
- }); //创建窗体
- } else {
- U.F.J.ChangeY(groupid, groupname, groupds, fileid, cb)
- }
- }
- /*
- 获取所选择的联系人,发送消息
- */
- U.F.J.ChangeY = function (groupid, groupname, groupds, fileid, cb) {
- var i, _UGE, _UBY,
- // _UCB = U.F.J.AsynDetermineCreateGroupAndAddGroupUser, //创建群异步回调
- _UTF = 1, //判断是否已经创建。如果没有创建,就把_UTF的值设置为0,0在存储过程的传参作用是创建群, 1是不创建直接修改群名
- _userid = US.userInfo.userid, //当前用户id 也是群主id
- _UGN = [groupname, groupds], //群名和群描述的数组 [0]群名 [1]群描述
- _UDE = U.D.SY.ET["UL"]["AD"], //需要添加用户的集合(群用户)
- _NAIDs = new Array();
- for (var i = 0; i < _UDE.length; i++) {
- var pd = 0;
- for (var u = 0; u < _NAIDs.length; u++) {
- if (_NAIDs[u].UserId == _UDE[i].UserId || _UDE[i].UserId == US.userInfo.userid) {//
- pd++
- }
- }
- if (pd == 0) {
- _NAIDs.push(_UDE[i]);
- }
- }
- _FriendUser = _$(_NAIDs).pluck("UserId").join(","),
- _UAID = _$(_NAIDs).pluck("UserId").join(","); //用,分割群用户的id 例: userid,userid
- _UGE = _$(US.Friend[2]).Select({ "GroupManageID": groupid })[0]; //判断群是否已经存在在列表中
- if (!_UGE) { //判断群是否存在
- _UTF = 0;
- groupid = groupid || Guid.newGuid(); //没有群id创建一个群id
- //创建群的实体,主要是用于添加到US.Friend[2]这个群集合里面
- _UGE = new U.F.T.GroupEntity((groupid = groupid || Guid.newGuid()), _UGN[0], new Date(), _userid, _UGN[1], null);
- _UAID = _userid + (_UAID ? "," : "") + _UAID; //拼接群用户id 把本人也添加到这个群里
- }
- _UDE.splice(0, _UDE.length); //添加成功后移除用户
- //创建群成员,给每个群成员发送一条建立群给拉入群的消息
- U.A.Request(US.Auth, ["CreateGroupAndAddUser", _userid, groupid, _UGN[0], _UGN[1], _UAID], U.F.J.AsynCXNEWTJ, ["", _UGE, _NAIDs.splice(0, _NAIDs.length), groupid, _UGN[0], _UGN[1], cb, _FriendUser, groupid, _UGN[0]]); //添加到数据库
- // U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "CreateGroupAndAddUser", _userid, _UGN[0], _UGN[1], groupid, _UAID, _UTF], U.F.J.AsynCXNEWTJ, ["", _UGE, _NAIDs.splice(0, _NAIDs.length), groupid, _UGN[0], _UGN[1], cb, _FriendUser, groupid, _UGN[0]]); //添加到数据库
- //给每个群成员发送一条有关于这个uw文件的消息
- // U.A.Request(US.CD, ([US.DB, "UseStudio_Friends", "SentMessageToFriend", US.userInfo.userid, _FriendUser, US.userInfo.UserNickName || US.userInfo.username, '' + groupid + ',' + _UGN[0] + ',' + _UGE.GroupManageCreateDate + ',' + fileid + ',' + _UGE.GroupManageName + '.UW', 5, false]), U.M.apply(), [""]);
- $("#UD_Temp_CK").hide()
- }
- /**
- * 确定添加按钮
- *点击好友添加确定按钮,去数据库创建一个群
- * @param {object} 添加好友窗体
- */
- U.F.J.AsynCXNEWTJ = function (r) {
- U.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.F.J.OAddGroup = function (groupinfo, UCB) {
- if (!U.U.L.isLogin(3)) {//判断是否登录
- var _userinfo = US.userInfo,
- _userid = _userinfo.UserId,
- _UDE = US.Friend[2],
- _UTF = _$(_UDE).Select({ "GroupManageID": groupinfo.GroupManageID })[0];
- if (!_UTF) {
- U.Alert("正在加入,请稍等..");
- U.A.Request(US.Auth, ["AddUsersToGroup", groupinfo.GroupManageID, _userid], U.F.J.AsynOAddGroup, ["", { MessageContent: groupinfo.GroupManageID, MessageDescript: groupinfo.GroupManageName, UserId: groupinfo.UserId }, UCB]);
- }
- else {
- if (UCB) {
- U.M.apply(this, UCB)();
- }
- else { U.F.W.ViewFriend(_UTF); }
- }
- }
- }
- //用户直接进入群异步
- U.F.J.AsynOAddGroup = function (r) {
- U.Alert("成功加入该群");
- var context = r.context,
- _UCB = context[2],
- _userid = US.userInfo.userid,
- _UGE = US.Disk.Disks[_userid],
- _UDE = U.F.N.AsynLYHJQCL(r); //添加群文件
- _UGE[0].splice(6, 0, (_UGE[4][_UDE.GroupManageID] = new U.Dk.M.Entity(_UDE.GroupManageID, 0, _userid, _UDE.GroupManageName, _UDE.GroupManageName, "folder", null, new Date(), U.UP.FFT("folder")[1], 1, null, null, 0, "", _UDE.GroupManageID))); //添加群网盘资料
- if (_UCB) {
- U.M.apply(this, _UCB)();
- }
- else {
- U.F.W.ViewFriend(_UDE);
- } //回调
- }
- /**
- * 加入群
- *
- * @param {object} 群信息
- */
- U.F.J.AddGroup = function (groupinfo) {
- if (!U.U.L.isLogin(3)) {//判断是否登录
- var _userinfo = US.userInfo,
- _userid = _userinfo.UserId,
- _UDE = US.Friend[2],
- _UTF = _$(_UDE).Select({ "GroupManageID": groupinfo.GroupManageID })[0];
- if (!_UTF) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SendJoinGroupMessage", _userid, groupinfo.GroupManageID, _userid, groupinfo.GroupManageName], U.F.J.AsynAddGroup, [""]);
- //U.A.Request(US.Auth,"UseStudioManage.AddToGroupMessageStatus", [_userid, groupinfo.GroupManageID, _userid, groupinfo.GroupManageName], U.F.J.AsynAddGroup, [""]);
- U.Alert("发送消息中...");
- }
- else { U.F.W.ViewFriend(_UTF); }
- }
- }
- //加入群异步
- U.F.J.AsynAddGroup = function (r) {
- U.Alert(r.value ? "已经向群主发送消息" : "消息发送失败请重新发送");
- }
- //#endregion
- /**
- * 弹出好友添加使用
- *
- * @param {object} 群信息
- */
- U.F.J.AddPopup = function (groupinfo) {
- var _SFC, _SFD, _SFDF, _SFDT, _SFDJ, _SFDC; //窗体,内嵌DIV,添加分组,添加/查找好友,加入群组,创建群组
- //弹出添加选择窗体
- _SFC = U.UI.Form({ "style": { "width": "390px", "height": "220px" }, "title": "添加好友/群聊", "Top": "0", "Left": "0" }).body;
- //宽度30%,高度30%,标题添加好友/群聊
- _SFD = $$("div", { "className": "U_F_PLACE" }, _SFC);
- _SFDF = $$("div", { "className": "U_F_SORT", "onclick": U.F.M.CreateFriendGroupPopup, "innerHTML": "添加分组" }, _SFD); //添加分组按钮
- _SFDT = $$("div", { "className": "U_F_SORTE", "onclick": U.F.S.FTCSS, "innerHTML": "添加/<br>查找好友" }, _SFD); //查找好友
- _SFDJ = $$("div", { "className": "U_F_SORT", "onclick": U.F.S.TCSS, "innerHTML": "加入群组" }, _SFD); //加入群聊
- _SFDC = $$("div", { "className": "U_F_SORT", "onclick": [[U.F.J.GroupInfoForm, [groupinfo]]], "innerHTML": "创建群组" }, _SFD); //创建群聊
- }
|