core
BIN
public/static/.DS_Store
vendored
Normal file
BIN
public/static/common/.DS_Store
vendored
Normal file
20484
public/static/common/dist/css/soho.min.css
vendored
Normal file
BIN
public/static/common/dist/icons/font-awesome/fonts/fontawesome-webfont.woff2
vendored
Normal file
BIN
public/static/common/dist/icons/themify/fonts/themify.woff
vendored
Normal file
277
public/static/common/dist/js/examples.js
vendored
Normal file
@ -0,0 +1,277 @@
|
||||
var kefu_code = 'KF_' + code;
|
||||
$(function () {
|
||||
var kefu = {
|
||||
Message: {
|
||||
addLog: function (obj, type, code) {
|
||||
var chat_body = $('.layout .content .chat .chat-body ');
|
||||
if (chat_body.length > 0) {
|
||||
type = type ? type : '';
|
||||
message = obj.message ? obj.message : '你好你好.';
|
||||
time = obj.time ? obj.time : (obj.create_time ? obj.create_time : '');
|
||||
var html = '<div class="message-item ' + type + '" data-log-id="' + obj.log_id + '">';
|
||||
html += '<div class="message-content">' + message + '</div>';
|
||||
html += '<div class="message-action">' + time;
|
||||
if (code == 0) {
|
||||
html += (type ? '<i class="ti-check"></i>' : ''); //如果已读 改成 <i class="ti-double-check"></i>
|
||||
} else {
|
||||
html += '<i title="Message could not be sent" class="ti-info-alt text-danger"></i>'; //如果已读 改成 <i class="ti-double-check"></i>
|
||||
}
|
||||
html += '</div></div>';
|
||||
$('.layout .content .chat .chat-body .messages').append(html);
|
||||
chat_body.scrollTop(chat_body.get(0).scrollHeight, -1).niceScroll({
|
||||
cursorcolor: 'rgba(66, 66, 66, 0.20)',
|
||||
cursorwidth: "4px",
|
||||
cursorborder: '0px'
|
||||
});
|
||||
}
|
||||
return true;
|
||||
},
|
||||
getQueue: function (status) {
|
||||
status =status?status:1;
|
||||
$.getJSON('/index/kefu/getQueue', {
|
||||
status: status,
|
||||
kefu_code: code
|
||||
}, function (res) {
|
||||
if (res.code == 200 && res.data.length > 0) {
|
||||
if(status ==1){
|
||||
$('#facing').html('');
|
||||
$.each(res.data, function (key, item) {
|
||||
var open = key == 0 ? 'open-chat' : '';
|
||||
var avatar_state_success = key == 0 ? 'avatar-state-success' : '';
|
||||
var facing_info = ' <li class="list-group-item ' + open + '" data-id="' + item.visitor_id + '">';
|
||||
facing_info += '<figure class="avatar ' + avatar_state_success + '">';
|
||||
facing_info += '<img src="' + item.visitor_avatar + '" class="rounded-circle"></figure>';
|
||||
facing_info += ' <div class="users-list-body"> <h5>' + item.visitor_name + '</h5></div>';
|
||||
$('#facing').append(facing_info);
|
||||
//新建聊天框
|
||||
if (key == 0) {
|
||||
kefu.Message.getChatLog(item.visitor_id, kefu_code);
|
||||
kefu.Message.setOnline(item.visitor_name, item.visitor_avatar);
|
||||
}
|
||||
|
||||
});
|
||||
}else {
|
||||
$('#history').html('');
|
||||
$.each(res.data, function (key, item) {
|
||||
var open = key == 0 ? 'open-chat' : '';
|
||||
var avatar_state_success = key == 0 ? 'avatar-state-success' : '';
|
||||
var facing_info = ' <li class="list-group-item ' + open + '" data-id="' + item.visitor_id + '">';
|
||||
facing_info += '<figure class="avatar ' + avatar_state_success + '">';
|
||||
facing_info += '<img src="' + item.visitor_avatar + '" class="rounded-circle"></figure>';
|
||||
facing_info += ' <div class="users-list-body"> <h5>' + item.visitor_name + '</h5></div>';
|
||||
$('#history').append(facing_info);
|
||||
//新建聊天框
|
||||
if (key == 0) {
|
||||
kefu.Message.getChatLog(item.visitor_id, kefu_code);
|
||||
kefu.Message.setOnline(item.visitor_name, item.visitor_avatar,2);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
getHistLog:function(){
|
||||
|
||||
},
|
||||
setOnline: function (visitor_name, visitor_avatar,status) {
|
||||
$('#visitor_avatar').html('<img src="' + visitor_avatar + '" class="rounded-circle">');
|
||||
$('#visitor_info h5').text(visitor_name);
|
||||
status=status?status:1;
|
||||
if(status ==1){
|
||||
$('#visitor_info i').text('在线');
|
||||
}else {
|
||||
$('#visitor_info i').text('离线');
|
||||
}
|
||||
|
||||
},
|
||||
getfirstChatLog: function () {
|
||||
var show = $('.layout .content .chat .chat-body .show');
|
||||
if (show.length > 0) {
|
||||
kefu.Message.getChatLog(show.attr('data-id'), kefu_code);
|
||||
}
|
||||
},
|
||||
getChatLog: function (uid, kefu_code) {
|
||||
$('.layout .content .chat .chat-body .messages').html('');
|
||||
$.getJSON('/index/kefu/getUserChatLog', {
|
||||
uid: uid,
|
||||
kefu_code: kefu_code
|
||||
}, function (res) {
|
||||
if (res.code == 200 && res.data.length > 0) {
|
||||
$.each(res.data, function (key, item) {
|
||||
if (item.log == 'kefu') {
|
||||
if (item.send_status == 1) {
|
||||
kefu.Message.addLog(item, 'outgoing-message', 0);
|
||||
} else {
|
||||
kefu.Message.addLog(item, 'outgoing-message', 1);
|
||||
}
|
||||
} else if (item.log == 'visitor') {
|
||||
if (item.send_status == 1) {
|
||||
kefu.Message.addLog(item, '', 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
toMeLog: function (obj) {
|
||||
$('.layout .content .sidebar-group #chats #facing li').each(function () {
|
||||
if ($(this).attr('data-id') == obj.id) {
|
||||
if ($(this).hasClass('open-chat') == true) {
|
||||
kefu.Message.addLog(obj, '', 0);
|
||||
return true;
|
||||
} else {
|
||||
var add = $(this).find('.users-list-body');
|
||||
if (add.find('.users-list-action').length > 0) {
|
||||
var num = add.find('.users-list-action').find('.new-message-count').text();
|
||||
add.find('.users-list-action').find('.new-message-count').text(Number(num) + 1);
|
||||
} else {
|
||||
add.append('<div class="users-list-action"><div class="new-message-count">1</div></div>');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var websocket = new WebSocket('ws://' + window.location.hostname + ':' + port);
|
||||
websocket.onopen = function (evt) {
|
||||
onOpen(evt)
|
||||
};
|
||||
websocket.onclose = function (evt) {
|
||||
onClose(evt)
|
||||
};
|
||||
websocket.onmessage = function (evt) {
|
||||
onMessage(evt)
|
||||
};
|
||||
websocket.onerror = function (evt) {
|
||||
onError(evt)
|
||||
};
|
||||
|
||||
function onOpen(evt) {
|
||||
console.log("连接成功");
|
||||
var msg = {};
|
||||
msg.data = {};
|
||||
msg.cmd = 'kefuConnection';
|
||||
msg.data.uid = kefu_code;
|
||||
websocket.send(JSON.stringify(msg));
|
||||
|
||||
}
|
||||
|
||||
function onClose(evt) {
|
||||
console.log("断开连接");
|
||||
}
|
||||
|
||||
function onMessage(evt) {
|
||||
var obj = JSON.parse(evt.data);
|
||||
if (obj.cmd == "chatMessage") {
|
||||
console.log(obj.data);
|
||||
// kefu.Message.addLog(obj.data,'',0);
|
||||
kefu.Message.toMeLog(obj.data);
|
||||
} else if (obj.cmd == "kefu_online") {
|
||||
$('#chats').find('.status').text('在线');
|
||||
//获取当前会话
|
||||
kefu.Message.getQueue()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onError(evt) {
|
||||
console.log("服务未开启");
|
||||
alert('服务未开启')
|
||||
}
|
||||
|
||||
function sendMsg() {
|
||||
var content = $('#msg').val();
|
||||
var msg = {};
|
||||
content = content.replace(" ", " ");
|
||||
if (!content) {
|
||||
return false;
|
||||
}
|
||||
msg.cmd = 'message';
|
||||
msg.data = content;
|
||||
console.log(msg)
|
||||
websocket.send(JSON.stringify(msg));
|
||||
$('#msg').val("");
|
||||
return true;
|
||||
}
|
||||
|
||||
$(document).on('submit', '.layout .content .chat .chat-footer form', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var input = $(this).find('input[type=text]');
|
||||
var message = input.val();
|
||||
message = $.trim(message);
|
||||
if (message) {
|
||||
var msg = {}
|
||||
msg.cmd = 'message';
|
||||
msg.data = kefu.Message.getChat(message);
|
||||
websocket.send(JSON.stringify(msg));
|
||||
|
||||
input.val('');
|
||||
} else {
|
||||
input.focus();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.layout .navigation .nav-group li ', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if($(this).find('a').hasClass('queue')){
|
||||
kefu.Message.getQueue()
|
||||
}else if($(this).find('a').hasClass('notifiy_badge')){
|
||||
kefu.Message.getQueue(2)
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.layout .content .sidebar-group .sidebar .list-group-item', function () {
|
||||
if (jQuery.browser.mobile) {
|
||||
$(this).closest('.sidebar-group').removeClass('mobile-open');
|
||||
}
|
||||
});
|
||||
$(document).on('click', '.layout .content .sidebar-group #chats #facing li', function (e) {
|
||||
e.preventDefault();
|
||||
if ($(this).hasClass('open-chat') == true) {
|
||||
return true
|
||||
} else {
|
||||
$(this).addClass('open-chat');
|
||||
$(this).find('.users-list-body').find('.users-list-action').remove();
|
||||
$(this).find('figure').addClass('avatar-state-success');
|
||||
$('.layout .content .sidebar-group #chats #facing li').not(this).removeClass('open-chat');
|
||||
$('.layout .content .sidebar-group #chats #facing li figure').not($(this).find('figure')).removeClass('avatar-state-success');
|
||||
//显示当前用户的聊天记录
|
||||
kefu.Message.setOnline($(this).find('h5').text(), $(this).find('img').attr('src'));
|
||||
var vid = $(this).attr('data-id');
|
||||
var obj = $('.chat-body').find('.' + vid);
|
||||
kefu.Message.getChatLog(vid, kefu_code);
|
||||
|
||||
}
|
||||
});
|
||||
$(document).on('click', '.layout .content .sidebar-group #friends #history li', function (e) {
|
||||
e.preventDefault();
|
||||
if ($(this).hasClass('open-chat') == true) {
|
||||
return true
|
||||
} else {
|
||||
$(this).addClass('open-chat');
|
||||
$(this).find('.users-list-body').find('.users-list-action').remove();
|
||||
$(this).find('figure').addClass('avatar-state-success');
|
||||
$('.layout .content .sidebar-group #friends #history li').not(this).removeClass('open-chat');
|
||||
$('.layout .content .sidebar-group #friends #history li figure').not($(this).find('figure')).removeClass('avatar-state-success');
|
||||
//显示当前用户的聊天记录
|
||||
kefu.Message.setOnline($(this).find('h5').text(), $(this).find('img').attr('src'));
|
||||
var vid = $(this).attr('data-id');
|
||||
var obj = $('.chat-body').find('.' + vid);
|
||||
kefu.Message.getChatLog(vid, kefu_code);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
1
public/static/common/dist/js/soho.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(e){(jQuery.browser=jQuery.browser||{}).mobile=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}(navigator.userAgent||navigator.vendor||window.opera),$(function(){var i={Started:{pageLoadingClose:function(){$(".page-loading").fadeOut(300,function(){$(this).remove()})},scrolllRun:function(e){var o=$(".layout .content .chat .chat-body");if(0<o.length)if(jQuery.browser.mobile)o.scrollTop(o.get(0).scrollHeight,-1);else{var i={cursorcolor:"rgba(66, 66, 66, 0.20)",cursorwidth:"4px",cursorborder:"0px"};$(".files ul").niceScroll(i),o.scrollTop(o.get(0).scrollHeight,-1).niceScroll(i),$(".layout .content .sidebar .sidebar-body").niceScroll(i),e&&($(".files ul").getNiceScroll().resize(),o.scrollTop(o.get(0).scrollHeight,-1).getNiceScroll().resize(),$(".layout .content .sidebar .sidebar-body").getNiceScroll().resize())}},mobileBrowserVhProblemFixed:function(){var e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh",e+"px")},init:function(){this.pageLoadingClose(),this.scrolllRun(),this.mobileBrowserVhProblemFixed(),$("body").hasClass("rtl")&&$(".dropdown-menu.dropdown-menu-right").removeClass("dropdown-menu-right"),jQuery.browser.mobile&&($("body").addClass("no-blur-effect"),$(".layout .content .sidebar-group .sidebar .list-group-item .users-list-body .users-list-action").removeClass("action-toggle"))}}};$('[data-toggle="tooltip"]').tooltip(),$(document).ready(function(){i.Started.init()}),$(window).on("resize",function(){i.Started.mobileBrowserVhProblemFixed()}),$(document).on("click",'[data-toggle="tooltip"]',function(){$(this).tooltip("hide")}),$(document).on("click","[data-navigation-target]",function(){var e=$(this).data("navigation-target"),o=$(".sidebar-group .sidebar#"+e);o.closest(".sidebar-group").find(".sidebar").removeClass("active"),o.addClass("active"),o.find("form input:first").focus(),$("[data-navigation-target]").removeClass("active"),$('[data-navigation-target="'+e+'"]').addClass("active"),jQuery.browser.mobile&&($(".sidebar-group").removeClass("mobile-open"),o.closest(".sidebar-group").addClass("mobile-open")),i.Started.scrolllRun(!0)}),$(document).on("click",".sidebar-close",function(e){jQuery.browser.mobile?$(".sidebar-group").removeClass("mobile-open"):$(this).closest(".sidebar.active").removeClass("active"),i.Started.scrolllRun(!0)}),$(".sidebar-group .sidebar .sidebar-body").scroll(function(){i.Started.scrolllRun(!0)})});
|
202
public/static/common/dist/js/user.js
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
// 服务的客服标识
|
||||
var kefu_code = 0;
|
||||
// 服务的客服名称
|
||||
var kefu_name = '';
|
||||
// 服务的客服头像
|
||||
var kefu_avatar = '';
|
||||
var visitor = {
|
||||
visitor_id: '',
|
||||
visitor_name: '',
|
||||
visitor_avatar: '',
|
||||
kefu_code:0
|
||||
};
|
||||
$(function () {
|
||||
|
||||
var user = {
|
||||
Message: {
|
||||
initialize:function(){
|
||||
var _uid = localStorage.getItem('uid');
|
||||
var _name = localStorage.getItem("name");
|
||||
var _avatar = localStorage.getItem("avatar");
|
||||
|
||||
if (_uid == null) {
|
||||
_uid = uid;
|
||||
localStorage.setItem('uid', _uid);
|
||||
}
|
||||
if (_name == null) {
|
||||
_name = uname;
|
||||
localStorage.setItem('name', _name);
|
||||
}
|
||||
if (_avatar == null) {
|
||||
_avatar = uavatar;
|
||||
localStorage.setItem('avatar', _avatar);
|
||||
}
|
||||
visitor.visitor_id = _uid;
|
||||
visitor.visitor_name = _name;
|
||||
visitor.visitor_avatar = _avatar;
|
||||
visitor.kefu_code = code;
|
||||
},
|
||||
add: function (obj, type, code) {
|
||||
var chat_body = $('.layout .content .chat .chat-body');
|
||||
if (chat_body.length > 0) {
|
||||
type = type ? type : '';
|
||||
message = obj.message ? obj.message : '你好你好.';
|
||||
time = obj.time ? obj.time : (obj.create_time ? obj.create_time : '');
|
||||
var html = '<div class="message-item ' + type + '" data-log-id="' + obj.chat_log_id + '">';
|
||||
html += '<div class="message-content">' + message + '</div>';
|
||||
html += '<div class="message-action">' + time;
|
||||
if (code == 0) {
|
||||
html += (type ? '<i class="ti-check"></i>' : ''); //如果已读 改成 <i class="ti-double-check"></i>
|
||||
} else {
|
||||
html += '<i title="Message could not be sent" class="ti-info-alt text-danger"></i>'; //如果已读 改成 <i class="ti-double-check"></i>
|
||||
}
|
||||
|
||||
html += '</div></div>';
|
||||
|
||||
$('.layout .content .chat .chat-body .messages').append(html);
|
||||
chat_body.scrollTop(chat_body.get(0).scrollHeight, -1).niceScroll({
|
||||
cursorcolor: 'rgba(66, 66, 66, 0.20)',
|
||||
cursorwidth: "4px",
|
||||
cursorborder: '0px'
|
||||
});
|
||||
}
|
||||
},
|
||||
connectKefu: function (data) {
|
||||
kefu_code = data.kefu_code;
|
||||
kefu_name = data.kefu_name;
|
||||
kefu_avatar = data.kefu_avatar;
|
||||
$('#kefu_name').text(data.kefu_name);
|
||||
},
|
||||
getChat: function (message) {
|
||||
var data = {
|
||||
from_id: visitor.visitor_id,
|
||||
from_name: visitor.visitor_name,
|
||||
from_avatar: visitor.visitor_avatar,
|
||||
to_id: kefu_code,
|
||||
to_name: kefu_name,
|
||||
to_avatar: kefu_avatar,
|
||||
message: message
|
||||
};
|
||||
return data;
|
||||
},
|
||||
getChatLog: function () {
|
||||
$.getJSON('/index/index/getUserChatLog', {
|
||||
uid: visitor.visitor_id,
|
||||
kefu_code: kefu_code
|
||||
}, function (res) {
|
||||
if (res.code == 200 && res.data.length > 0) {
|
||||
$.each(res.data, function (key, item) {
|
||||
|
||||
if (item.log == 'visitor') {
|
||||
if (item.send_status == 1) {
|
||||
user.Message.add(item, 'outgoing-message', 0);
|
||||
} else {
|
||||
user.Message.add(item, 'outgoing-message', 1);
|
||||
}
|
||||
} else if (item.log == 'kefu') {
|
||||
if (item.send_status == 1) {
|
||||
user.Message.add(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
user.Message.initialize();
|
||||
var websocket = new WebSocket('ws://'+window.location.hostname+':'+port);
|
||||
websocket.onopen = function (evt) {
|
||||
onOpen(evt)
|
||||
};
|
||||
websocket.onclose = function (evt) {
|
||||
onClose(evt)
|
||||
};
|
||||
websocket.onmessage = function (evt) {
|
||||
onMessage(evt)
|
||||
};
|
||||
websocket.onerror = function (evt) {
|
||||
onError(evt)
|
||||
};
|
||||
|
||||
function onOpen(evt) {
|
||||
console.log("连接成功");
|
||||
var msg = {};
|
||||
msg.data = {};
|
||||
msg.cmd = 'visitorConnection';
|
||||
msg.data.visitor_id = visitor.visitor_id;
|
||||
msg.data.visitor_name = visitor.visitor_name;
|
||||
msg.data.visitor_avatar = visitor.visitor_avatar;
|
||||
websocket.send(JSON.stringify(msg));
|
||||
}
|
||||
|
||||
function onClose(evt) {
|
||||
console.log("断开连接");
|
||||
}
|
||||
|
||||
function onMessage(evt) {
|
||||
var obj = JSON.parse(evt.data);
|
||||
//上线成功 连接客服
|
||||
if (obj.cmd == 'online') {
|
||||
var msg = {};
|
||||
msg.data = {};
|
||||
msg.cmd = 'visitorToKefu';
|
||||
msg.data.uid = visitor.visitor_id;
|
||||
msg.data.name = visitor.visitor_name;
|
||||
msg.data.avatar = visitor.visitor_avatar;
|
||||
msg.data.kefu_code = visitor.kefu_code;
|
||||
websocket.send(JSON.stringify(msg));
|
||||
} else if (obj.cmd == 'visitorToKefu') {
|
||||
//连接客服成功
|
||||
if(obj.code == 200){
|
||||
user.Message.connectKefu(obj.data);
|
||||
//获取与该客服聊天记录
|
||||
user.Message.getChatLog();
|
||||
}else if(obj.code == 201){
|
||||
alert('客服已下线')
|
||||
}
|
||||
|
||||
} else if (obj.cmd = "message") {
|
||||
if (obj.code == 200) {
|
||||
user.Message.add(obj.data, 'outgoing-message', 0);
|
||||
} else if (obj.code == 201) {
|
||||
user.Message.add(obj.data, 'outgoing-message', 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (obj.cmd = "chatMessage") {
|
||||
//接收客服发送toMe的消息
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onError(evt) {
|
||||
console.log("服务未开启");
|
||||
alert('服务未开启')
|
||||
}
|
||||
|
||||
$(document).on('submit', '.layout .content .chat .chat-footer form', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var input = $(this).find('input[type=text]');
|
||||
var message = input.val();
|
||||
message = $.trim(message);
|
||||
if (message) {
|
||||
var msg = {}
|
||||
msg.cmd = 'message';
|
||||
msg.data = user.Message.getChat(message);
|
||||
websocket.send(JSON.stringify(msg));
|
||||
|
||||
input.val('');
|
||||
} else {
|
||||
input.focus();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.layout .content .sidebar-group .sidebar .list-group-item', function () {
|
||||
if (jQuery.browser.mobile) {
|
||||
$(this).closest('.sidebar-group').removeClass('mobile-open');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
BIN
public/static/common/dist/media/img/call-bg.png
vendored
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
public/static/common/dist/media/img/man_avatar1.jpg
vendored
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
public/static/common/dist/media/img/man_avatar2.jpg
vendored
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
public/static/common/dist/media/img/man_avatar3.jpg
vendored
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
public/static/common/dist/media/img/man_avatar5.jpg
vendored
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
public/static/common/dist/media/img/women_avatar1.jpg
vendored
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
public/static/common/dist/media/img/women_avatar3.jpg
vendored
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
public/static/common/dist/media/img/women_avatar4.jpg
vendored
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
public/static/common/dist/media/img/women_avatar5.jpg
vendored
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
public/static/common/images/kefu.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
public/static/common/images/visitor.jpg
Normal file
After Width: | Height: | Size: 30 KiB |