| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <script src="../Script/Common/huayi.load.js"></script>
- <script src="../Script/Common/huayi.config.js"></script>
- <!-- <link href="../css/layer/need/layer.css" /> -->
- <link href="../css/init.css" rel="stylesheet" />
- <link href="./css/replyChat.css" rel="stylesheet" />
- <title></title>
- <style>
- </style>
- </head>
- <body>
- <div class="Common">
- <table>
- <tr class="tr">
- <th>历史消息:</th>
- <td>
- <p>注:历史 消息只显示最新50条记录</p>
- <div class="historyCon" style="width: 100%; height: 200px; overflow-y: auto; border: 1px solid #ccc;padding: 5px;">
- <ul class="chatlist_con">
- </ul>
- </div>
- </td>
- </tr>
- <tr>
- <th>角色:</th>
- <td>
- <select name="" id="role" class="select_">
- <option value="">请选择角色</option>
- <option value="1">角色1</option>
- <option value="2">角色2</option>
- </select>
- <!-- <select name="" id="zx" class="select_"></select> -->
- </td>
- </tr>
- <tr>
- <th>内容:</th>
- <td colspan="2">
- <textarea data-adaptheight id="content" name="" rows="" cols="" placeholder="输入回复内容..."></textarea>
- </td>
- </tr>
- </table>
- <div class="btn_box">
- <button class="btns">发送</button>
- <span class="error" style="color: red;display: none;">内容为空!</span>
- </div>
- </div>
- <script src="../js/adjustHeight.js"></script>
- <!-- <script src="../css/laydate/laydate.js"></script> -->
- <script>
- var userId = helper.request.queryString("userId");
- var toId = helper.request.queryString("toId");
- var id = helper.request.queryString("id");
- var userCode;
-
- $(document).ready(function(){
- getRole()
- });
- //下拉框
- //获取坐席下拉框
- // $.getJSON(huayi.config.callcenter_url + "Index/GetUserListByRoleId", {
- // "token": $.cookie("token"),
- // "roleid": 0
- // }, function(result) {
- // if(result.state.toLowerCase() == "success") {
- // goodslist = result.data;
- // bindZX($("#zx"));
- // if(userId){
- // $('#zx').val(userId);
- // }
- // }
- // });
- function bindseat(obj) {
- obj.empty();
- obj.append('<option value="0" selected="selected">所有角色</option>');
- $(goodslist).each(function(i, n) {
- obj.append('<option value="' + n.F_RoleId + '">' + n.F_RoleName + '</option>');
- })
- }
- //获取角色下拉框
- function getRole() {
- $("#role").empty();
- $("#role").append('<option value="0" selected="selected">所有角色</option>');
- $.getJSON(huayi.config.callcenter_url + "signtokenapi/api/UserAccount/getlistsbypage", {
- "token": $.cookie("token")
- }, function(result) {
- if(result.state.toLowerCase() == "success") {
- var res = result.data.rows;
- $(res).each(function(i, n) {
- $("#role").append('<option value="' + n.usercode + '">' + n.username + '</option>');
- })
- if(toId) {
- $("#role").val(toId)
- }
- }
- });
- }
- function historys(user, to) {
- helper.init.isload = 0;
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "testusertypeapi/api/TestUserType/GetOnlineservicetinfo",
- async: true,
- dataType: 'json',
- data: {
- token: $.cookie("token"),
- id: id,
- },
- success: function (data) {
- helper.init.isload = 1;
- $('.chatlist_con').html('');
- $(data.data).each(function(i, n) {
- console.log('n', n)
- if(to == n.touserid) {
- $('<li>' +
- // '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
- '<div class="message_mincon self">' +
- // '<img class="ver_middle" src="img/chat_pic.jpg" alt="" width="30" height="30"/>' +
- '<div class="message_text">' + n.Msgcontent + '</div>' +
- '</div>' +
- '</li>').appendTo('.chatlist_con')
- } else {
- $('<li>' +
- // '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
- '<div class="message_mincon">' +
- // '<img class="ver_middle" src="img/chat_list2.jpg" alt="" width="30" height="30"/>' +
- '<div class="message_text">' + n.Msgcontent + '</div>' +
- '</div>' +
- '</li>').appendTo('.chatlist_con')
- }
- });
- }
- });
- // var farTop=$(".chatlist_con").css('height');
- // $(".historyCon").animate({ scrollTop:farTop});
- }
- if(userId) {
- $('.tr').show();
- historys(userId,toId)
- userCode = userId
- // setInterval(historys, 2000,userId,toId);//Ajax调用函数
- }else{
- $('.tr').hide();
- userCode = window.localStorage.userCode
- }
- $(document).ready(function() {
- $(".btns").click(function() {
- // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
- // parent.layer.close(index); //再执行关闭
- if($('#content').val()==''){
- $('.error').show();
- }else{
- $('.error').hide();
- sendMessage();
- }
- // parent.initTable();
- // parent.layer.msg("添加成功");
- })
- function sendMessage() {
- // 发送给所有人时ToRoleId=0 且 ToUserId=0
- //
- // 发送给角色时ToRoleId>0 且 ToUserId=0
- //
- // 发送给角色时ToRoleId=0 且 ToUserId>0
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "testusertypeapi/api/TestUserType/AddOnlineservice",
- async: true,
- dataType: 'json',
- // data: {
- // token: $.cookie("token"),
- // Content: $('#content').val(),
- // ToUserId: $('#zx').val(),
- // ToRoleId: $('#role').val()
- // },
- data: {
- token: $.cookie("token"),
- Msgcontent: $('#content').val(),
- fromuserid: userCode,
- touserid: $('#role').val()
- },
- success:function(data){
- if(data.state.toLowerCase()=='success'){
- if(userId) {
- parent.$("#table_all").bootstrapTable('refresh');
- $('#content').val('')
- } else {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.layer.msg("添加成功");
- }
- }
- }
- });
- }
- })
- </script>
- </body>
- </html>
|