説明なし

chat.html 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <!-- <script src="../Script/Common/huayi.load.js"></script> -->
  6. <!-- <script src="../Script/Common/huayi.config.js"></script> -->
  7. <script src="../js/jquery.min.js?v=2.1.4"></script>
  8. <script src="../js/jquery.cookie.js"></script>
  9. <script src="../js/bootstrap.min.js?v=3.3.6"></script>
  10. <!-- <link href="../css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
  11. <link href="../css/boot/bootstrap-table.css" rel="stylesheet">
  12. <link href="../css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
  13. <link href="../css/animate.min.css" rel="stylesheet">
  14. <link href="../css/style.min862f.css?v=4.1.0" rel="stylesheet"> -->
  15. <link href="../css/init.css" rel="stylesheet" />
  16. <link href="./css/chat.css" rel="stylesheet" />
  17. <title></title>
  18. <style>
  19. </style>
  20. </head>
  21. <body>
  22. <div class="Common">
  23. <div class="chat-header"></div>
  24. <div class="chat-body">
  25. <table>
  26. <tr class="tr">
  27. <!-- <th>历史消息:</th> -->
  28. <td>
  29. <p>注:只显示最新历史消息</p>
  30. <div class="historyCon">
  31. <ul class="chatlist_con">
  32. </ul>
  33. </div>
  34. </td>
  35. </tr>
  36. <!-- <tr class="role-wrapper">
  37. <th>角色:</th>
  38. <td>
  39. <select name="" id="role" class="select_">
  40. <option value="0">所有角色</option>
  41. </select>
  42. <select name="" id="zx" class="select_"></select>
  43. </td>
  44. </tr> -->
  45. <tr>
  46. <!-- <th>内容:</th> -->
  47. <td colspan="2">
  48. <textarea data-adaptheight id="content" name="" rows="" cols="" placeholder="输入回复内容..."></textarea>
  49. </td>
  50. </tr>
  51. </table>
  52. </div>
  53. <div class="btn_box chat-bottom">
  54. <button class="btns">发送</button>
  55. <span class="error" style="color: red;display: none;">内容为空!</span>
  56. </div>
  57. </div>
  58. <script>
  59. // var userId = helper.request.queryString("userId");
  60. // var toId = helper.request.queryString("toId");
  61. // var id = helper.request.queryString("id");
  62. var userCode;
  63. // var userId = helper.request.queryString("userId");
  64. // var toId = helper.request.queryString("toId");
  65. // var id = helper.request.queryString("id");
  66. var userId = ''
  67. var toId = ''
  68. var id = ''
  69. $(document).ready(function(){
  70. // getRole()
  71. $(".btns").click(function() {
  72. if(!userId) {
  73. if ($('#role').val() === "0") {
  74. layer.confirm('请选择角色!', {
  75. icon: 2,
  76. btn: ['确定']
  77. });
  78. return;
  79. }
  80. }
  81. if($('#content').val()==''){
  82. $('.error').show();
  83. }else{
  84. $('.error').hide();
  85. sendMessage();
  86. }
  87. })
  88. historys()
  89. setInterval(historys, 2000,userId,toId);//Ajax调用函数
  90. });
  91. //获取角色下拉框
  92. // function getRole() {
  93. // $("#role").empty();
  94. // $("#role").append('<option value="0" selected="selected">所有角色</option>');
  95. // $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", {
  96. // "token": $.cookie("token"),
  97. // "PageIndex": 1,
  98. // "PageSize": 50
  99. // }, function(result) {
  100. // var res = result.rows;
  101. // $(res).each(function(i, n) {
  102. // $("#role").append('<option value="' + n.F_UserCode + '">' + n.F_UserCode + '</option>');
  103. // })
  104. // if(toId) {
  105. // $("#role").val(toId)
  106. // }
  107. // });
  108. // }
  109. function historys(user, to) {
  110. // helper.init.isload = 0;
  111. $.ajax({
  112. type: "get",
  113. url: "http://192.168.5.46:28000/" + "testusertypeapi/api/TestUserType/GetOnlineservicetinfo",
  114. async: true,
  115. dataType: 'json',
  116. data: {
  117. token: $.cookie("token"),
  118. fromuserid: 'lisi',
  119. touserid: 8001,
  120. // id: "5f990e75bc7ca8a6d50fd82a",
  121. },
  122. success: function (data) {
  123. // helper.init.isload = 1;
  124. $('.chatlist_con').html('');
  125. $(data.data).each(function(i, n) {
  126. // if(to == n.touserid) {
  127. if('lisi' == n.fromuserid) {
  128. $('<li>' +
  129. // '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
  130. '<div class="message_mincon self">' +
  131. '<img class="ver_middle" src="../img/chat_pic.jpg" alt="" width="60" height="60"/>' +
  132. '<div class="message_text">' + n.Msgcontent + '</div>' +
  133. '</div>' +
  134. '</li>').appendTo('.chatlist_con')
  135. } else {
  136. $('<li>' +
  137. // '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
  138. '<div class="message_mincon">' +
  139. '<img class="ver_middle" src="../img/chat_list2.jpg" alt="" width="60" height="60"/>' +
  140. '<div class="message_text">' + n.Msgcontent + '</div>' +
  141. '</div>' +
  142. '</li>').appendTo('.chatlist_con')
  143. }
  144. });
  145. }
  146. });
  147. // var farTop=$(".chatlist_con").css('height');
  148. // $(".historyCon").animate({ scrollTop:farTop});
  149. }
  150. // if (userId) {
  151. // $('.tr').show();
  152. // $('.role-wrapper').hide()
  153. // historys(userId,toId)
  154. // console.log('toId', toId)
  155. // userCode = userId
  156. // // setInterval(historys, 2000,userId,toId);//Ajax调用函数
  157. // } else {
  158. // $('.tr').hide();
  159. // $('.role-wrapper').show()
  160. // userCode = $.cookie("userCode")
  161. // }
  162. function sendMessage() {
  163. // 发送给所有人时ToRoleId=0 且 ToUserId=0
  164. //
  165. // 发送给角色时ToRoleId>0 且 ToUserId=0
  166. //
  167. // 发送给角色时ToRoleId=0 且 ToUserId>0
  168. $.ajax({
  169. type: "get",
  170. url: "http://192.168.5.46:28000/" + "testusertypeapi/api/TestUserType/AddOnlineservice",
  171. async: true,
  172. dataType: 'json',
  173. // data: {
  174. // token: $.cookie("token"),
  175. // Msgcontent: $('#content').val(),
  176. // fromuserid: userCode,
  177. // touserid: $('#role').val()
  178. // },
  179. data: {
  180. token: $.cookie("token"),
  181. Msgcontent: $('#content').val(),
  182. fromuserid: 'lisi',
  183. touserid: 8001,
  184. },
  185. success:function(data){
  186. if(data.state.toLowerCase()=='success'){
  187. // if(userId) {
  188. $('#content').val('')
  189. // parent.$("#table_all").bootstrapTable('refresh');
  190. // } else {
  191. // var index = parent.layer.getFrameIndex(window.name);
  192. // parent.layer.close(index);
  193. // parent.$("#table_all").bootstrapTable('refresh');
  194. // }
  195. }
  196. }
  197. });
  198. }
  199. </script>
  200. </body>
  201. </html>