Authored by 毕凯

Merge branch 'feature/cs-quit-queue' into 'master'

Feature/cs quit queue



See merge request !623
... ... @@ -67,11 +67,11 @@ exports.detail = (req, res, next) => {
}
res.render('question/detail', Object.assign(result, {
title: 'YOHOBUY!潮流大调查',
title: 'YOHO!调研中心',
module: '3party',
page: 'question-detail',
pageHeader: headerModel.setNav({
navTitle: 'YOHOBUY!潮流大调查'
navTitle: 'YOHO!调研中心'
}),
isApp: req.yoho.isApp,
localCss: true
... ...
... ... @@ -117,6 +117,7 @@ router.get('/passport/reg/index', validateCode.load, reg.index);
router.post('/passport/reg/verifymobile', validateCode.check, reg.sendCodeBusyBoy, reg.verifyMobile);
router.get('/passport/reg/code', reg.guardStep(2), reg.code);
router.post('/passport/reg/sendcode', reg.guardStep(2), reg.sendCodeBusyBoy, reg.sendCode);
router.post('/passport/reg/sendcodeagain', reg.guardStep(2), reg.sendCodeBusyBoy, reg.sendCode);
router.post('/passport/reg/verifycode', reg.guardStep(2), reg.verifyCode);
router.get('/passport/reg/password', reg.guardStep(3), reg.password);
router.post('/passport/reg/setpassword', reg.guardStep(3), reg.setPassword);
... ...
... ... @@ -3,8 +3,8 @@
<!--im 头部-->
<header class="yoho-header chat-header">
<a id="js-back" href="{{#if backUrl}}{{backUrl}}{{^}}javascript:history.go(-1);{{/if}}" class="iconfont nav-back">&#xe610;</a>
<div class="title">智能小YO</div>
<div class="header-right"><span data-action="change-human">人工客服</span></div>
<div class="title"><i class="chat-status"></i><span class="js-service-txt">正在连接...</span></div>
<div class="header-right"></div>
</header>
<!--网络连接失败-->
<div class="connection-failed hide">
... ...
{
"name": "m-yohobuy-node",
"version": "5.7.10",
"version": "5.7.11",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -22,7 +22,7 @@ class ActController extends Controller {
lazyLoad($('img.lazy'));
this.more = new GetMore();
this.more.on('more', this.doMore.bind(this));
this.page = 1;
this.page = 5;
this.loading = false;
global.jQuery = $;
}
... ...
... ... @@ -11,6 +11,7 @@ import {time} from './time';
import {api} from './store';
import {RatingView, LeaveMSGView, OrderListView } from './view';
import tip from 'plugin/tip';
import dialog from 'plugin/dialog';
let FastClick = require('yoho-fastclick');
... ... @@ -112,7 +113,6 @@ let chat = {
const self = this;
cmEntity.encryptedUid = encryptedUid;
self.fetchHistoryMsg().always(function() {
... ... @@ -167,7 +167,7 @@ let chat = {
onOpen: $.noop,
sendFailCallback: function() {
self._sysInfo('<p>连接断开,请尝试<span class="blue">重连</span></p>')
.one('click', function() {
.one('touchend', function() {
self.connect();
});
},
... ... @@ -184,8 +184,49 @@ let chat = {
*/
bindEvents: function() {
let self = this;
let $dialog;
this.$chat
.on('click.Queue.quit', '[data-trigger=quit-queue]', function() {
dialog.showDialog({
dialogText: '确认结束排队吗?',
hasFooter: {
leftBtnText: '继续等待',
rightBtnText: '结束排队'
}
}, function() {
cmEntity.type = socketConf.recType.QUIT_QUEUE;
socket.send(JSON.stringify(cmEntity));
dialog.hideDialog();
});
$dialog = $('.dialog-wrapper .dialog-box');
$dialog.css({
background: 'hsla(100, 100%, 100%, 1)'
});
})
.on('click.Chat.end', '[data-trigger=end-chat]', function() {
dialog.showDialog({
dialogText: '确认结束本次服务吗?',
hasFooter: {
leftBtnText: '继续咨询',
rightBtnText: '结束服务'
}
}, function() {
cmEntity.type = socketConf.recType.USER_END_CHAT;
socket.send(JSON.stringify(cmEntity));
dialog.hideDialog();
});
$dialog = $('.dialog-wrapper .dialog-box');
$dialog.css({
background: 'hsla(100, 100%, 100%, 1)'
});
})
.on('click.Chat.end', '[data-action=re-connect]', function() {
self.connect();
})
.on('click.Rating.toggle', '[data-trigger=rating]', function() {
if (self.canEvalute) {
self.ratingView.toggle();
... ... @@ -268,12 +309,14 @@ let chat = {
conversationId: cmEntity.conversationId,
});
}).on('rating-success', function(e, data) {
const state = (window.socket || {}).readyState;
self._sysInfo(`您对我们的服务评价为:${data}`);
self.canEvalute = false;
cmEntity.type = socketConf.recType.EVALUTE_SUCCESS;
if (state === WebSocket.OPEN) {
socket.send(JSON.stringify(cmEntity));
// resizeFooter();
}
});
... ... @@ -322,12 +365,12 @@ let chat = {
disconnect(content) {
let self = this;
self.renderHeader('offline');
this.canLeaveMSG = true;
this.$chat.toggleClass('online', false);
this.toggleMenu(false);
this._sysInfo(`<p>${content}<span class="blue">连接客服</span></p>`)
.one('click', function() {
.one('touchend', function() {
self.connect();
});
},
... ... @@ -576,6 +619,7 @@ let chat = {
// ------------------------------------------
// 用户进入
case allTypes.ENTER:
this.renderHeader('robot');
chatMessage.newContent && this._sysInfo(chatMessage.newContent);
break;
... ... @@ -590,6 +634,11 @@ let chat = {
this._sysInfo(chatMessage.content);
break;
case allTypes.QUIT_QUEUE:
this.renderHeader('robot');
this._sysInfo(chatMessage.content);
break;
// 客服邀请评价
case allTypes.EVAL_INVITE:
this._sysInfo('<p data-trigger="rating">请对我们的服务进行<span class="blue">评价</span></p>');
... ... @@ -636,7 +685,6 @@ let chat = {
*/
_manualState(state, cmEntity) { // eslint-disable-line
const self = this;
const $chatHeader = self.$header;
const $chat = self.$chat;
const sysInfo = self._sysInfo.bind(this);
const chatMessage = cmEntity.chatMessage;
... ... @@ -670,12 +718,13 @@ let chat = {
// state 1: 排队中
function inQueue() {
self.renderHeader('queue');
whetherLeaveMsg(cmEntity);
}
// state 2: 人工客服进入
function linkSuccess() {
$chatHeader.find('.js-service-txt').text('YOHO客服');
self.renderHeader('human');
$chat
.toggleClass('online', true)
... ... @@ -825,7 +874,7 @@ let chat = {
},
switchService: function(type) {
this.renderHeader(type);
this.renderHeader(`switch-${type}`);
if (type === 'human') {
cmEntity.type = socketConf.recType.MANUAL_SERVICE;
... ... @@ -843,9 +892,25 @@ let chat = {
title: '智能小YO',
right: '<span data-action="change-human">人工客服</span>'
},
queue: {
title: '<i class="chat-status"></i><span class="js-service-txt">队列中...</span>',
right: '<span data-trigger="quit-queue">结束排队</span>'
},
human: {
title: '<i class="chat-status"></i><span class="js-service-txt">YOHO客服</span>',
right: '<span data-trigger="end-chat">结束服务</span>'
},
offline: {
title: '<i class="chat-status"></i><span class="js-service-txt">YOHO客服</span>',
right: '<span data-action="re-connect">重新连接</span>'
},
'switch-robot': {
title: '<i class="chat-status"></i><span class="js-service-txt">正在连接...</span>',
right: '<span class="chat-rating-trigger" data-trigger="rating">评价</span>'
right: '<span></span>'
},
'switch-human': {
title: '<i class="chat-status"></i><span class="js-service-txt">连接人工...</span>',
right: ''
}
};
... ...
... ... @@ -62,12 +62,11 @@ function sendMsg(msg) {
socket.send(msg);
} else {
sendFailCallback();
console.log('The socket is not open.');
}
}
module.exports = {
init: socketInit,
send: sendMsg
send: sendMsg,
};
... ...
... ... @@ -30,6 +30,8 @@ let config = {
SUC_DISTRIBUTE: 10009, // 客服管理员收到会话分配成功的回执
CS_CHATTING: 5000000, // 客服管理员收到会话分配成功的回执
IN_QUNEUE: 777777, // 队列中发送消息后收到的反馈
QUIT_QUEUE: 888881, // 排队中退申请退出队列
USER_END_CHAT: 888882, // 用户结束会话
OFFLINE: 999999999, // 断线
OP_LEAVE: 999999998 // 对方离开
},
... ...