-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchat_index.php
2868 lines (2678 loc) · 97.3 KB
/
chat_index.php
1
<?phprequire_once( __DIR__.'/../config.inc.php' );require_once( DOCUMENT_ROOT.'/lib/mesages.class.php' );$chat_uid = $_SESSION['staffid'];$oms_id = $_SESSION['oms_id'];$secret = 'oms';$token = md5(date('y-m-d h:i').$chat_uid.$oms_id.$secret);$pageload = 10;//消息显示的条数$session_no = 0;//会话id$mesNum = 0;$messageSessionList = [];//消息类型// $mes_type = 'message';//实例化消息$mes = new messageList( $chat_uid, $oms_id );//最近联系人if (isset($chat_uid)) { $recentContact = $mes->recentContact();}//最近联系人session_no集合;$ContactManSession = [];//群聊列表$arrGroup = $mes->groupChatList();// 好友列表$arrfrientList = $mes->friendsList();$friendSearch = $recentContact;// 最近联系人 集合if (is_array($friendSearch)) { foreach ($friendSearch as $key => $value) { $ContactManSession[] = $value['session_no']; }}//搜索if (!empty($arrfrientList)) { foreach ($arrfrientList as $key => $value) { $friend['id'] = $value['id']; $friend['id'] = $value['pid']; $friend['mestype'] = 'message'; $friend['contacts_name'] = $value['name']; $friend['mes_id'] = $value['staffid']; $friend['card_image'] = $value['card_image']; $friendSearch[] = $friend; }}// 加入管理员 群 的 session$ContactManSession[] = 'ca';//自己的信息$userinfo = $mes->userinfo();$chat_name = $userinfo['name'];//自己名字$card_image = $userinfo['card_image'];//头像的url$isAdmin = $userinfo['general_admin'];//提示消息列表if (isset($chat_uid)) { $arrMes = $mes->mesAlertList($isAdmin); if (!empty($arrMes)) { foreach ($arrMes as $key => $value) { $mesNum += $value['mes_num']; $messageSessionList[] = $value['session_no']; } }}if (!empty($_GET['staffid'])) { $staffidInfo = $mes->getStaffidInfo(intval($_GET['staffid']));}// print_r($arrMes);//管理员的所有信息 // $chatAdminList = $mes->getAdmin();?><!doctype html><html lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>聊天</title> <!-- Include these three JS files: --> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/touchSwipe.js?"></script> <script src="js/jquery-ui.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/chatViewer.min.js"></script> <script type="text/javascript" src="js/web_message.js?v=1.0.1"></script> <link rel="stylesheet" href="css/jquery-ui.css"> <link rel="stylesheet" href="css/viewer.min.css"> <link rel="stylesheet" href="css/webRight.css" type="text/css"/> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> <link rel="stylesheet" href="css/font-awesome.min.css" type="text/css"/> <link rel="stylesheet" href="css/app.css" type="text/css"/><style type="text/css"> html, body{ height: 100%; overflow: hidden; } *{font-family: 'Microsoft YaHei', SimSun, sans-serif !important;} .pc_mes_tool ul{ margin: 0;padding: 0 } .container-tab ul{ margin: 0;padding: 0 } .chat-main-footer ul{ margin: 0;padding: 0 } .online_man{ text-align: center;margin: 0 auto;box-shadow: 0 0 5px #999;} .online_man ul{margin-left: auto;margin-right: auto;padding: 0;} #name_box{ position:fixed;background:#fff;display:none;width: 100%;margin-top:0px; z-index:9999;height: 100%;} .myFriend { display: none; width: 80%;height: 300px;margin: auto;border: 1px solid #ccc; } .myFriend > div { float: left; } .myFriend .myFriend-icon{ width: 8%;height: 100%;line-height: 300px; text-align: center;vertical-align: middle;} .myFriend .myFriend-icon span{ width: 32px; height: 32px;margin: auto;display: inline-block; } .myFriend .chat-orgFriend{ width: 46%;height: 100%;overflow: auto;background: rgb(250,238,241); } .myFriend .myFriend-list li { height: 36px; line-height: 36px; font-size: 14px; } .myFriend .myFriend-list li:hover {background-color: #ccc;} .myFriend .myFriend-list .myFriend-items-del { cursor: pointer; width: 32px;height: 32px;padding: 5px;display: inline-block;margin-left: 10px;line-height: 22px;text-align: center;background: #F1A8A8;} .myFriend .myFriend-body{padding: 2px;} .myFriend .myFriend-list li img { height: 32px; width: 32px;line-height: 32px; } .myFriend .myFriend-list li input { display: none; height: 23px; line-height: 23px;width: 15px; float: left;} .orgFriend { width: 100%;text-align: center; } .orgFriend > p { display: inline-block; border: 1px solid #ccc; } .orgFriend .orgFriend-list-cur { background-color: #ccc; } #chat-orgFriend-list{ overflow: auto; } #chat-orgFriend .panel{ background: transparent; } .chat-orgName-select { width: 46%;height: 100%;background: rgb(250,238,241);} /*.orgFriend .orgFriend-list { border: 1px solid #ccc; }*/ /*.orgFriend > span { width: 120px; height: 40px; line-height: 40px;display: inline-block; }*/ .mes_chakan_close{ line-height: 20px; cursor: pointer; } .mes_dclose{ cursor: pointer; position: absolute; top: 3px; font-size: 33px; color: #fff; right: 0;} .tab-content{ overflow: auto;position: absolute; width: 100%;top: 105px;bottom: 37px;} /*#submit{height: 35px;}*/ @media screen and (max-width:500px){ .myFriend .chat-orgFriend{ width: 100%;height: 100%;overflow: auto;background: rgb(250,238,241); } .myFriend { display: none; width: 100%;height: 300px;margin: auto;border: 1px solid #ccc; } .chat-orgName-select ,.myFriend-icon{ display: none; } .myFriend .myFriend-list li input { display: block; } .myFriend .myFriend-list li > span { display: inline-block;width: 100%;position: absolute;height: 100%;background-color: transparent;opacity: 0;left: 0;z-index: 111;} } .latt-container{ height: auto !important;overflow: auto !important;position: inherit !important; } .latt-wrapper{height: auto !important; }</style> <script type="text/javascript"> var chatConfig = { chat_uid: "", // 自己的id chat_name: "", // 自己的 名字 room_id: "",// 房间id to_uid_header_img: "", // 接受这者 的头像url session_no: "", // 会话id mes_type: "", // 会话 类型 message 单聊 , groupMessage }; var freeChat = function () { } var chat_uid = "<?php echo $chat_uid;?>"; $(function (){ //连接 服务器 connect(); }) var custom = 1;//客服id var mes_online = 1; var oms_id = "<?php echo $oms_id;?>";//自己的组织id chat_uid = "<?php echo $chat_uid;?>"; // 自己的用户id var chat_name = "<?php echo $chat_name;?>";// 自己的名字 var accept_name ="<?php echo $accname?>";//接收人名字 var room_id = "<?php echo isset($oms_id) ? $oms_id : 1?>";//房间id var chat_token = "<?php echo !empty($token) ? $token : 1?>"; var to_uid = <?php echo isset($_GET['staffid']) ? $_GET['staffid'] : 0;?>;// 接收人id // var db_id;//indexeddb var to_uid_header_img ='';// 接收人id var mes_type = "message"; var session_no = 0;//会话id var document_url = "<?php echo DOCUMENT_URL?>"; var groupId = 0; var header_img_url = "<?php echo $card_image?>"; //保存输入的数据 var inputSave = ""; // 当前的页面 var webUrl = 'chat_index'; // 加载图片的 index var imgIndex = 0; //光标的位置 // var cursorPos; //最近联系人 nearestContact = new Object(); nearestContact = <?php echo !empty($ContactManSession) ? json_encode( $ContactManSession ): json_encode([]);?>; $recentContact = <?php echo !empty($friendSearch) ? json_encode( $friendSearch ): json_encode([]);?>; // 会话 对象 </script></head><body><!-- <textarea name="" id="test" cols="30" rows="10"></textarea> --><!-- 加载图片的保存 --><div class="loadImg-box"> <ul class="loadImg loadImging" style="display:none"></ul></div><div class="chat_voice_box" voice_url=""> <audio src="" preload ></audio></div><div class="chat_alert alert-success" role="alert"> <button class="close" data-dismiss="alert" type="button" >×</button> <p>恭喜您操作成功!</p></div><!-- 正在加载 --><div class="chat_loader"> <div class="loader-inner ball-scale-multiple"> <div></div> <div></div> <div></div> </div></div><!-- 消息通知 --><!-- 消息提示 --><div class="mesNoticeContainer"></div><!-- end --><div class="chat_notice_container"> <div class="chat_notice_close close">×</div> <div class="chat_notice_list_box"> <div class="chat_notice_list"> <div class="chat_notice_img"> <img src="/chat/images/chatNotice.png" alt=""> </div> <div class="chat_notice_con"> <span></span> <span></span> </div> <div class="chat_notice_agree chat_notice_sel"></div> <div class="chat_notice_unagree chat_notice_sel"></div> </div> </div></div><div id="name_box"> <div class="orgFriend"> <p> <span class="orgFriend-list orgFriend-list-cur btn" data-type= "c">本组织内部好友</span> <span class="orgFriend-list btn" data-type="m">我的好友</span> </p> </div> <div class="myFriend"> <!-- 我的好友 --> <div class="chat-orgFriend"> <div class="panel-group" id="chat-orgFriend"> <div class="panel friend-group"> <div class="panel-heading" mestype= "groupMessage" data-toggle="collapse" class="group-man-show" data-parent="#chat-orgFriend" href="#chat-orgFriend-list"> <h4 class="panel-title"><span title="我的好友" >我的好友</span></h4> </div> <div id="chat-orgFriend-list" class="panel-collapse collapse"> <div class="panel-body myFriend-body"> <ul class="list-group myFriend-list"> <?php if (!empty($arrfrientList)) :?> <?php foreach ($arrfrientList as $k => $v) : ?> <li mes_id="<?php echo $v['staffid'];?>" group-name="<?php echo $v['name'];?>" class="myFriend-items"><span class="myFriend-items-Mask" mes_id="<?php echo $v['staffid'];?>"></span><input type="checkbox" mes_id="<?php echo $v['staffid'];?>" class="myFriend-items-in"><img class="header-img" src="<?php echo empty($v['card_image'])?'/chat/images/niming.png':$v['card_image']; ?>" alt=""><?php echo $v['name'];?></li> <?php endforeach; ?> <?php else:?> 还没有好友! <?php endif ;?> </ul> </div> </div> <span class="caret drop-down"></span> </div> </div> </div> <div class="myFriend-icon"><span><img src="/chat/images/jiantou.png" alt=""></span></div> <!-- 选择人后的容器 --> <div class="chat-orgName-select"> <h5>已选好友</h5> <ul class="list-group myFriend-list"> </ul> </div> </div> <!-- 公司组织 --> <div class="orgJiagou" style="height: 400px; overflow: auto;"></div> <div style="clear:both;"></div> <div id="orgAct" style="width:100%;text-align: center;"></div> <div style="width:100%;text-align: center;"> <button style="margin-top:17px;width:157px;height:30px;margin-right: 10px;" id="b_no" class="btn btn-sm btn-info" >取 消</button><button style="margin-top:17px;width:157px;height:30px;margin-left: 10px;" id="b_is" class="btn btn-sm btn-info">确 定</button> </div></div><script type="text/javascript"> // 好友的 选择 $(function () { // 手机 上的点击 var myFriendItemsIn = $('.myFriend-items-in'); var friendItem = $('.myFriend-items'); var orgNameSelected = $('.chat-orgName-select ul'); var orgFriendList = $('.orgFriend-list'); orgFriendList.click(function () { var dataType = $(this).attr('data-type'); orgFriendList.removeClass('orgFriend-list-cur'); $(this).addClass('orgFriend-list-cur'); if ( dataType == 'c' ) { $('.myFriend').hide(); $('.orgJiagou').show(); } else { $('.myFriend').show(); $('.orgJiagou').hide(); } }) // window.friendMap = ''; var friendSelect = function () { this.mes_id =''; this.group_name =''; this.friendMap = []; } friendSelect.prototype.addMan = function (obj){ if ( $.inArray(this.mes_id, this.friendMap) == -1 ) { if ( typeof obj == 'object' ) { var selected = obj.clone(); var manDel = $('<span mes_id="'+this.mes_id+'">×</span>'); selected.addClass('myFriend-items-sel'); manDel.addClass('myFriend-items-del'); manDel.css('display', 'none'); // 删除 已选好友 manDel.click(function (e) { e.stopPropagation(); var mes_id = $(this).attr('mes_id'); myFriend.mes_id = mes_id; selected.remove(); myFriend.delMan(); }) selected.hover(function () { manDel.css('display', 'inline-block'); }, function () { manDel.css('display', 'none'); }); selected.append(manDel); orgNameSelected.append(selected); } this.friendMap.push(this.mes_id); return window.friendMap = this.friendMap; }; } friendSelect.prototype.delMan = function (obj) { this.friendMap = _chat_remove(this.mes_id, this.friendMap); // this.friendMap.remove(this.mes_id); return window.friendMap = this.friendMap; } var myFriend = new friendSelect(); friendItem.click(function (e) { var $this = $(this); var $thisIn = $this.find('input'); var mes_id = $this .attr('mes_id'); var group_name = $this .attr('group-name'); myFriend.mes_id = mes_id; myFriend.group_name = group_name; // console.log( $thisIn.prop('checked')); // if ( $thisIn.prop('checked') ) { // $thisIn.prop('checked', false); // $('.myFriend-list li.myFriend-items-sel[mes_id="'+mes_id+'"]').remove(); // myFriend.delMan(); // } else { // $thisIn.prop('checked', true); // myFriend.addMan($this); // } myFriend.addMan($(this)); }); // 手机上的 input 点击 $('.myFriend-items-Mask').click(function ( e ){ e.stopPropagation(); var mes_id = $(this).attr('mes_id'); myFriend.mes_id = mes_id; if ( $(this).next().prop('checked') ) { $(this).next().prop('checked', false); myFriend.delMan(); } else { myFriend.addMan(''); $(this).next().prop('checked', true); // $('.myFriend-list li.myFriend-items-sel[mes_id="'+mes_id+'"]').remove(); } }) // myFriendItemsIn.click(function (e){ // // 阻止冒泡 // e.stopPropagation(); // var mes_id = $(this).attr('mes_id'); // $(this).prop('checked'); // myFriend.mes_id = mes_id; // if ( $(this).prop('checked') ) { // myFriend.addMan($(this).parent()); // } else { // $('.myFriend-list li.myFriend-items-sel[mes_id="'+mes_id+'"]').remove(); // myFriend.delMan(); // } // }) })</script><div class="bagimg"> <img src="images/2.jpg" alt=""></div><div class="container-box"><div class="details-list"> <div class="container-title"> <div class="container-header"> <img src="<?php echo $card_image;?>" width="50px" height="50px" alt="<?php echo $chat_name;?>"> <h3 style="padding: 5px 0 5px 70px;text-align:left;"><?php echo $chat_name;?></h3> <h3 style="padding: 5px 10px 5px 70px;text-align:left;color: #A9A9A9; font-size: 18px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="<?php echo $_SESSION['org_name'];?>"><?php echo $_SESSION['org_name'];?></h3> </div> <div class="dropdown"> <i id="chatNoticeList" data-target="#" href="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> <i class="icon-list"></i> <span class="caret"></span> </i> <ul class="dropdown-menu chat-set-user" aria-labelledby="chatNoticeList"> <li set-switch = '1' set-data = "VoiceState" class="dropdown-menu-man dissolve-group VoiceState close-voice">关闭声音</li> <li set-switch = '1' set-data = "desktopState" class="dropdown-menu-man dissolve-group desktopState close-voice">关闭桌面通知</li> </ul> </div> <!-- <span class="chat_mes_notice"><img src="/chat/images/chat_notice.png" alt=""></span> --> </div> <div class="container-tab"> <ul> <li class="tab-title" ind= '0' title="最近联系人"><img src="images/mesage.png" alt="最近联系人"></li> <!-- <li title="选择好友聊天"><img id="f_man" src="images/friend.png" alt="选择好友聊天"></li> --> <li title="选择人聊天"><img id="s_man" src="images/rens1.png" alt="选择人聊天"></li> <li class="tab-title" ind= '1' title="选择群聊"><img src="images/rens.png" alt="选择群聊"></li> <a href="new_groupChat.php" target="_blank" title="新建群聊"><li title="新建群聊"><img src="images/addMan.png" alt="新建群聊"></li></a> <i class="sanjiao"></i> </ul> </div> <!-- 最近联系人 --> <div class="recent-container tab-chat"> <div class="search-ren-pos"> <ul class="list-group recent-box"> <li class="search-ren"><i class="search-icon"></i><input type="text" id="search-ren" placeholder="搜索联系人"></li> <?php $style = 'style= "margin-top:83px;"'?> <?php if ( $isAdmin == 1 ):?> <?php $style = 'style= "margin-top:126px;"'?> <li class="chat_admin session_no" data-placement="right" group-name="管理员联系群" session_no="ca" mes_id="" mestype ="adminMessage" ><span class="header-img"><img src="/chat/images/chat_admin.png" alt=""></span><i>管理员联系群</i></li> <?php endif;?> <li class="chat_system_notice" data-placement="right" onclick="chatSystemNotice()" group-name=""><span class="header-img"><img src="/chat/images/chatNotice.png" alt=""></span><i>系统通知</i></li> </ul> </div> <div class="friends-list-box" <?php echo $style;?>> <!-- 好友列表 --> <div class="panel-group" id="accordion"> <div class="panel friend-group"> <div class="panel-heading" mestype= "groupMessage" data-toggle="collapse" class="group-man-show" data-parent="#accordion" href="#friends-list-d"> <h4 class="panel-title"><span title="我的好友" >我的好友</span></h4> </div> <div id="friends-list-d" class="panel-collapse collapse"> <div class="panel-body groupMan-list"> <ul class="list-group"> <?php if (!empty($arrfrientList)) :?> <?php foreach ($arrfrientList as $k => $v) : ?> <li mes_id="<?php echo $v['staffid'];?>" group-name="<?php echo $v['name'];?>" class="chat_people group-people"><img class="header-img" src="<?php echo $v['card_image']; ?>" alt=""><?php echo $v['name'];?><span class="delgroupman" data-type="fri" id="<?php echo $v['staffid'];?>" style="display: none;">×</span></li> <?php endforeach; ?> <?php endif ;?> </ul> </div> </div> <span class="caret drop-down"></span> </div> </div> <!-- end群 --> </div> <!-- 最近联系人的搜索结果 --> <ul class="search-ren-res list-group"></ul> <div class="tab-content con-tab-content"> <ul class="list-group com-recent-box" <?php echo $style ;?>> <?php if (!empty($recentContact)): foreach ($recentContact as $key => $value) :?> <?php $herder_img = $value['card_image']; $contacts_name = $value['contacts_name']; if ($value['mestype'] !== "message") { $contacts_name = $value['accept_name']; $herder_img = '/chat/images/rens.png'; } $cont_id = $value['mes_id']; ?> <?php if ($value['mestype'] !== "message") :?> <li class="session_no recent-hover" data-placement="right" group-name="<?php echo $value['accept_name']; ?>" delConId = <?php echo $value['id'];?> session_no="<?php echo $value['session_no'];?>" mes_id="<?php echo $cont_id;?>" mestype ="<?php echo $value['mestype'];?>" ><span class="header-img"><img src="<?php echo $herder_img?>" alt=""></span><i><?php echo $contacts_name;?></i><span title = "从列表中删除" mestype="<?php echo $value['mestype'];?>" delConId = <?php echo $value['id'];?> session="<?php echo $value['session_no'];?>" class="recent-close">×</span></li> <?php else: ?> <li class="recent-contact content-staff-info chat_people recent-hover" data-placement="right" group-name="<?php echo $contacts_name;?>" delConId = <?php echo $value['id'];?> session_no="<?php echo $value['session_no'];?>" mes_id="<?php echo $cont_id;?>" mestype ="<?php echo $value['mestype'];?>" ><span class="header-img"><img src="<?php echo $herder_img;?>" alt=""></span><i><?php echo $contacts_name;?></i><span title = "删除聊天记录" mestype="<?php echo $value['mestype'];?>" delConId = <?php echo $value['id'];?> session="<?php echo $value['session_no'];?>" class="recent-close">×</span></li> <?php endif; ?> <?php endforeach; ?> <?php endif; ?> </ul> </div> <div class="chat-main-footer"> <ul> <li class="footer-friend"><i class="fri-icon" title="本组织外的好友"></i></li> <li><i class="all-search search-icon" title="好友的查找" id = "allSearch"></i></li> <li class=""><a href="#" title="多人视频" data-para= "vM" class="pc_mes_tool_videoM pc_mes_tool_list"></a></li> <li class=""><a href="/welcomepage.php" target="_blank" class="chat-home" title="主页" ></a></li> </ul> </div> </div> <div class="tab-content group-content tab-chat" style="border-top: 1px solid #ccc;"> <!-- 群列表 --> <div class="panel-group" id="accordion"> <?php if (!empty($arrGroup)): foreach ($arrGroup as $key => $value): ?> <div class="panel group-chat"> <div class="panel-heading session_no db_session_no" mestype= "groupMessage" group-name="<?php echo $value['group_name']?>" groupId="<?php echo $value['id'];?>" group-all="<?php echo $value['all_staffid']?>" session_no='<?php echo $value['pid']?>'> <h4 class="panel-title"><a title="<?php echo $value['group_name']?>" groupid = "<?php echo $value['pid']?>" data-toggle="collapse" class="group-man-show" data-parent="#accordion" href="#collapse<?php echo $key;?>"><?php echo $value['group_name']?></a></h4> </div> <div id="collapse<?php echo $key;?>" class="panel-collapse collapse"> <div class="panel-body groupMan-list"> <ul class="list-group groupRightClick"> <!-- 群聊参加人 --> </ul> </div> </div> <div class="dropdown"> <i id="dLabel<?php echo $key;?>" data-target="#" href="http://example.com" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> <i class="icon-list"></i> <span class="caret"></span> </i> <ul class="dropdown-menu group-operation" aria-labelledby="dLabel<?php echo $key;?>"> <?php if ($chat_uid == $value['group_founder']):?> <li groupId="<?php echo $value['pid'];?>" class="dropdown-menu-man dissolve-group">解散该群</li> <?php else:?> <li groupId="<?php echo $value['pid'];?>" class="dropdown-menu-man esc-group">退出该群</li> <?php endif;?> </ul> </div> </div> <?php endforeach;?> <?php endif;?> </div> <!-- end群 --> </div> </div> <!-- 右边人数 和 消息数 --> <div class="mes_fixed_big"> <div class="mes_abs"> <div class="mes_fixed"> <div class="mes_ico_box" cata-box='ren'> <div class="mes_ico mes_hide" style="background-position:-6px -50px"></div> <div class="mes_ico mes_hide" style="background-position:-100px -100px;text-align: center;color:#fff;"> <span class="mes_hide" style='line-height: 50px;'><span class='online_ren'>0</span>人</span> </div> </div> <div class="mes_ico_box" cata-box='mes'> <div class="mes_ico mes_hide" style="background-position:-6px 0"></div> <div class="mes_ico mes_hide" style="background-position:-100px -100px"> <div class="mes_radio mes_hide"><?= $mesNum;?></div> </div> </div><!-- <div class="kefu-icon"> <div class="kefu" mes_id="customer" group-name ="客服">联系客服</div> </div> --> <!-- <div class="mes_move"><i class="icon-sort"></i></div> --> </div> <div class="online_man"> <div class="man_tittle"> <span>人员列表</span> <span class ="close" style='cursor: pointer; margin-right: 5px;background: #000;color: #fff; position:absolute;width:20px;height:20px;border-radius: 50%;right: 0; top: 7px; '>×</span> </div> <div class="onlinesSroll-box"> <div class="onlinesSroll"></div> </div> <!-- 人员列表 --> <!-- 搜索框 --> <div class="search_box"> <input type="text" class= "search_in" id="search_in" placeholder= "搜索"> <span class="search_staff"></span> <ul class="staff-list-group search_result"> </ul> </div> <ul class="list-group oms_onlineNum"></ul> </div> <div class="mes_con" style="display: none;"> <div class="mes_tittle"> <span>消息列表</span> <span class ="close" style='cursor: pointer; margin-right: 5px;background: #000;color: #fff; position:absolute;width:20px;height:20px;border-radius: 50%;right: 0; top: 7px; '>×</span> </div> <!-- 消息列表 --> <?php if (!empty($arrMes)):?> <?php foreach ($arrMes as $key => $value) :?> <?php $messageTypes = $value['mesages_types']; if ( $value['message_type'] == 'message') { $sender_name = $value['sender_name']; $addClass = "chat_people"; $chat_header_img = $value['chat_header_img']; } else if ( $value['message_type'] == 'groupMessage' ){ $sender_name = $value['accept_name']; $addClass = "session_no"; $chat_header_img = '/chat/images/rens.png'; } elseif ( $value['message_type'] == 'adminMessage' ) { $sender_name = $value['accept_name']; $addClass = "session_no"; $chat_header_img = '/chat/images/chat_admin.png'; } switch ( $messageTypes ) { case 'text': $par = ['/%6b/', '/%5C/', '/{@(.+)@}/U', '/\{\|/U', '/\|\}/U']; $repStr = ['<br/>', '\\', '', '<img width="24px" class="cli_em" src="/chat/emoticons/images/', '.gif">']; $content =preg_replace($par, $repStr,$value['message_content']); break; case 'image': case 'images': $content = '【图片】'; break; case 'file': $content = '【文件】'; break; case 'voice': $content = '【语音】'; break; case 'revoke': $content = '撤销一条信息'; break; case 'va': $content = "开启了群聊视频"; break; case 'notice': $sender_name = $sender_name.'【申请对话】'; $content = $value['message_content']; $chat_header_img = "/chat/images/chatNotice.png"; $addClass = 'chat_notice'; break; case 'notice_respond': $sender_name = $sender_name; $content = '已同意可以会话了'; $chat_header_img = "/chat/images/chatNotice.png"; $addClass = 'chat_people'; break; case 'sysNotice': $content = $sender_name.$value['message_content']; $sender_name = '系统通知'; $chat_header_img = "/chat/images/chatNotice.png"; $addClass = 'chat_customer_notice'; break; default: $content = '出错了'; break; } ?> <div class="mes_box mes_chakan_close <?php echo $addClass;?>" chat_mes_num= "<?php echo $value['mes_num'];?>" mes_id="<?php echo $value['sender_id'];?>" session_no='<?php echo $value['session_no'];?>' mesid="<?php echo $value['id'];?>" mestype="<?php echo $value['message_type'];?>" group-name="<?php echo $sender_name;?>" group-all = "<?php echo $value['accept_id'];?>" session_no='<?php echo $value['session_no'];?>'> <div class="mes_header"> <img src="<?php echo $chat_header_img;?>" alt=""> </div> <span class='mex_con'><?php echo $sender_name;?></span> <div class="mes_content_list" style=''> <span class="chat_mes_content"> <?php if ( !empty( $value['mention'] ) ):?> <span class ="mention" data-name ="<?php echo rtrim(ltrim($value['mention'], '0'), ',');?>" style="color: red"> 有人@我 </span> <?php endif; ?> <span class="chat_mes_content_s"> <?php echo $content;?> </span> </span> </div> <span class="mes_num"><?php echo $value['mes_num'];?></span> <span class='mes_close' mestype='<?php echo $value['message_type'];?>' mes_id='<?php echo $value['sender_id'];?>' session_no='<?php echo $value['session_no'];?>'>X</span> </div> <?php endforeach;?> <?php endif;?> <!-- end --> </div> </div> </div> <div class="chat-container"> <div class=" chating-content chat-tab-content"> <div class="mes_title"> <h2 class="mes_title_con" >请选择人<i title="群聊添加人" class="add-groupMan"></i></h2><span aria-hidden="true" class="mes_dclose">×</span> </div> <div class="mes_con_box"> <div class="he-ov-box mes-scroll pc_he-ov-box chat_initial"> <div class="loader"> <div class="mes_load" style="display:none;"><?php echo $pageload;?></div> <div class="loading-3"> <i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i> </div> </div> <ul class="he_ov session-box" ></ul> </div> <div class="pc_mes_input_box"> <div class="pc_emoji_box" onmousedown="return false" ontouchstart="return false"></div> <div class="pc_mes_tool"> <ul> <li class="pc_mes_tool_emoji pc_mes_tool_list" onmousedown="return false" ontouchstart="return false" unselectable="on"></li> <!-- <li class="pc_mes_tool_img pc_mes_tool_list"></li> --> <li class="pc_mes_tool_file pc_mes_tool_list"></li> <li class=""><a href="javascript:void(0)" title="语音" data-para= "a" onclick="vaChat(this)" class="pc_mes_tool_audio pc_mes_tool_list keydown_voice"></a></li> <li class=""><a href="#" title="视频" data-para= "v" onclick="vaChat(this)" class="pc_mes_tool_video pc_mes_tool_list"></a></li> </ul> </div> <div class="pc_mes_input" id="pc_mes_input" contenteditable="true"></div> <div class="pc_mes_send"> <!-- <span style = "color: #aaa">按Shift + Enter 换行, Enter提交</span> --> <div class="chat_btn">发送</div> <div class="chat-send-select"> <span class="chat-send-form"></span> </div> </div> </div> <div class="mes_footer mb_mes_footer mb_mes_footer"> <div class="plus_menu_box"> <div class="plus_menu"> <span class="header_icon plus-list"><img src="/chat/images/header_icon.png" alt=""></span> <input style="display:none" type="file" multiple id="send-upimg"><span id="cli-upFile"><img src="images/uploadfile.png" alt=""></span> <span title="视频" data-para= "v" onclick="vaChat(this)" class="pc_mes_tool_video pc_mes_tool_list" style="display: in"></span> </div> <i class="icon-caret-down"></i> </div> <!-- <form onsubmit="onSubmit(); return false;"> --> <div class="mes_input"> <i class="plus_icon"></i> <div class="mes_inout textarea chat_text_voice" id="mes_textarea" style="height:auto;" contenteditable="true"></div> <textarea style="display:none" class="mes_inout" ></textarea> <input type="submit" class="btn btn-primary chat_text_voice chat_submit" id="submit" value="发送" /> <!-- <div class="keydown_voice chat_voice_input">按下开始说话</div> --> <div class="chat_input_key chat_voice_input"></div> <div style="clear:both"></div> </div> <div class="emoticons"></div> <!-- </form> --> </div> </div> </div></div><div class="send-img-box"> <span class="send-img-close com-close">×</span> <!-- <canvas id="canvas"></canvas> --></div><!-- 弹出框 --><div class="cd-popup" role="alert"> <div class="cd-popup-container"> <p class="mes_alert_con">请选择聊天对象</p> <ul class="cd-buttons"> <li><a href="#" class="clo_alert alertvalue">确定</a></li> <!-- <li><a href="#">否</a></li> --> </ul> <a href="#" class="cd-popup-close img-replace">关闭</a> </div> <!-- cd-popup-chat-container --></div> <!-- cd-popup --><!-- Resource jQuery --><div class="img-box"> <div class="img-box-title"><span>发送的图片</span><span style="color: #000;" class="com-close com-close-act">×</span></div> <div class="sending-img-box"></div> <div class="img-box-act"><span class="btn btn-success com-close-act">取消</span><span class="btn btn-info send-clipboard-img">发送</span></div></div><div class="file-main"><form action="" enctype ="multipart/form-data"> <ul> <li> <input id="token" name="token" class="ipt" value=""> </li> <li> <input id="key" name="key" class="ipt" value=""> </li> <li> <input id="file" name="file" multiple = 'true' class="ipt" type="file" /> </li> <li> <input id="filename" type="text" value=""> </li> </ul></form></div><!-- 上传进度 --><div id="progressbar"><div class="progress-label"></div><div id="formatSpeed"></div></div><!-- 查找好友 模态框 --><div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" id = "search-all" > <div class="modal-dialog modal-lg modal-css"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">添加本组织以外的好友</h4> </div> <div class="modal-body"> <div class="search-box"> <input type="text" id="searchIn" class="form-control" placeholder="请输入你想找的名字"><i id= "actSearchFriend" class="searchAll-icon"></i> </div> <!-- <p>我好友</p> --> <div class="friendItem-box clearfix"></div> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --></div><!-- /.modal --><script type="text/javascript">/********************** 业务处理 *************************/// 管理员联系群的点击// var chatAdmin = function (obj) {// $('.con-tab-content li').css('background', 'none');// $(obj).css('background', '#BEB7C7');// session_no = 'ca';// mes_type = "adminMessage";// $('.mes_title_con').html( $(obj).attr('group-name') );// $('#mes_load').html(10);// ws.send('{"type": "chatAdmin", "mes_type": "'+mes_type+'", "session_no": "ca"}');// //消息向上滚动// $('.he-ov-box').unbind('scroll');// $('.he-ov-box').bind("scroll", function (){// mesScroll();// })// }// 好友查找(function () { // 输入的名字 var searchName = ''; // 调用模态框 var allSearch = document.getElementById('allSearch'); var searchIn = document.getElementById('searchIn'); // enter 搜索 searchIn.onkeydown = function (e) { var e = e || event, keycode = e.which || e.keyCode; if ( keycode == 13 ) { searchName = searchIn.value; searchFriend.searchAct(searchName); }; } // 好友的查找 var actSearchFriend = document.getElementById('actSearchFriend'); actSearchFriend.onclick = function () { searchName = searchIn.value; searchFriend.searchAct(searchName); } searchIn.oninput = function () { if ( $(this).val() == '' ) { $('.friendItem-box').html(''); }; } allSearch.onclick = function () { $('#search-all').modal('show'); } var searchFriend = {}; searchFriend.searchAct = function ( name ) { ws.send('{"type": "friendAdd","actType":"lookup","name":"'+name+'"}'); } // foot li 点击事件 增加 高亮 显示 $('.footer-friend').click(function (e) { $('.sanjiao').hide(); $(this).addClass('foot-curColor'); })}())//文件的分享var chatShare = function ( obj ) { // window.event ? window.event.cancelBubble = true : evt.stopPropagation(); $('.chat-shareing').removeClass('chat-shareing'); obj.className += ' chat-shareing'; $('#s_man').trigger('click'); // $('#b_is').attr( 'val', 'share' ); // $('#name_box').show();}//系统 通知消息var chatSystemNotice = function () { var json = '{"type":"sysNotice"}'; chatController(json);}var chatController = function ( json ){ ws.send(json);}/*************** pc输入框 ********************///文件发送$('.pc_mes_tool_file').click( function () { getQiniuToken(); trig($('#file'));})//图片发送// $('.pc_mes_tool_img').click( function () {// trig($('#file'));// })/**************** end *******************/// pc 输入框的bing 事件;$(function () { var mesInput = $('#pc_mes_input'); mesInput.on('drop', function ( e ) { e.stopPropagation(); e.preventDefault(); })})//pc 提交$('#pc_mes_input, #mes_textarea').on('input', function () { var val = $(this).html(); inputSave = val;});$('.chat_btn').click(function () { var inputValue = $('.pc_mes_input').html(); $('#mes_textarea').html(''); $('#mes_textarea').html(inputValue); $("#submit").trigger("click"); $('.pc_mes_input').html(''); $('.pc_mes_input').focus();});$('.chat-send-form').click(function (e) { e.stopPropagation(); var localSend = localStorage.getItem('sendForm'); localSend = parseInt(localSend) ? 1 : 0; var html = '<ul class="send-list focus-hide">\ <li data-parm ="1"> 按Enter发送</li>\ <li data-parm ="0"> 按Ctrl + Enter发送</li>\ </ul>'; $('.send-list').remove(); $(this).before(html); $(this).parent().find('li').eq(localSend).addClass('send-current'); $(this).parent().find('li').click(function (e) { e.stopPropagation(); $('.send-current').removeClass('send-current'); $(this).addClass('send-current'); var para = $(this).data('parm'); localSend = localSend ? 0 : 1; console.log(localSend); localStorage.setItem('sendForm',localSend ); });});//最近联系人增加与更新var addContact = {};addContact.is = function (session_id) { for (var i in nearestContact) { if ( nearestContact[i] == session_id) { return true; }; } return false;}//通知消息同意不同意$(document).on('click', '.chat_notice_sel', function () { var dataParm = $(this).attr('data-parm'); var senderId = $(this).attr('sender-id'); var noticeHtml = $(this).html(); $('.chat_notice_container').hide(); ws.send('{"type": "chat_notice_sel", "dataParm": "'+dataParm+'", "senderId": "'+senderId+'", "oms_id": "'+ChainOmsId+'"}');})//增加最近联系人addContact.Dom = function () { var data = { "type": "addContact", "mestype": mes_type, "session_no" : session_no, "sender_name": chat_name, "accept_name": $('.mes_title_con').text(), "mes_id": to_uid, "to_uid_header_img": to_uid_header_img, "timeStamp": new Date().getTime(), }; if (mes_type == "message") { $('.con-tab-content .com-recent-box').prepend('<li class="recent-contact staff-info chat_people recent-hover" data-placement="right" group-name="'+data.accept_name+'" session_no="'+data.session_no+'" mes_id="'+data.mes_id+'" mestype ="'+data.mestype+'" ><span class="header-img"><img src="'+data.to_uid_header_img+'" alt=""></span><i>'+data.accept_name+'</i><span title = "删除聊天记录" mestype="'+data.mestype+'" session="'+data.session_no+'" class="recent-close">×</span></div></li>') } else { $('.con-tab-content .com-recent-box').prepend('<li class="session_no staff-info recent-hover" data-placement="right" group-name="'+data.accept_name+'" session_no="'+data.session_no+'" mes_id="'+data.mes_id+'" mestype ="'+data.mestype+'" ><div><span class="header-img"><img src="/chat/images/rens.png" alt=""></span><i>'+data.accept_name+'</i><span title = "删除聊天记录" mestype="'+data.mestype+'" session="'+data.session_no+'" class="recent-close">×</span></div></li>') } nearestContact.push(session_no); ws.send(JSON.stringify(data));};//最近联系人更新addContact.upd = function ( to_uid ) { if ( $('.recent-contact[session_no="'+session_no+'"]').index() != 0 ) { $('.con-tab-content .com-recent-box').prepend($('.recent-contact[session_no="'+session_no+'"]')); ws.send('{"type": "updContact", "to_uid": "'+to_uid+'", "session_no": "'+session_no+'", "message_type": "'+mes_type+'"}'); };}/******************* 消息列表session集合 *********************/var arrMessageList = new Array();arrMessageList = <?php echo !empty($messageSessionList) ? json_encode($messageSessionList) : json_encode([]);?>;//通知消息点击//外来的oms_id var ChainOmsId = '' ;$(document).on('click', '.chat_notice', function () { var session_id = $(this).attr('session_no'); var sender_id = $(this).attr('mes_id'); ChainOmsId = $(this).attr('oms_id'); $('.chat_notice_container').show(); // ws.send('{"type": "chat_notice", "sender_id": '+session_id+'}'); var con_mes_num = parseInt($(".mes_chakan_close[session_no='"+session_id+"']").attr('chat_mes_num')); mes_notice_close('message', sender_id, con_mes_num); nearestContact.push(session_id);})//群聊名字点击// $('.group-man-show').click(function (e){// // e.stopPropagation();// var obj = $(this);// var showMansessionNo = obj.attr('groupid');// if (!$(e.target).is('.groupSign')) {// gpManSh( showMansessionNo, 'showGroupMans_list' );// };// $('.group-man-show').removeClass('groupAct');// obj.addClass('groupAct');// obj.addClass('groupSign');// })//上传图片点击//触发文件点击var trig = function (obj){ obj.trigger('click');}$('#upclick').click( function(){ trig($('#file'));});$('#cli-upFile img').click(function(){ getQiniuToken(); trig($('#file')); return;}); // 选择图片的改变$('#send-upimg').on('change', function(){ //检验是否为图像文件 var obj = $(this); var file = $(this)[0].files[0]; $.each( $(this)[0].files, function (i, file){ if(!/image\/\w+/.test(file.type)){ alert("只能发送图片"); return false; } var reader = new FileReader(); //将文件以Data URL形式读入页面 reader.readAsDataURL(file); reader.onload=function(e){ var img = new Image(); img.src = this.result; img.className = "send-img"; $('.sending-img-box').html(''); $('.sending-img-box').append( img ); $('.send-clipboard-img').trigger('click'); $('.plus_menu_box').hide(); //显示文件 } });});//粘贴发送的图片取消$('.com-close-act').click(function(){ $('.img-box').hide();})//群聊删除人$(document).on('click', '.delgroupman', function(){ var obj = $(this); var groupid = obj.attr("groupid"); var id = obj.attr("id"); var dataType = obj.attr("data-type"); $('.alertvalue').attr('id', id); $(this).parent().addClass('mandel'); $('.mes_alert_con').html('你确定要删除他吗?'); $('.cd-popup').addClass('is-visible'); if ( dataType == "fri" ) { $('.alertvalue').attr('type', 'friDel'); } else { $('.alertvalue').attr('groupid', groupid); $('.alertvalue').attr('type', 'del'); } return false;});//退出群$('.esc-group').on('click', function (){ var groupId = $(this).attr('groupId'); ws.send('{"type": "esc_group", "groupId": "'+groupId+'"}'); $(this).parents('.panel').remove(); alert('退出群成功!'); return;})//群聊解散$('.dissolve-group').on('click', function (){ var groupId = $(this).attr('groupId'); ws.send('{"type": "dissolve_group", "groupId": "'+groupId+'"}'); $(this).parents('.panel').remove();})$('.alertvalue').on('click', function (){ var obj = $(this); var id = obj.attr("id"); $('.mandel').remove(); if ( obj.attr('type') == "del") { var groupid = obj.attr("groupid"); ws.send('{"type":"delgroupman", "groupid": "'+groupid+'", "id":"'+id+'"}'); } else if ( obj.attr('type') == "friDel" ) { ws.send('{"type":"delFriend", "uid":"'+id+'"}'); }})//删除最近联系人var delContactFun = function( id, mestype, session_id){ nearestContact = _chat_remove(session_no, nearestContact); // nearestContact.remove(session_no); $('.recent-action').parent('li').remove() ws.send('{"type": "delContact", "session_no":"'+session_id+'", "mestype":"'+mestype+'", "id": "'+id+'"}');};!function (window) { var omsChat = function () { this.v = '1.0.0'; } var call = {}; omsChat.prototype.singleChat = function (option) { var name ; to_uid = option.to_uid; to_uid_header_img = option.to_uid_header_img; mes_type = option.mes_type; session_no = parseInt( to_uid ) < parseInt( chat_uid ) ? to_uid+"-"+chat_uid : chat_uid+"-"+to_uid; name = option.name; if ($(window).width() < 700) { $('.chat-container').show(); $('.details-list').hide(); }; $('.chating-content .pc_he-ov-box').removeClass('chat_initial'); // 最近联系人的背景改变 $('.con-tab-content li').css('background', 'none'); $('.con-tab-content li[session_no='+session_no+']').css('background', '#BEB7C7'); //end // groupId = $(this).attr('groupId'); $('.chating-content .mes_title_con').html(name); // if (!$(e.target).is('.mes_chakan_close')) { if ($.inArray(session_no, arrMessageList) != -1) { var con_mes_num = parseInt($(".mes_chakan_close[session_no='"+session_no+"']").attr('chat_mes_num')); mes_chakan_close('message', to_uid, con_mes_num); }; // }; ws.send('{"type":"mes_chat", "to_uid":"'+to_uid+'"}'); var res = addSession.addSession(to_uid); $('.chating-content .mes_load').html(10); // 图片的清空 $('.loadImg').html(''); imgIndex = 0; //消息向上滚动 // 群聊里的人 消失 $('.chat-show-groupMan-box').remove(); $('.add-groupMan').remove(); $('.groupManShowIng').removeClass('groupManShowIng'); $('.chating-content .he-ov-box').unbind('scroll'); $('.chating-content .he-ov-box').bind("scroll", function (){ mesScroll(); }); } omsChat.prototype.complexChat = function () { }; omsChat.prototype.on = function(events, callback){ if(typeof callback === 'function'){ call[events] = callback; } return this; }; omsChat.prototype.ConSucCal = function () { call.connect(); } var sChat = new omsChat(); window.sChat = sChat;}(window);sChat.on('connect', function () { <?php if ( !empty($_GET['staffid']) ) { $options = [ 'to_uid'=>$_GET['staffid'], 'to_uid_header_img'=> $staffidInfo['card_image'], 'mes_type'=> 'message', 'name'=> $staffidInfo['name'], ]; echo "sChat.singleChat(". json_encode($options) .");"; }; ?>});// $(document).on('click', function () {// sChat.singleChat({// to_uid: 5// ,to_uid_header_img: ''// ,mes_type: 'message'// ,name: '赵桂坊'// });// })// 选择人聊天$(document).on('click', '.chat_people', function( e ){ var name,options; to_uid = $(this).attr('mes_id'); to_uid_header_img = $(this).find('img').attr('src'); name = $(this).attr('group-name') //会话id的改变 mes_type = "message"; options = { to_uid: to_uid ,to_uid_header_img: to_uid_header_img ,mes_type: 'message' ,name: name }; sChat.singleChat(options);})//选择群列表显示对话内容$(document).on('click', '.session_no', function ( event ){ var groupJson = ''; $('.pc_he-ov-box').removeClass('chat_initial'); session_no = $(this).attr('session_no')//会话id mes_type = $(this).attr('mestype')//会话id // if (session_no == $(this).attr('session_no')) { return ; }; //在手机上交替显示 if ($(window).width() < 700) { $('.chat-container').show(); $('.details-list').hide(); }; //end var valName = $(this).attr('group-name');//会话名字 // groupId = $(this).attr('groupId'); //消息向上滚动 $('.chating-content .he-ov-box').unbind('scroll'); $('.chating-content .he-ov-box').bind("scroll", function (){ mesScroll(); }) //背景颜色的改变 $('.con-tab-content li').css('background', 'none'); $('.con-tab-content li[session_no='+session_no+']').css('background', '#BEB7C7'); $('.mes_title_con').html(valName); // 加入聊天 addSession.addSession(session_no); $('.mes_title').append('<i title="群聊添加人" class="add-groupMan"></i>'); if ( mes_type == 'groupMessage' ) { $('.mes_title_con').append('<i class = "dropDown-showMan-n"></i>'); $('.add-groupMan').show(); groupJson = '{"type":"mes_groupChat", "session_no":"'+session_no+'" }'; } else if ( mes_type == 'adminMessage' ) { groupJson = '{"type":"chatAdmin", "session_no":"ca" }'; }; // if (!$(event.target).is('.mes_chakan_close')) { var mesCC = $(".mes_chakan_close[session_no='"+session_no+"']"); // 是否 有人 @ if ( mesCC.length > 0 ) { if ( mesCC.find('.mention').length > 0 ) { var mentionName = mesCC.find('.mention').attr('data-name'); mentionNotice ( mentionName ); }; var con_mes_num = parseInt($(".mes_chakan_close[session_no='"+session_no+"']").find('.mes_num').html()); mes_chakan_close( mes_type, session_no, con_mes_num ); }; // }; ws.send(groupJson); $('.chating-content .mes_load').html(10); // 图片的清空 $('.loadImg').html(''); imgIndex = 0; // 群聊的人 重置 $('.chat-show-groupMan-box').remove(); $('.groupManShowIng').removeClass('groupManShowIng');});//群聊 操作 事件$(function(){ var GroupOperation = function () { this.groupName = $('.group-man-show'); this.groupid = ''; var slef = this; this.sg = $('.mes_con_box'); this.groupName.click(function ( e ) { var obj = $(this); var showMansessionNo = obj.attr('groupid'); if (!$(e.target).is('.groupSign')) { slef.gpManSh( showMansessionNo, 'showGroupMans_list' ); }; $('.group-man-show').removeClass('groupAct'); obj.addClass('groupAct'); obj.addClass('groupSign'); }); } GroupOperation.prototype = { init: function ( obj ) { var slef = this; obj.click(function (e) { console.log(43333); if ( message_type == 'groupMessage' ) { return false; }; e.stopPropagation(); // var groupid = $(this).attr('groupid'); if ( $(this).hasClass('groupManShowIng') ) { $('.chat-show-groupMan-box').slideToggle("slow", function () { if ( $('.chat-show-groupMan-box').css('display') == 'none' ) { $('.dropDown-showMan-n').css('background-image', "url(/chat/images/xialaIng.png)"); } else { $('.dropDown-showMan-n').css('background-image', "url(/chat/images/xiala.png)"); } }); return false; }; $(this).addClass('groupManShowIng'); slef.gpManSh( session_no, 'TshowGroupMans_list' ); // ws.send('{"": "", "": "", "": ""}'); }) }, gpManSh: function (groupid, Callback) { ws.send('{"type": "groupManShow", "Callback":"'+Callback+'", "session_id":"'+groupid+'"}'); } } var GroupOperationObj = new GroupOperation(); GroupOperationObj.init( $('.mes_title_con') ); window.GroupOperationObj = GroupOperationObj;})// 有人@var mentionNotice = function ( name ) { var mentionNoticeObj = $('<div class = "mentionNotice" style="position: relative"><div style ="position: absolute; top: 0; width: 100%;height: 30px;line-height: 30px;text-align: center;background-color: #A27373;color: #fff;z-index: 999">'+name+'@你</div></div>'); $('.mes_con_box').prepend(mentionNoticeObj); setTimeout('$(".mentionNotice").fadeOut(1000)', 4000);}//删除最近联系人$(document).on('click', '.recent-action', function (e) { e.stopPropagation(); var r=confirm("要从联系人中删除他吗?"); if ( r == false ) { return false; }; var delconid = ($(this).attr('delconid')); var session_id = ($(this).attr('session_no')); delContactFun( delconid, mes_type, session_id );})//enter 提交$(".mes_footer, .pc_mes_input").keydown(function(e){ var e = e || event, keycode = e.which || e.keyCode; if(e.shiftKey && (e.keyCode==13)){ var localSend = localStorage.getItem('sendForm'); if ( localSend == '1' ) { e.preventDefault(); var inputValue = $('.pc_mes_input').html(); $('#mes_textarea').html(inputValue); $('.pc_mes_input').html(''); $("#submit").trigger("click"); }; } else if (keycode==13) { var localSend = localStorage.getItem('sendForm'); if ( !localSend || localSend == '0' ) { e.preventDefault(); var inputValue = $('.pc_mes_input').html(); $('#mes_textarea').html(inputValue); $('.pc_mes_input').html(''); $("#submit").trigger("click"); }; }}); //消息提交var mesParam = { mes_obj: function (){ if (to_uid == 0 && session_no == 0) { $('.mes_alert_con').html('请选择聊天对象!') $('.cd-popup').addClass('is-visible'); return false; } else { return true; } }, mes_empty: function (){ if ($('#mes_textarea').html() =='') { $('.mes_alert_con').html('消息不能为空!') $('.cd-popup').addClass('is-visible'); return false; } else { return true; } },};/*********** 文件发送 ******************///发送文件 //请求 tokenfunction xmlhttp() { var $xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari $xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 $xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } return $xmlhttp;}// 请求token var getQiniuToken = function () { $xmlhttp = xmlhttp(); $xmlhttp.onreadystatechange = function() { if ($xmlhttp.readyState == 4) { if($xmlhttp.status == 200){ document.getElementById('token').value = $xmlhttp.responseText; } else { alert('get uptoken other than 200 code was returned') } } } $upTokenUrl = '/chat/uptoken.php'; $xmlhttp.open('GET', $upTokenUrl, true); $xmlhttp.send(); $file = document.getElementById('file');};//消息提交var Qiniu_UploadUrl = "http://up.qiniu.com";var progressbar = $("#progressbar"),progressLabel = $(".progress-label");progressbar.progressbar({ value: false, change: function() { $('#progressbar').show(); // progressLabel.text(progressbar.progressbar("value") + "%"); }, complete: function() { $('#progressbar').hide(); // progressLabel.hide(); // progressLabel.text("Complete!"); }});//普通文件上传var Qiniu_upload = function(f, token, key, sendType) { var xhr = new XMLHttpRequest(); xhr.open('POST', Qiniu_UploadUrl, true); var formData, startDate; formData = new FormData(); if (key !== null && key !== undefined) formData.append('key', key); formData.append('token', token); formData.append('file', f); var taking; xhr.upload.addEventListener("progress", function(evt) { if (evt.lengthComputable) { var nowDate = new Date().getTime(); taking = nowDate - startDate; var x = (evt.loaded) / 1024; var y = taking / 1000; // var uploadSpeed = (x / y); // var formatSpeed; // if (uploadSpeed > 1024) { // formatSpeed = (uploadSpeed / 1024).toFixed(2) + "Mb\/s"; // // $('#formatSpeed').html(formatSpeed); // } else { // formatSpeed = uploadSpeed.toFixed(2) + "Kb\/s"; // // $('#formatSpeed').html(formatSpeed); // } var percentComplete = Math.round(evt.loaded * 100 / evt.total); progressbar.progressbar("value", percentComplete); // console && console.log(percentComplete, ",", formatSpeed); } }, false); xhr.onreadystatechange = function(response) { console.log(xhr.status == 200); if (xhr.readyState == 4 && xhr.status == 200 && xhr.responseText != "") { var blkRet = JSON.parse(xhr.responseText); document.getElementById('key').value = blkRet.key; document.getElementById('filename').value = blkRet.fname; onSubmit(to_uid, chat_uid, groupId, mes_type, sendType, session_no); // console && console.log(blkRet); } else if (xhr.status != 200 && xhr.responseText) { var blkRet = JSON.parse(xhr.responseText); // onSubmit(to_uid, chat_uid, groupId, mes_type, 'file',session_no); console.log(blkRet); alert('发送失败!'); return false; // console.log(blkRet); } }; startDate = new Date().getTime(); $("#progressbar").show(); xhr.send(formData);}; //发送文件$('#file').on('change', function (){ var nowTime = new Date().getTime(); var sendType = 'file'; if (!mesParam.mes_obj()) { $(this).val(''); return false; }; if ($("#file")[0].files.length > 0 && token != "") { for (var i = 0; i < $("#file")[0].files.length; i++) { $key = $("#file")[0].files[i].name; document.getElementById('filename').value = $key; $key ='file/'+chat_uid+'/'+to_uid+'/'+nowTime+'/'+$key; document.getElementById('key').value = $key; var token = $("#token").val(); if(/image\/\w+/.test($(this)[0].files[i].type)){ sendType = 'images'; } else { sendType = 'file'; } Qiniu_upload($("#file")[0].files[i], token, $key, sendType); // $.each( $(this)[0].files, function (i, file){ // if(/image\/\w+/.test(file.type)){ // sendType = 'images'; // } // }) }; }else { console && console.log("form input error"); } $(".plus_menu_box").hide(); });//会话提交document.getElementById('submit').onclick = function (){ //接收人名字 if (!mesParam.mes_obj() || !mesParam.mes_empty()) { return false; }; if (mes_type == 'groupMessage') { to_uid_header_img = '/chat/images/rens.png'; } // if ($('.recent-hover[session_no="'+session_no+'"]').length == 0) { if ( $.inArray(session_no, nearestContact) == -1 ) { addContact.Dom(); } else { addContact.upd( to_uid ); } // H5AppDB.indexedDB.selectData(data) onSubmit(to_uid, chat_uid, groupId, mes_type, 'text',session_no);};//消息提交document.getElementsByClassName('send-clipboard-img')[0].onclick = function (){ //接收人名字 if (!mesParam.mes_obj()) { return false; }; onSubmit(to_uid, chat_uid, groupId, mes_type, 'image',session_no);};//通知消息关闭var mes_notice_close = function (mestype, session_id, mes_num){ ws.send('{"type":"mes_notice_close", "to_uid":"'+session_id+'", "mestype":"'+mestype+'"}'); mesnum = mesnum - parseInt(mes_num); $('.mes_radio').html(mesnum); session_id = session_id + 't'; $('.mes_chakan_close[session_no="'+session_id+'"]').remove(); arrMessageList = _chat_remove(session_id, arrMessageList); // arrMessageList.remove(session_id);}//消息的关闭var mes_chakan_close = function (mestype, session_id, mes_num){ if ( $.inArray(session_no, nearestContact ) == -1 ) { addContact.Dom(); } else { addContact.upd( session_id ); } if ( mestype == 'message' ) { session_no = parseInt(chat_uid) < parseInt( session_id ) ? chat_uid+"-"+session_id : session_id+"-"+chat_uid; } else if ( mestype == 'groupMessage' || mestype == 'adminMessage' ) { session_no = session_id; } ws.send('{"type":"mes_close", "to_uid":"'+session_id+'", "session_no": "'+session_no+'", "message_type":"'+mestype+'"}'); mesnum = mesnum - parseInt(mes_num); $('.mes_radio').html(mesnum); $('.mes_chakan_close[session_no="'+session_no+'"]').remove(); arrMessageList = _chat_remove(session_no, arrMessageList); // arrMessageList.remove(session_no);}var mes_NoChakan_close = function (mestype, session_id, mes_num){ // if ( $.inArray(session_no, nearestContact ) == -1 ) { // addContact.Dom(); // } else { // addContact.upd( session_id ); // } if ( mestype == 'message' ) { session_close_no = parseInt(chat_uid) < parseInt( session_id ) ? chat_uid+"-"+session_id : session_id+"-"+chat_uid; } else { session_close_no = session_id; } ws.send('{"type":"mes_close", "to_uid":"'+session_id+'", "session_no": "'+session_close_no+'", "message_type":"'+mestype+'"}'); mesnum = mesnum - parseInt(mes_num); $('.mes_radio').html(mesnum); $('.mes_chakan_close[session_no="'+session_close_no+'"]').remove(); arrMessageList = _chat_remove(session_close_no, arrMessageList); // arrMessageList.remove(session_close_no);}//消息的关闭$(document).on('click', '.mes_close', function ( e ){ e = e || window.event; e.stopPropagation(); //阻止冒泡 var mestype = $(this).attr('mestype'); var mes_num = $(this).prev('.mes_num').html(); // session_no = $(this).attr('session_no'); mes_id = $(this).attr('mes_id'); mes_NoChakan_close(mestype, mes_id, mes_num);});// function getCursortPosition (ctrl) {//获取光标位置函数// var CaretPos = 0; // // IE Support // if (document.selection) { // ctrl.focus ();// var Sel = document.selection.createRange ();// Sel.moveStart ('character', -ctrl.value.length); // CaretPos = Sel.text.length; // } // // Firefox support // else if (ctrl.selectionStart || ctrl.selectionStart == '0') {// CaretPos = ctrl.selectionStart;// return (CaretPos); // }// }// //2.设置光标位置// function setCaretPosition(ctrl, pos){//设置光标位置函数 // if(ctrl.setSelectionRange)// { // ctrl.focus();// ctrl.setSelectionRange(pos,pos);// } else if (ctrl.createTextRange) {// var range = ctrl.createTextRange(); // range.collapse(true); // range.moveEnd('character', pos);// range.moveStart('character', pos); // range.select();// } // }function doGetCaretPosition (oField) { // Initialize var iCaretPos = 0; document.getSelection(); // IE Support if (document.selection) { // Set focus on the element oField.focus(); // To get cursor position, get empty selection range var oSel = document.selection.createRange(); // Move selection start to 0 position oSel.moveStart('character', -oField.value.length); // The caret position is selection length iCaretPos = oSel.text.length; } // Firefox support else if (oField.selectionStart || oField.selectionStart == '0'){ iCaretPos = oField.selectionStart; } // Return results return iCaretPos;}// function getCursortPosition (ctrl) {// //获取光标位置函数 // var CaretPos = 0; // // IE Support // if (document.selection) { // ctrl.focus ();// var Sel = document.selection.createRange ();// Sel.moveStart ('character', -ctrl.value.length);// CaretPos = Sel.text.length; // } // // Firefox support // else if (ctrl.selectionStart || ctrl.selectionStart == '0') {// CaretPos = ctrl.selectionStart; return (CaretPos);// }// }// 获取光标 粘贴/*向光标 后插入 内容@parm html 要插入的内容@parm bool 是否 把内容转换 html 实体*/function insertHtmlAtCaret(html, bool) { var sel, range; if (window.getSelection) { // IE9 and non-IE sel = document.getSelection(); if (sel.getRangeAt && sel.rangeCount) { range = sel.getRangeAt(0); range.deleteContents(); // sel.getRangeAt(0).commonAncestorContainer; // console.log(sel.getRangeAt(0).commonAncestorContainer); // Range.createContextualFragment() would be useful here but is // non-standard and not supported in all browsers (IE9, for one) var el = document.createElement("div"); if ( bool ) { html = html.replace(/</g, "<").replace(/>/g, ">"); }; el.innerHTML = html; var frag = document.createDocumentFragment(), node, lastNode; while ( (node = el.firstChild) ) { lastNode = frag.appendChild(node); } range.insertNode(frag); // Preserve the selection if (lastNode) { range = range.cloneRange(); range.setStartAfter(lastNode); range.collapse(true); sel.removeAllRanges(); sel.addRange(range); } } } else if (document.selection && document.selection.type != "Control") { // IE < 9 document.selection.createRange().pasteHTML(html); }}//粘贴图片$(function(){ var imgReader = function( item ){ var blob = item.getAsFile(), reader = new FileReader(); reader.onload = function( e ){ var img = new Image(); img.src = e.target.result; img.className = "send-img"; $('.sending-img-box').html(''); $('.sending-img-box').append( img ); $('.img-box').show(); }; reader.readAsDataURL( blob ); }; // $('.pc_mes_input').bind('paste', function ( e ) { // $('#mes_textarea').trigger('paste'); // }) var pasteEvnet = function ( e ) { e.preventDefault(); var clipboardData = e.clipboardData, i = 0, items, item, types; if (!clipboardData.items) { //chrome insertHtmlAtCaret(clipboardData.getData('text/plain'), true); return false; } if( clipboardData ){ items = clipboardData.items; if( !items ){ return; } item = items[0]; types = clipboardData.types || []; for( ; i < types.length; i++ ){ if( types[i] === 'Files' ){ item = items[i]; break; } } if ( item && item.kind === 'string') { insertHtmlAtCaret(clipboardData.getData('text/plain'), true ); // $( '#pc_mes_input' ).append( clipboardData.getData('text/plain') ); inputSave += clipboardData.getData('text/plain'); // $( '#pc_mes_input' ).on('input', function () { // console.log($(this).html()); // }) return; }; if( item && item.kind === 'file' && item.type.match(/^image\//i) ){ imgReader( item ); } } } //粘贴事件 document.getElementById( 'mes_textarea' ).addEventListener( 'paste', function( e ){ pasteEvnet( e );return; }) //粘贴事件 document.getElementById( 'pc_mes_input' ).addEventListener( 'paste', function( e ){ pasteEvnet( e );return; }) });//聊天对话框img放大$(document).on( 'click', '.he_ov .send-img', function (){ var curIndex = $(this).attr('index'); $('.viewer-container').remove(); $(".loadImg").viewer(); $(".loadImg img").eq(parseInt(curIndex)).trigger('click');});// $('.send-img-close, .send-img-box').click( function (event){// if ($(event.target).is('i')) {// return false;// };// $('.send-img-box').hide();// })//得到人员头像var getStaffHead = function ( headImg ){ to_uid_header_img = headImg;};//组织架构的引用// console.log(sidList)//button确定$('#b_is').click(function (){ var sidList = [1]; var val = $(this).attr('val'); if ( typeof friendMap != 'undefined' ) { Array.prototype.push.apply(sidList, friendMap); }; if (val == "selman") { //在手机上交替显示 // if ( $(window).width() < 500 ) { // $('.chat-container').show(); // $('.details-list').hide(); // }; // //end // var jsonText = JSON.stringify(sidList); // if (sidList.length >1) { // alert('只能选择一个人!');return false; // }; // to_uid = sidList[0]; // ws.send('{"type":"mes_chat", "to_uid":"'+to_uid+'"}'); // $('.chating-content .mes_load').html(10); // mes_type = "message"; // //会话id的改变 // if ( parseInt(to_uid) < parseInt(chat_uid) ) { // session_no = to_uid+"-"+chat_uid; // } else { // session_no = chat_uid+"-"+to_uid; // } // //消息向上滚动 // $('.chating-content .he-ov-box').unbind('scroll'); // $('.chating-content .he-ov-box').bind("scroll", function (){ // mesScroll(); // }) // $.ajax({ // url:'getndp.php', // data:'jsonText='+jsonText, // type:'post', // success:function(data){ // var d=eval('('+data+')') // for (var i = 0; i < d.length; i++) { // $('.chating-content .mes_title_con').html(d[i].name); // getStaffHead(d[i].card_image); // } // } // }) } else if ( val == "addGroupMan" ) { // sidList = 1; // $('.chat_alert').show(500); // setTimeout(function(){ // $('.chat_alert').hide(500); // },2000); // ws.send('{"type":"addGroupMan", "session_no":"'+session_no+'", "sidList":['+sidList+']}'); } else if ( val == "share" ) { // to_uid = sidList[0]; // var session_id ; // var content = $('.chat-shareing').attr('data-placement'); // if ( parseInt(to_uid) < parseInt(chat_uid) ) { // session_id = to_uid+"-"+chat_uid; // } else { // session_id = chat_uid+"-"+to_uid; // } // $('.chat_alert p').html('已分享!'); // $('.chat_alert').show(500); // setTimeout(function(){ // $('.chat_alert').hide(500, function (){ // $('.chat_alert p').html('恭喜您操作成功!'); // }); // },2000); // ws.send('{"type":"sayUid","to_uid":"'+to_uid+'","groupId":"", "accept_name":"'+accept_name+'","message_type":"message", "mes_types":"file","session_no":"'+session_id+'","content":"'+content+'"}'); } else if ( val == "vaChat" ) {// sidList = _chat_remove(chat_uid, sidList);// // sidList.remove(chat_uid);// ajaxSidList = sidList;// $.ajax({// url: '/chat/va-chat/ajax_getToken.php?createSession=1',// data: 'createSession=1',// type: 'post',// success: function (data) {// // ws.send('{"type": "vaAnswer", "client_id": "'+client_id+'", "act": "'+act+'", "session_id": "'+data[1].session_id+'"}');// ws.send('{"type": "va","session_id": "'+data+'", "act": "vM","to_uid": "'+ajaxSidList+'"}');// window.location.href="https://www.omso2o.com/chat/va-chat/vaChat.php?session_id="+data+"&Invitation=1";// // window.open("https://www.omso2o.com/chat/va-chat/vaChat.php?session_id="+data+"&Invitation=1");// },// }) }; $('#name_box').hide(); $('.selected').find('div').html('<ul class="unique_ul"></ul>'); $('#No1').find('.ltclasscheckbox').attr('checked',false); $('.select_member_num').html($('.selected').find('sid').length+'/'+$('#No1').find('sid').length); sidList=[];})// 组织架构 button取消// $('#b_no').click(function(){// $('#name_box').hide();// })/*********************** end *******************************//************************ 非业务处理 ***********************/// function vMChat( obj ) {// window.event? window.event.cancelBubble = true : evt.stopPropagation();// $('#b_is').attr('val', 'vaChat');// $('#name_box').show();// }var vaChat = function ( obj ) { //接收人名字 if (!mesParam.mes_obj() || $('.vaChat').length > 0) { return false; }; if ( mes_type == 'groupMessage' ) { if ( !confirm('你确定要开启群视频吗?') ) { return false; }; $.ajax({ url: '/chat/va-chat/ajax_getToken.php?createSession=1', data: 'createSession=1', type: 'post', success: function (data) { ws.send('{"type":"sayUid","to_uid":"0","senderid":"'+chat_uid+'", "groupId":"0", "accept_name":"'+$('.chating-content .mes_title_con').text()+'","message_type":"groupMessage", "mes_types":"va","session_no":"'+session_no+'","content":"'+data+'"}'); // ws.send('{"type": "vaAnswer", "client_id": "'+client_id+'", "act": "'+act+'", "session_id": "'+data[1].session_id+'"}'); // window.location.href="https://www.omso2o.com/chat/va-chat/vaChat.php?session_id="+data[1].session_id+"&Invitation=1"; // window.open("https://www.omso2o.com/chat/va-chat/vaChat.php?session_id="+data[1].session_id+"&Invitation=1"); } }) return false; } var type = obj.getAttribute('data-para'); var wait = $('<div>正在等待对方连接.....</div>'); wait.addClass('vaChat'); var cancel = $('<span>取消</span>'); cancel.click(function () { $(this).parent().remove(); // session_no = parseInt( to_uid ) < parseInt( chat_uid ) ? to_uid+"-"+chat_uid : chat_uid+"-"+to_uid; ws.send('{"type":"vaChat","to_uid":"'+to_uid+'","senderid":"'+chat_uid+'", "groupId":"0", "accept_name":"'+ $('.chating-content .mes_title_con').text()+'","message_type":"message", "mes_types":"text","session_no":"'+session_no+'","content":"语音取消"}'); // {"type":"sayUid","to_uid":"'++'","senderid":"4", "groupId":"0", "accept_name":"赵桂芳","message_type":"message", "mes_types":"text","session_no":"4-5","content":"语音取消"} // ws.send('{"type":"vaCancel", "to_uid": }'); }); wait.append(cancel); $('body').append(wait); ws.send('{"type": "va", "act": "'+type+'","to_uid": "'+to_uid+'"}');}// 会话 添加var AddSession = function () { this.sessionList = new Array(); this.index = 0;}AddSession.prototype.addSession = function (session_id) { this.sessionList = []; this.sessionList.push(session_id); return true;};AddSession.prototype.mesnum = function ( uid ) { // 找出 和谁在聊天 return -1;}// 实例化 增加 会话 var addSession = new AddSession();// 客户那里 消息关闭var chatCustomerNotice = function () { var session_id = chat_uid+'sn'; var closeObj = $('.mes_chakan_close[session_no="'+session_id+'"]'); var objLength = closeObj.length; ws.send('{"type":"sys_mes_close", "message_type":"message"}'); mesnum = mesnum - parseInt(objLength); $('.mes_radio').html(mesnum); closeObj.remove();};//系统通知的关闭$(document).on('click', '.chat_close',function () { $(this).parent().hide(500);})// 消息通知 里的系统通知 点击$('.chat_customer_notice').on( 'click', function (){ var htmlCon = $(this).find('.chat_mes_content').html(); // var mes_num = $(this).attr( 'chat_mes_num' ); chatCustomerNotice(); chatSystemNotice();})// 输入框的 列表 $('.pc_mes_tool_list').hover(function () { $(this).css('opacity', 0.5 );}, function () { $(this).css('opacity', 1 );})//用设置增加的classvar setuUserinfo = { VoiceState: { listClass: ['voiceOff','voiceOn'], listSwitch: 0, listText: ['关闭声音','开启声音'] }, desktopState: { listClass: ['deskOff','deskOn',], listSwitch: 1, listText: ['关闭桌面通知','开启桌面通知'] }};//用户默认设置储存本地// var setuUserinfo = {// VoiceState: 1,// }//页面加载$(function () { $.each( setuUserinfo, function ( i, o) { if ( localStorage.getItem(i) == null ) { localStorage.setItem( i, o.listSwitch ); } else { setuUserinfo[i].listSwitch = localStorage.getItem( i ); } setUserAll( i, setuUserinfo[i].listSwitch ); })})var setUserAll = function ( oc, state ) { state = parseInt(state); var obj = $(".chat-set-user li."+oc); var changeClass = setuUserinfo[oc].listClass[state]; var changeHtml = setuUserinfo[oc].listText[state]; obj.html('<i class ="'+changeClass+'"></i>'+changeHtml); obj.addClass(changeClass); state = state == 1 ? 0 : 1; obj.attr('set-switch', state);}$('.chat-set-user li').click(function () { var _this = $(this); var setClass = _this.attr('set-data'); var setSwitch = _this.attr('set-switch'); setUserAll(setClass, setSwitch); localStorage.setItem( setClass, setSwitch ); setuUserinfo[setClass].listSwitch = setSwitch;});//!function($) { var types = ['notice', 'warning', 'error', 'success']; var audio; var settings = { inEffect: { opacity: 'show' }, inEffectDuration: 100, stay: 5000, sticky: false, type: 'notice', position: 'top-right', sound: '/chat/audio/notice.wav', }; function dataSetting(el, options, name) { var data = el.data('notify-' + name); if (data) options[name] = data; }; var Notify = function(el, options){ var el = $(el); var $this = this; var dataSettings = {}; $.each(['type','stay','position'], function(k, v){ dataSetting(el, dataSettings, v); }); if (el.data('notify-sticky')) { dataSettings['sticky'] = el.data('notify-sticky') == 'yes'; } this.opts = $.extend({}, settings, dataSettings, typeof options == 'object' && options); // 检查 type 配置里面是否有 sticky 值 if (this.opts.type.indexOf('sticky') > -1) { this.opts.sticky = true; this.opts.type = $.trim(this.opts.type.replace('sticky','')); } // 检查 type 类型是否支持 if (types.indexOf(this.opts.type) == -1) { this.opts.type = settings.type; } var wrapAll =$('.mesNoticeContainer'); var itemOuter = $('<div></div>').addClass('notify-item-wrapper'); this.itemInner = $('<div></div>').show().addClass('mesNotice').appendTo(wrapAll).animate(this.opts.inEffect, this.opts.inEffectDuration).wrap(itemOuter); $('<div>×</div>').addClass('mesNoticeClose').prependTo(this.itemInner).click(function(){$this.close()}); $('<div><img src = "'+options.imgUrl+'"></div>').addClass('mesNoticeImg').appendTo(this.itemInner); $('<div>'+options.tittle+'</div>').addClass('mesNoticeTittle').appendTo(this.itemInner); $('<div>'+options.content+'</div>').addClass('mesNoticeCon').appendTo(this.itemInner); navigator.userAgent.match(/MSIE 6/i) && wrapAll.css({top: document.documentElement.scrollTop}); !this.opts.sticky && setTimeout(function(){$this.close()}, this.opts.stay); var VoiceState = localStorage.getItem('VoiceState'); if ( VoiceState == '0' ) { if (window.HTMLAudioElement) { audio = new Audio(); audio.src = options['soundUrl']; audio.play(); } } }; Notify.prototype.close = function () { var obj = this.itemInner; obj.animate({opacity: '0'}, 600, function() { obj.parent().animate({height: '0px'}, 300, function() { obj.parent().remove(); }); }); }; // $.notifySetup = function(options) { // $.extend(settings, options); // // console.log(options); // if (options['sound']) { // if (window.HTMLAudioElement) { // audio = new Audio(); // audio.src = options['sound']; // } // } // }; $.fn.notify = function(options) { return this.each(function () { if (typeof options == 'string') { return new Notify(this, {type: options}); } return new Notify(this, options); }); };}(window.jQuery);// 最近联系人 搜索$('#search-ren').on('input', function () { var inValue = $.trim($(this).val().toString());//去掉两头空格 var searchRenRes = $('.search-ren-res'); if ( inValue == '') { searchRenRes.hide(); return; }; // $(this).parent().hide(); var resSearch = search_in('contacts_name', inValue, $recentContact); searchRenRes.html(''); for (var i in resSearch ) { if (resSearch[i].mestype != 'message') { searchRenRes.append('<li class="session_no" data-placement="right" group-name="'+resSearch[i].contacts_name+'" delConId = '+resSearch[i].id+' session_no="'+resSearch[i].session_no+'" mes_id="'+resSearch[i].mes_id+'" mestype ="'+resSearch[i].mestype+'" ><span class="header-img"><img src="/chat/images/rens.png" alt=""></span><i>'+resSearch[i].contacts_name+'</i><span title = "从列表中删除" mestype="'+resSearch[i].mestype+'" delConId = '+resSearch[i].id+' session="'+resSearch[i].session_no+'" class="recent-close">×</span></li>'); } else { searchRenRes.append('<li class="recent-contact content-staff-info chat_people" data-placement="right" group-name="'+resSearch[i].contacts_name+'" delConId = '+resSearch[i].id+' session_no="'+resSearch[i].session_no+'" mes_id="'+resSearch[i].mes_id+'" mestype ="'+resSearch[i].mestype+'" ><span class="header-img"><img src="'+resSearch[i].card_image+'" alt=""></span><i>'+resSearch[i].contacts_name+'</i><span title = "从列表中删除" mestype="'+resSearch[i].mestype+'" delConId = '+resSearch[i].id+' session="'+resSearch[i].session_no+'" class="recent-close">×</span></li>'); } } searchRenRes.show();})//人员的搜索$('.search_staff').click(function () { $('#search_in').trigger('input');})//在线人员信息var onlineManInfo = new Array(); $('#search_in').on('input', function () { var inValue = $.trim($(this).val().toString());//去掉两头空格 if ( inValue == '') { $('.search_result').hide(); return; }; var resSearch = search_in('client_name', inValue, onlineManInfo); $('.search_result').html(''); for (var p in resSearch ) { $('.search_result').append('<li mes_id="'+p+'" data-placement="left" class="staff-info chat_people db_chat_people" group-name="'+resSearch[p].client_name+'"><span class="header-img"><img src="'+client_list[p].header_img_url+'" alt="'+resSearch[p].client_name+'"></span><span style = "color: red">'+resSearch[p].client_name+'</span></li>'); } $('.search_result').show();})//搜索在线人数返回 搜索结果var search_in = function (index, inValue, array) { //在线的人的名字 var clientName = ''; //返回的数组 var resData = {}; for (var i in array ) { clientName = array[i][index]; if (typeof array[i] == 'object' ) { if ( clientName.indexOf(inValue) != -1 ) { resData[i] = array[i]; }; }; } return resData;}//pc inout 的高度var inputBottom = $('.he-ov-box').css('bottom');//pc 表情的显示$('.pc_mes_tool_emoji').click(function () { var obj = document.getElementById('pc_mes_input'); $('.pc_emoji_box').show(500); addempath("pc_emoji_box");})//通知消息关闭$('.chat_notice_close').click(function () { $('.chat_notice_container').hide(500);})//提示消息var alertMes = function ( con ) { $('.alertMesCon').text(con); $('.alert').show(500); setTimeout(function(){ $('.alert').hide(500); },2000);}//客服滑过$('.kefu-icon').hover(function (e){ $('.kefu-icon .kefu').stop().animate({ top: 0, })},function (e){ $('.kefu-icon .kefu').stop().animate({ top: 40, })});//判断是不是移动端function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); var flag = true; for (var v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } } return flag; } //人员滑过$(document).on('mouseover', '.list-group .recent-hover', function (){ $('.recent-action').removeClass('recent-action'); $(this).find('.recent-close').addClass('recent-action');})//人员离开$(document).on('mouseout', '.list-group .recent-hover', function (){ $('.recent-action').removeClass('recent-action');})//消息在线人数拖动var mes_bottom = parseInt($('.mes_fixed').css('bottom'));$('.mes_fixed').swipe( { swipeStatus:function(event, phase, direction, distance, duration, fingerCount) { if (direction == 'down' && mes_bottom > 0) { // console.log(distance) $('.mes_fixed').css('bottom', mes_bottom - distance); // console.log($('.mes_fixed').css('bottom')) } else if (direction == 'up') { // console.log(distance) $('.mes_fixed').css('bottom', distance + mes_bottom); }; if (phase == 'cancel' || phase == 'end') { mes_bottom = parseInt($('.mes_fixed').css('bottom')); }; },});//群聊参加人滑过事件$(document).on('mouseover', '.group-people',function(){ $(this).find('.delgroupman').show();})$(document).on('mouseout', '.group-people', function(){ $(this).find('.delgroupman').hide();})//对话框的高度var mesHeight = 0;//查看更多$(document).on("click", '.onload', function(){ $('.he-ov-box').trigger("scroll");})// 好友点击$('.fri-icon').click( function () { // $('.sanjiao').hide(); // $('.fri-sanjiao').show(); $('.com-recent-box').hide(); $('.friends-list-box').show();})//联系人tab$('.tab-title').click(function(){ var index = $(this).index(); var ind = $(this).attr('ind'); $('.tab-chat').hide(); $('.sanjiao').show(); $('.fri-sanjiao').hide(); $('.com-recent-box').show(); $('.friends-list-box').hide(); if ( $('.chat-main-footer ul li').hasClass('foot-curColor') ) { $('.footer-friend').removeClass('foot-curColor'); }; $('.tab-chat').eq(ind).show(); //小三角移动 $('.sanjiao').animate({left:((index+1)*2-1)*12.5+"%"}, 'linear');})//对话框关闭$('.mes_dclose').on('click', function (){ $('.chat-container').hide(); $('.details-list').show();})//滚动条滚动事件var mesScroll = function (){ if ($(".chating-content .he-ov-box").scrollTop() == 0 ) { var mes_loadnum = $('.chating-content .mes_load').html(); $('.chating-content .loader').show() mesHeight = $('.chating-content .he_ov').height() ws.send('{"type":"mes_load","mes_loadnum":"'+mes_loadnum+'", "message_type":"'+mes_type+'", "to_uid":"'+to_uid+'","session_no": "'+session_no+'"}'); };}//删除指定数组元素// Array.prototype.remove = function(val) {// var index = this.indexOf(val);// if (index > -1) {// this.splice(index, 1);// }// };//删除指定数组元素var _chat_remove = function (val, array) { var index = array.indexOf(val); if (index > -1) { array.splice(index, 1); } return array;}//表情的添加function addempath(className) { var emPath = "<?php echo DOCUMENT_URL?>/chat/emoticons/images/";//表情路径 var total = 134;//表情的个数 var newTotal = 14;//新增表情的个数 $('.'+className).html(''); for(var i=0; i < newTotal ; i++) { $('.'+className).append('<div class="em_gif"><img width="24px" class="cli_em" em_name="'+'f'+i+'" src="'+emPath+'f'+i+'.gif"></div>'); } for(var i=0; i < total ; i++) { $('.'+className).append('<div class="em_gif"><img width="24px" class="cli_em" em_name="'+i+'" src="'+emPath+i+'.gif"></div>'); }}//加号的单击$(".plus_icon").click( function (){ $(".plus_menu_box").toggle();});//pc 输入框聚焦$('.pc_mes_input').focus( function () { $(".pc_emoji_box").hide(); $(".he-ov-box").css("bottom", inputBottom); $(".he-ov-box").scrollTop($(".he-ov-box")[0].scrollHeight);})//输入框聚焦$('#mes_textarea').focus( function(){ $(".emoticons").hide(); var inputHeight = $('.mes_footer').height();// 输入框的高度 $(".he-ov-box").css("bottom", inputHeight); $(".he-ov-box").scrollTop($(".he-ov-box")[0].scrollHeight);})//表情的点击事件$(document).on('click', ".emoticons .cli_em, .pc_emoji_box .cli_em", function (event){ event.stopPropagation(); var em_name = $(this).attr('em_name'); var obj = document.getElementById('pc_mes_input'); obj.focus(); var cursor; inputSave = inputSave + "{|"+em_name+"|}"; var addThis = $(this).clone(); addThis.appendTo('#mes_textarea'); addThis = $(this).clone(); $(obj).append(addThis); obj.focus(); // insertHtmlAtCaret(addThis[0].outerHTML, false); // addThis.appendTo('#pc_mes_input'); // $('textarea').val($('.textarea').html())})//表情的显示$('.header_icon').click(function () { addempath('emoticons'); $(".emoticons").toggle(); $(".plus_menu_box").hide(); var inputHeight = $('.mes_footer').height();// 输入框的高度 $(".he-ov-box").css("bottom", inputHeight); $(".he-ov-box").scrollTop($(".he-ov-box")[0].scrollHeight); $('.plus_menu_box').hide();})// 右边消息的个数var mesnum = parseInt($('.mes_radio').html());//消息的个数$('.loader').hide();//消息定位的底部$(".he-ov-box").scrollTop($(".he_ov")[0].scrollHeight);//close popup$('.cd-popup').on('click', function(event){ if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup') || $(event.target).is('.clo_alert') ) { event.preventDefault(); $(this).removeClass('is-visible'); }});//close popup when clicking the esc keyboard button$(document).keyup(function(event){ if(event.which=='27'){ $('.cd-popup').removeClass('is-visible'); }});//textare 自适应高度(function($){ $.fn.autoTextarea = function(options) { var defaults={ maxHeight:null, minHeight:$(this).height() }; var opts = $.extend({},defaults,options); $(this).each(function() { $(this).bind("keyup",function(){ var height,style=this.style; var inputHeight = $('.mes_footer').height(); $(".mes_inout").val($(this).html()); this.style.height = opts.minHeight + 'px'; if (this.scrollHeight > opts.minHeight) { if (opts.maxHeight && this.scrollHeight > opts.maxHeight) { height = opts.maxHeight; style.overflowY = 'scroll'; } else { height = this.scrollHeight; style.overflowY = 'hidden'; } style.height = height + 'px'; $(".he-ov-box").scrollTop($(".he-ov-box")[0].scrollHeight+45) $(".he-ov-box").css("bottom", inputHeight); } }); }); };})(jQuery);//输入框的最小高度;$("#mes_textarea").autoTextarea({ maxHeight:260, minHeight:inputBottom});//单聊选择人// $('#s_man').click(function( e ){// e.stopPropagation();// $('#b_is').attr('val', 'selman');// $('#name_box').show();// }) //增加群聊人数选择人// $(document).on('click', '.add-groupMan', function(e){// console.log(33);// e.stopPropagation();// $('#b_is').attr('val', 'addGroupMan');// $('#name_box').show();// })//右边图标点击事件$('.mes_ico_box').swipe( { click:function(event, phase, direction, distance, duration,fingerCount) { var mes_abs = $('.mes_abs').css('right'); var cata_box = $(this).attr('cata-box'); if (cata_box == 'ren') { $('.online_man').show(); $('.mes_con').hide(); //0px 消息隐藏 if (mes_abs == '0px' || mes_abs == '200px') { $('.mes_abs').animate({ right: 140 }, { queue: true, duration: 500 }) } else { $('.mes_abs').animate({ right: 0 }, { queue: true, duration: 500 }) } } else { $('.online_man').hide(); $('.mes_con').show(); if (mes_abs == '0px' || mes_abs == '140px') { $('.mes_abs').animate({ right: 200 }, { queue: true, duration: 500 }) } else { $('.mes_abs').animate({ right: 0 }, { queue: true, duration: 500 }) } } }})// document点击事件$(document).click(function (event){ if( !$(event.target).parents('.mes_fixed_big').is('.mes_fixed_big') && !$(event.target).is('.mes_close')) { // event.preventDefault(); $('.mes_abs').animate({ right: 0 }, { queue: true, duration: 500 }) } if (!$(event.target).is('.pc_mes_tool_emoji')) { $('.pc_emoji_box').hide(); }; // if (!$(event.target).parents('#name_box').is('#name_box')) { // $('#name_box').hide(); // }; $('.groupMenu').hide(); $('.focus-hide').hide(); if ( $('.mes_title_con').hasClass('groupManShowIng') ) { $('.chat-show-groupMan-box').slideUp("slow", function () { $('.dropDown-showMan-n').css('background-image', "url(/chat/images/xialaIng.png)"); }); return false; };})//右边图标$('.mes_ico_box').hover(function (){ $(this).css('background-color', '#9dd2e7')}, function (){ $(this).css('background-color', '#444851')})//消息滑过$(document).on('mouseenter' , '.mes_box',function(){ $(this).css('background-color', '#9dd2e7') $(this).find('.mes_close').show() });$(document).on('mouseleave', '.mes_box', function (){ $(this).css('background-color', '#fff') $(this).find('.mes_close').hide()});//人员换过//人员信息var staffInfo = { tel:null, tel_branch:null, mobile_phone:null,};//获取人员信息var getStaffInfo = function (data){ staffInfo.tel = data.tel; staffInfo.tel_branch = data.tel_branch; staffInfo.mobile_phone = data.mobile_phone;}//请求人员信息var ajaxGetStaffInfo = function (staffid, direction, css){ var arrDirectionCg =new Object(); arrDirectionCg = { 'left': 'right','right':'left', 'up': 'bottom', 'down': 'top' }; var directionChang = arrDirectionCg[direction]; var margin ="margin-"+directionChang; $('.staff-info-box').remove(); $.ajax({ url:"getStaffTels.php", type:"post", data:"staffid="+staffid, success: function ( data ){ var data = $.parseJSON(data); getStaffInfo(data); // var index = parseInt($(".infoCurrent").index()); $(".infoCurrent").append('<div class= "staff-info-box"><div class="arrow"></div><ul><li>座机:'+data.tel+'</li><li>分机:'+data.tel_branch+'</li><li>手机:'+data.mobile_phone+'</li><li>组织名字:'+data.org_name+'</li></ul></div>'); $('.staff-info-box').css(css); $('.staff-info-box').css(directionChang, "100%"); $('.staff-info-box').css('margin-left', "10"); $('.staff-info-box .arrow').css('border-'+direction,"8px solid #fff"); $('.staff-info-box .arrow').css(direction,"100%"); // $('.staff-info-box').css(); } })}$(function (){ var winHeight = $(window).height(); var onlineManHeight = winHeight - parseInt($('.oms_onlineNum').css('top')); $('.oms_onlineNum').css('height', onlineManHeight); $('.search_result').css('height', onlineManHeight);})//消息滑过$(document).on('mouseenter' , '.staff-info',function(){ var obj = $(this); var _index = obj.index(); var onlineManTop = $('.oms_onlineNum').css('top'); var staffid = obj.attr('mes_id'); $('.online_man').addClass('infoCurrent'); var direction = obj.attr('data-placement'); var height = obj.outerHeight(); var offtop = _index * height + height/2 + 38 - $('.oms_onlineNum').scrollTop(); // var offtop = height/2-85/2; ajaxGetStaffInfo(staffid, direction, { top: offtop});});// 人员消息的 消失$(document).on('mouseleave', '.online_man', function (){ var obj = $(this); obj.removeClass('infoCurrent'); $('.staff-info-box').remove();});//消息滑过$(document).on('mouseenter' , '.content-staff-info',function(){ var obj = $(this); var staffid = obj.attr('mes_id'); var _index = obj.index(); var height = obj.outerHeight(); var offtop = ( _index - 1 ) * height + 125 + parseInt($('.com-recent-box').css('marginTop')) - $('.con-tab-content').scrollTop(); $('.details-list').addClass('infoCurrent'); var direction = obj.attr('data-placement'); ajaxGetStaffInfo(staffid, direction, {top: offtop});});$(document).on('mouseleave', '.content-staff-info', function (){ $('.details-list').removeClass('infoCurrent'); $('.staff-info-box').remove();});//消息关闭$('.close').click(function (){ $('.mes_abs').animate({ right: 0 }, { queue: true, duration: 0 })})var mesShow = new messageShow();/************************ end ********************************/</script><script src="/lattice/Publics/Js/selectPerson.js"></script><script> lattSetting({ glob:{ //不设置这个属性或者属性为空就不强制应用全局属性 // val:'#chooseTec', //字符串值存放位置 // ignore:[true,false], //是否忽略(如果设置了一致性,下面也还设置val的话讲优先采取下面的) // type:[1,2,3], // on:['click','dblclick','.....'], isfill:false, //是否把结果值填充的val选择器中 [true,false]; }, items:[ { type:1, //组织架构类型 val:'#s_man', // 选择人 callback:function(sidList,names){ //在手机上交替显示 var arrStaffid = []; if ( $(window).width() < 500 ) { $('.chat-container').show(); $('.details-list').hide(); }; //end if (sidList.length >1) { alert('只能选择一个人!'); return false; }; for (var i = 0; i < sidList.length; i++ ) { arrStaffid.push(sidList[i][1]); } if ( typeof friendMap != 'undefined' ) { Array.prototype.push.apply(arrStaffid, friendMap); }; if (arrStaffid.length == 0){ alert('请选择人!');return false; } var jsonText = JSON.stringify(arrStaffid); to_uid = arrStaffid[0]; ws.send('{"type":"mes_chat", "to_uid":"'+to_uid+'"}'); $('.chating-content .mes_load').html(10); mes_type = "message"; //会话id的改变 if ( parseInt(to_uid) < parseInt(chat_uid) ) { session_no = to_uid+"-"+chat_uid; } else { session_no = chat_uid+"-"+to_uid; } //消息向上滚动 $('.chating-content .he-ov-box').unbind('scroll'); $('.chating-content .he-ov-box').bind("scroll", function (){ mesScroll(); }) $.ajax({ url:'getndp.php', data:'jsonText='+jsonText, type:'post', success:function(data){ var d=eval('('+data+')') for (var i = 0; i < d.length; i++) { $('.chating-content .mes_title_con').html(d[i].name); getStaffHead(d[i].card_image); } } }) } }, { type:1, //组织架构类型 val:'.pc_mes_tool_videoM', // 多人视频 callback:function(sidList,names){ var arrStaffid = []; for (var i = 0; i < sidList.length; i++ ) { arrStaffid.push(sidList[i][1]); } if ( typeof friendMap != 'undefined' ) { Array.prototype.push.apply(arrStaffid, friendMap); }; ajaxSidList = _chat_remove(chat_uid, arrStaffid); $.ajax({ url: '/chat/va-chat/ajax_getToken.php?createSession=1', data: 'createSession=1', type: 'post', success: function (data) { // ws.send('{"type": "vaAnswer", "client_id": "'+client_id+'", "act": "'+act+'", "session_id": "'+data[1].session_id+'"}'); ws.send('{"type": "va","session_id": "'+data+'", "act": "vM","to_uid": "'+ajaxSidList+'"}'); window.location.href="https://www.omso2o.com/chat/va-chat/vaChat.php?session_id="+data+"&Invitation=1"; // window.open("https://www.omso2o.com/chat/va-chat/vaChat.php?session_id="+data+"&Invitation=1"); }, }) } }, { type:1, //组织架构类型 val:'.add-groupMan', // 添加群聊人数 callback:function(sidList,names){ var arrStaffid = []; for (var i = 0; i < sidList.length; i++ ) { arrStaffid.push(sidList[i][1]); } $('.chat_alert').show(500); setTimeout(function(){ $('.chat_alert').hide(500); },2000); ws.send('{"type":"addGroupMan", "session_no":"'+session_no+'", "sidList":['+arrStaffid+']}'); } }, { type:1, //组织架构类型 val:'.chat-share', // 文件分享 callback:function(sidList,names){ var arrStaffid = []; for (var i = 0; i < sidList.length; i++ ) { arrStaffid.push(sidList[i][1]); } if ( typeof friendMap != 'undefined' ) { Array.prototype.push.apply(arrStaffid, friendMap); }; to_uid = arrStaffid[0]; var session_id ; var content = $('.chat-shareing').attr('data-placement'); if ( parseInt(to_uid) < parseInt(chat_uid) ) { session_id = to_uid+"-"+chat_uid; } else { session_id = chat_uid+"-"+to_uid; } $('.chat_alert p').html('已分享!'); $('.chat_alert').show(500); setTimeout(function(){ $('.chat_alert').hide(500, function (){ $('.chat_alert p').html('恭喜您操作成功!'); }); },2000); ws.send('{"type":"sayUid","to_uid":"'+to_uid+'","groupId":"", "accept_name":"'+accept_name+'","message_type":"message", "mes_types":"file","session_no":"'+session_id+'","content":"'+content+'"}'); } }, ], }) $(function () { $(document).on('click', '#s_man, .pc_mes_tool_videoM, .add-groupMan', function ( e ) { // e.stopPropagation(); $('#name_box').show(); $('.latt-container').css('height', '400px !important').appendTo($('.orgJiagou')); $('#latt-ok').hide(); $('.latt-container .btn').hide(); }); var nIs= $('#b_is'); var nNo= $('#b_no'); nIs.click(function () { $('#latt-ok').trigger('click'); }); nNo.click(function () { $('#name_box').hide(); }) })</script><style> .latt-container{ height: auto !important; }</style></body></html>