| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <!-- <script src="../Script/Common/huayi.load.js"></script> -->
- <!-- <script src="../Script/Common/huayi.config.js"></script> -->
- <script src="../js/jquery.min.js?v=2.1.4"></script>
- <script src="../js/jquery.cookie.js"></script>
- <script src="../js/bootstrap.min.js?v=3.3.6"></script>
- <!-- <link href="../css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
- <link href="../css/boot/bootstrap-table.css" rel="stylesheet">
- <link href="../css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
- <link href="../css/animate.min.css" rel="stylesheet">
- <link href="../css/style.min862f.css?v=4.1.0" rel="stylesheet"> -->
- <link href="../css/init.css" rel="stylesheet" />
- <link href="./css/chat.css" rel="stylesheet" />
- <title></title>
- <style>
- </style>
- </head>
- <body>
- <div class="Common">
- <div class="chat-header"></div>
- <div class="chat-body">
- <table>
- <tr class="tr">
- <!-- <th>历史消息:</th> -->
- <td>
- <p>注:只显示最新历史消息</p>
- <div class="historyCon">
- <ul class="chatlist_con">
-
- </ul>
- </div>
- </td>
- </tr>
- <!-- <tr class="role-wrapper">
- <th>角色:</th>
- <td>
- <select name="" id="role" class="select_">
- <option value="0">所有角色</option>
- </select>
- <select name="" id="zx" class="select_"></select>
- </td>
- </tr> -->
- <tr>
- <!-- <th>内容:</th> -->
- <td colspan="2">
- <textarea data-adaptheight id="content" name="" rows="" cols="" placeholder="输入回复内容..."></textarea>
- </td>
- </tr>
- </table>
- </div>
- <div class="btn_box chat-bottom">
- <button class="btns">发送</button>
- <span class="error" style="color: red;display: none;">内容为空!</span>
- </div>
- </div>
- <script>
- // var userId = helper.request.queryString("userId");
- // var toId = helper.request.queryString("toId");
- // var id = helper.request.queryString("id");
- var userCode;
- // var userId = helper.request.queryString("userId");
- // var toId = helper.request.queryString("toId");
- // var id = helper.request.queryString("id");
- var userId = ''
- var toId = ''
- var id = ''
- $(document).ready(function(){
- // getRole()
- $(".btns").click(function() {
- if(!userId) {
- if ($('#role').val() === "0") {
- layer.confirm('请选择角色!', {
- icon: 2,
- btn: ['确定']
- });
- return;
- }
- }
- if($('#content').val()==''){
- $('.error').show();
- }else{
- $('.error').hide();
- sendMessage();
- }
- })
- historys()
- setInterval(historys, 2000,userId,toId);//Ajax调用函数
- });
- //获取角色下拉框
- // function getRole() {
- // $("#role").empty();
- // $("#role").append('<option value="0" selected="selected">所有角色</option>');
- // $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", {
- // "token": $.cookie("token"),
- // "PageIndex": 1,
- // "PageSize": 50
- // }, function(result) {
- // var res = result.rows;
- // $(res).each(function(i, n) {
- // $("#role").append('<option value="' + n.F_UserCode + '">' + n.F_UserCode + '</option>');
- // })
- // if(toId) {
- // $("#role").val(toId)
- // }
- // });
- // }
- function historys(user, to) {
- // helper.init.isload = 0;
- $.ajax({
- type: "get",
- url: "http://192.168.5.46:28000/" + "testusertypeapi/api/TestUserType/GetOnlineservicetinfo",
- async: true,
- dataType: 'json',
- data: {
- token: $.cookie("token"),
- fromuserid: 'lisi',
- touserid: 8001,
- // id: "5f990e75bc7ca8a6d50fd82a",
- },
- success: function (data) {
- // helper.init.isload = 1;
- $('.chatlist_con').html('');
- $(data.data).each(function(i, n) {
- // if(to == n.touserid) {
- if('lisi' == n.fromuserid) {
- $('<li>' +
- // '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
- '<div class="message_mincon self">' +
- '<img class="ver_middle" src="../img/chat_pic.jpg" alt="" width="60" height="60"/>' +
- '<div class="message_text">' + n.Msgcontent + '</div>' +
- '</div>' +
- '</li>').appendTo('.chatlist_con')
- } else {
- $('<li>' +
- // '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
- '<div class="message_mincon">' +
- '<img class="ver_middle" src="../img/chat_list2.jpg" alt="" width="60" height="60"/>' +
- '<div class="message_text">' + n.Msgcontent + '</div>' +
- '</div>' +
- '</li>').appendTo('.chatlist_con')
- }
- });
- }
- });
- // var farTop=$(".chatlist_con").css('height');
- // $(".historyCon").animate({ scrollTop:farTop});
- }
- // if (userId) {
- // $('.tr').show();
- // $('.role-wrapper').hide()
- // historys(userId,toId)
- // console.log('toId', toId)
- // userCode = userId
- // // setInterval(historys, 2000,userId,toId);//Ajax调用函数
- // } else {
- // $('.tr').hide();
- // $('.role-wrapper').show()
- // userCode = $.cookie("userCode")
- // }
- function sendMessage() {
- // 发送给所有人时ToRoleId=0 且 ToUserId=0
- //
- // 发送给角色时ToRoleId>0 且 ToUserId=0
- //
- // 发送给角色时ToRoleId=0 且 ToUserId>0
- $.ajax({
- type: "get",
- url: "http://192.168.5.46:28000/" + "testusertypeapi/api/TestUserType/AddOnlineservice",
- async: true,
- dataType: 'json',
- // data: {
- // token: $.cookie("token"),
- // Msgcontent: $('#content').val(),
- // fromuserid: userCode,
- // touserid: $('#role').val()
- // },
- data: {
- token: $.cookie("token"),
- Msgcontent: $('#content').val(),
- fromuserid: 'lisi',
- touserid: 8001,
- },
- success:function(data){
- if(data.state.toLowerCase()=='success'){
- // if(userId) {
- $('#content').val('')
- // parent.$("#table_all").bootstrapTable('refresh');
- // } else {
- // var index = parent.layer.getFrameIndex(window.name);
- // parent.layer.close(index);
- // parent.$("#table_all").bootstrapTable('refresh');
- // }
- }
- }
- });
- }
- </script>
- </body>
- </html>
|