民权县12345_前端

replyChat.html 7.0KB

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