暫無描述

WeChatReply.html 5.9KB

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