Нет описания

replyChat.html 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. <!-- <link href="../css/layer/need/layer.css" /> -->
  8. <link href="../css/init.css" rel="stylesheet" />
  9. <link href="./css/replyChat.css" rel="stylesheet" />
  10. <title></title>
  11. <style>
  12. </style>
  13. </head>
  14. <body>
  15. <div class="Common">
  16. <table>
  17. <tr class="tr">
  18. <th>历史消息:</th>
  19. <td>
  20. <p>注:历史 消息只显示最新50条记录</p>
  21. <div class="historyCon" style="width: 100%; height: 200px; overflow-y: auto; border: 1px solid #ccc;padding: 5px;">
  22. <ul class="chatlist_con">
  23. </ul>
  24. </div>
  25. </td>
  26. </tr>
  27. <tr>
  28. <th>角色:</th>
  29. <td>
  30. <select name="" id="role" class="select_">
  31. <option value="">请选择角色</option>
  32. <option value="1">角色1</option>
  33. <option value="2">角色2</option>
  34. </select>
  35. <!-- <select name="" id="zx" class="select_"></select> -->
  36. </td>
  37. </tr>
  38. <tr>
  39. <th>内容:</th>
  40. <td colspan="2">
  41. <textarea data-adaptheight id="content" name="" rows="" cols="" placeholder="输入回复内容..."></textarea>
  42. </td>
  43. </tr>
  44. </table>
  45. <div class="btn_box">
  46. <button class="btns">发送</button>
  47. <span class="error" style="color: red;display: none;">内容为空!</span>
  48. </div>
  49. </div>
  50. <script src="../js/adjustHeight.js"></script>
  51. <!-- <script src="../css/laydate/laydate.js"></script> -->
  52. <script>
  53. var userId = helper.request.queryString("userId");
  54. var toId = helper.request.queryString("toId");
  55. var id = helper.request.queryString("id");
  56. var userCode;
  57. $(document).ready(function(){
  58. getRole()
  59. });
  60. //下拉框
  61. //获取坐席下拉框
  62. // $.getJSON(huayi.config.callcenter_url + "Index/GetUserListByRoleId", {
  63. // "token": $.cookie("token"),
  64. // "roleid": 0
  65. // }, function(result) {
  66. // if(result.state.toLowerCase() == "success") {
  67. // goodslist = result.data;
  68. // bindZX($("#zx"));
  69. // if(userId){
  70. // $('#zx').val(userId);
  71. // }
  72. // }
  73. // });
  74. function bindseat(obj) {
  75. obj.empty();
  76. obj.append('<option value="0" selected="selected">所有角色</option>');
  77. $(goodslist).each(function(i, n) {
  78. obj.append('<option value="' + n.F_RoleId + '">' + n.F_RoleName + '</option>');
  79. })
  80. }
  81. //获取角色下拉框
  82. function getRole() {
  83. $("#role").empty();
  84. $("#role").append('<option value="0" selected="selected">所有角色</option>');
  85. $.getJSON(huayi.config.callcenter_url + "signtokenapi/api/UserAccount/getlistsbypage", {
  86. "token": $.cookie("token")
  87. }, function(result) {
  88. if(result.state.toLowerCase() == "success") {
  89. var res = result.data.rows;
  90. $(res).each(function(i, n) {
  91. $("#role").append('<option value="' + n.usercode + '">' + n.username + '</option>');
  92. })
  93. if(toId) {
  94. $("#role").val(toId)
  95. }
  96. }
  97. });
  98. }
  99. function historys(user, to) {
  100. helper.init.isload = 0;
  101. $.ajax({
  102. type: "get",
  103. url: huayi.config.callcenter_url + "testusertypeapi/api/TestUserType/GetOnlineservicetinfo",
  104. async: true,
  105. dataType: 'json',
  106. data: {
  107. token: $.cookie("token"),
  108. id: id,
  109. },
  110. success: function (data) {
  111. helper.init.isload = 1;
  112. $('.chatlist_con').html('');
  113. $(data.data).each(function(i, n) {
  114. console.log('n', n)
  115. if(to == n.touserid) {
  116. $('<li>' +
  117. // '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
  118. '<div class="message_mincon self">' +
  119. // '<img class="ver_middle" src="img/chat_pic.jpg" alt="" width="30" height="30"/>' +
  120. '<div class="message_text">' + n.Msgcontent + '</div>' +
  121. '</div>' +
  122. '</li>').appendTo('.chatlist_con')
  123. } else {
  124. $('<li>' +
  125. // '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
  126. '<div class="message_mincon">' +
  127. // '<img class="ver_middle" src="img/chat_list2.jpg" alt="" width="30" height="30"/>' +
  128. '<div class="message_text">' + n.Msgcontent + '</div>' +
  129. '</div>' +
  130. '</li>').appendTo('.chatlist_con')
  131. }
  132. });
  133. }
  134. });
  135. // var farTop=$(".chatlist_con").css('height');
  136. // $(".historyCon").animate({ scrollTop:farTop});
  137. }
  138. if(userId) {
  139. $('.tr').show();
  140. historys(userId,toId)
  141. userCode = userId
  142. // setInterval(historys, 2000,userId,toId);//Ajax调用函数
  143. }else{
  144. $('.tr').hide();
  145. userCode = window.localStorage.userCode
  146. }
  147. $(document).ready(function() {
  148. $(".btns").click(function() {
  149. // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  150. // parent.layer.close(index); //再执行关闭
  151. if($('#content').val()==''){
  152. $('.error').show();
  153. }else{
  154. $('.error').hide();
  155. sendMessage();
  156. }
  157. // parent.initTable();
  158. // parent.layer.msg("添加成功");
  159. })
  160. function sendMessage() {
  161. // 发送给所有人时ToRoleId=0 且 ToUserId=0
  162. //
  163. // 发送给角色时ToRoleId>0 且 ToUserId=0
  164. //
  165. // 发送给角色时ToRoleId=0 且 ToUserId>0
  166. $.ajax({
  167. type: "get",
  168. url: huayi.config.callcenter_url + "testusertypeapi/api/TestUserType/AddOnlineservice",
  169. async: true,
  170. dataType: 'json',
  171. // data: {
  172. // token: $.cookie("token"),
  173. // Content: $('#content').val(),
  174. // ToUserId: $('#zx').val(),
  175. // ToRoleId: $('#role').val()
  176. // },
  177. data: {
  178. token: $.cookie("token"),
  179. Msgcontent: $('#content').val(),
  180. fromuserid: userCode,
  181. touserid: $('#role').val()
  182. },
  183. success:function(data){
  184. if(data.state.toLowerCase()=='success'){
  185. if(userId) {
  186. parent.$("#table_all").bootstrapTable('refresh');
  187. $('#content').val('')
  188. } else {
  189. var index = parent.layer.getFrameIndex(window.name);
  190. parent.layer.close(index);
  191. parent.layer.msg("添加成功");
  192. }
  193. }
  194. }
  195. });
  196. }
  197. })
  198. </script>
  199. </body>
  200. </html>