12345市长热线标准版-前端

replyChat.html 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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="./Script/Common/huayi.http.js"></script>
  8. <link href="./css/layer/need/layer.css" />
  9. <link rel="stylesheet" href="./css/init.css" />
  10. <title></title>
  11. <style>
  12. .chatlist_con, .chatlist_con li{
  13. margin: 0;
  14. padding: 0;
  15. list-style: none;
  16. }
  17. .BiaoTi {
  18. width: 100%;
  19. text-align: center;
  20. border-color: #ccc;
  21. border: 1px solid #ccc;
  22. }
  23. textarea {
  24. border-color: #ccc;
  25. border: 1px solid #ccc;
  26. height: 100px;
  27. }
  28. .chatlist_con li {
  29. margin-bottom: 15px;
  30. }
  31. .message_time {
  32. margin:0;
  33. text-align: center;
  34. }
  35. .message_time span{
  36. border: 0;
  37. }
  38. .ver_middle {
  39. float: left;
  40. margin: 0 10px 0 0;
  41. border-radius: 3px;
  42. }
  43. .message_text {
  44. display: inline-block;
  45. position: relative;
  46. padding: 0 10px;
  47. max-width: calc(100% - 40px);
  48. min-height: 30px;
  49. line-height: 2.5;
  50. font-size: 9pt;
  51. text-align: left;
  52. word-break: break-all;
  53. background-color: #e6e2e2;
  54. border-radius: 4px;
  55. }
  56. .message_text:before {
  57. content: " ";
  58. position: absolute;
  59. top: 9px;
  60. right: 100%;
  61. border: 6px solid transparent;
  62. border-right-color: #e6e2e2;
  63. }
  64. .chatlist_con li .self {
  65. text-align: right;
  66. }
  67. .chatlist_con li .self .ver_middle {
  68. float: right;
  69. margin: 0 0 0 10px;
  70. }
  71. .self .message_text {
  72. background-color: #67c3db;
  73. color: #fff;
  74. }
  75. .self .message_text:before {
  76. right: inherit;
  77. left: 100%;
  78. border-right-color: transparent;
  79. border-left-color: #67c3db;
  80. }
  81. .Common table {
  82. width: 95%;
  83. margin: 0 auto;
  84. }
  85. .Common table th {
  86. width: 10%;
  87. }
  88. .btns {
  89. padding: 6px 15px;
  90. font-size: 15px;
  91. }
  92. </style>
  93. </head>
  94. <body>
  95. <div class="Common">
  96. <table>
  97. <tr class="tr">
  98. <th>历史消息:</th>
  99. <td>
  100. <p>注:历史 消息只显示最新50条记录</p>
  101. <div class="historyCon" style="width: 100%; height: 200px;overflow-y: auto;border: 1px solid #ccc;padding: 5px;">
  102. <ul class="chatlist_con">
  103. </ul>
  104. </div>
  105. </td>
  106. </tr>
  107. <tr>
  108. <th>角色:</th>
  109. <td>
  110. <select name="" id="role" class="select_"></select>
  111. <select name="" id="zx" class="select_"></select>
  112. </td>
  113. </tr>
  114. <tr>
  115. <th>内容:</th>
  116. <td colspan="2">
  117. <textarea data-adaptheight id="content" name="" rows="" cols="" placeholder="输入回复内容..."></textarea>
  118. </td>
  119. </tr>
  120. </table>
  121. <div class="btn_box">
  122. <button class="btns">发送</button>
  123. </div>
  124. </div>
  125. <script src="./js/adjustHeight.js"></script>
  126. <script src="./css/laydate/laydate.js"></script>
  127. <script>
  128. var userId = helper.request.queryString("userId");
  129. var roleId = helper.request.queryString("roleId");
  130. var toId = helper.request.queryString("toId");
  131. //下拉框
  132. //获取坐席下拉框
  133. $.getJSON(huayi.config.callcenter_url + "Index/GetUserListByRoleId", {
  134. "token": $.cookie("token"),
  135. "roleid": 0
  136. }, function(result) {
  137. if(result.state.toLowerCase() == "success") {
  138. goodslist = result.data;
  139. bindZX($("#zx"));
  140. if(userId){
  141. $('#zx').val(userId);
  142. }
  143. }
  144. });
  145. function bindZX(obj) {
  146. obj.empty();
  147. obj.append('<option value="0" selected="selected">所有人</option>');
  148. $(goodslist).each(function(i, n) {
  149. obj.append('<option value="' + n.F_UserId + '">' + n.F_UserName + '' + n.F_UserCode + '</option>');
  150. })
  151. }
  152. function bindseat(obj) {
  153. obj.empty();
  154. obj.append('<option value="0" selected="selected">所有角色</option>');
  155. $(goodslist).each(function(i, n) {
  156. obj.append('<option value="' + n.F_RoleId + '">' + n.F_RoleName + '</option>');
  157. })
  158. }
  159. //获取角色下拉框
  160. $.getJSON(huayi.config.callcenter_url + "Index/GetRoleList", {
  161. "token": $.cookie("token")
  162. }, function(result) {
  163. if(result.state.toLowerCase() == "success") {
  164. goodslist = result.data;
  165. bindseat($("#role"));
  166. if(userId){
  167. $('#role').val(roleId);
  168. }
  169. }
  170. });
  171. $("#role").change(function() {
  172. var pid = $(this).val();
  173. $.getJSON(huayi.config.callcenter_url + "Index/GetUserListByRoleId", {
  174. "token": $.cookie("token"),
  175. "roleid": pid
  176. }, function(result) {
  177. if(result.state.toLowerCase() == "success") {
  178. goodslist = result.data;
  179. bindZX($("#zx"));
  180. }
  181. });
  182. })
  183. function historys(user, to) {
  184. helper.init.isload = 0;
  185. $.ajax({
  186. type: "post",
  187. url: huayi.config.callcenter_url + "Index/GetChatLists",
  188. async: true,
  189. dataType: 'json',
  190. data: {
  191. token: $.cookie("token"),
  192. isread: 2,
  193. top: 50,
  194. fromid: user
  195. },
  196. success: function (data) {
  197. helper.init.isload = 1;
  198. $('.chatlist_con').html('');
  199. $(data.rows).each(function(i, n) {
  200. if(to == n.FromUserId) {
  201. $('<li>' +
  202. '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
  203. '<div class="message_mincon self">' +
  204. '<img class="ver_middle" src="img/chat_pic.jpg" alt="" width="30" height="30"/>' +
  205. '<div class="message_text">' + n.Content + '</div>' +
  206. '</div>' +
  207. '</li>').appendTo('.chatlist_con')
  208. } else {
  209. $('<li>' +
  210. '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
  211. '<div class="message_mincon">' +
  212. '<img class="ver_middle" src="img/chat_list2.jpg" alt="" width="30" height="30"/>' +
  213. '<div class="message_text">' + n.Content + '</div>' +
  214. '</div>' +
  215. '</li>').appendTo('.chatlist_con')
  216. }
  217. });
  218. }
  219. });
  220. // var farTop=$(".chatlist_con").css('height');
  221. // $(".historyCon").animate({ scrollTop:farTop});
  222. }
  223. if(userId) {
  224. $('.tr').show();
  225. historys(userId,toId)
  226. setInterval(historys, 2000,userId,toId);//Ajax调用函数
  227. }else{
  228. $('.tr').hide();
  229. }
  230. $(document).ready(function() {
  231. $(".btns").click(function() {
  232. // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  233. // parent.layer.close(index); //再执行关闭
  234. sendMessage();
  235. // parent.initTable();
  236. // parent.layer.msg("添加成功");
  237. })
  238. function sendMessage() {
  239. // 发送给所有人时ToRoleId=0 且 ToUserId=0
  240. //
  241. // 发送给角色时ToRoleId>0 且 ToUserId=0
  242. //
  243. // 发送给角色时ToRoleId=0 且 ToUserId>0
  244. $.ajax({
  245. type: "post",
  246. url: huayi.config.callcenter_url + "Index/SaveChatInfo",
  247. async: true,
  248. dataType: 'json',
  249. data: {
  250. token: $.cookie("token"),
  251. Content: $('#content').val(),
  252. ToUserId: $('#zx').val(),
  253. ToRoleId: $('#role').val()
  254. },
  255. success:function(data){
  256. if(data.state.toLowerCase()=='success'){
  257. $('#content').val('');
  258. }
  259. }
  260. });
  261. }
  262. })
  263. </script>
  264. </body>
  265. </html>