济源12345的前端

replyChat.html 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. <span class="error" style="color: red;display: none;">内容为空!</span>
  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. if($('#content').val()==''){
  235. $('.error').show();
  236. }else{
  237. $('.error').hide();
  238. sendMessage();
  239. }
  240. // parent.initTable();
  241. // parent.layer.msg("添加成功");
  242. })
  243. function sendMessage() {
  244. // 发送给所有人时ToRoleId=0 且 ToUserId=0
  245. //
  246. // 发送给角色时ToRoleId>0 且 ToUserId=0
  247. //
  248. // 发送给角色时ToRoleId=0 且 ToUserId>0
  249. $.ajax({
  250. type: "post",
  251. url: huayi.config.callcenter_url + "Index/SaveChatInfo",
  252. async: true,
  253. dataType: 'json',
  254. data: {
  255. token: $.cookie("token"),
  256. Content: $('#content').val(),
  257. ToUserId: $('#zx').val(),
  258. ToRoleId: $('#role').val()
  259. },
  260. success:function(data){
  261. if(data.state.toLowerCase()=='success'){
  262. $('#content').val('');
  263. }
  264. }
  265. });
  266. }
  267. })
  268. </script>
  269. </body>
  270. </html>