Authored by 李奇

留言开关添加

@@ -227,33 +227,32 @@ var _loadPage = function() { @@ -227,33 +227,32 @@ var _loadPage = function() {
227 227
228 /** 228 /**
229 * 人工链接 229 * 人工链接
230 - * @param msgType 内部消息类型  
231 - * @param message 内部消息对象 230 + * @param rec 接收对象
232 * @private 231 * @private
233 */ 232 */
234 - function linkSuccess(msgType, message) { 233 + function linkSuccess(rec) {
  234 +
  235 + var OUT_SERVICE = 0, // 0 没上班
  236 + LINE_UP = 1, // 1 需要排队
  237 + MANUAL_SERVICE = 2, // 2 接入人工
  238 + ADMIN_MANUAL_SERVICE = 3; // 3 管理员分配
235 239
236 - var OUT_SERVICE = 0,  
237 - LINE_UP = 1,  
238 - MANUAL_SERVICE = 2,  
239 - ADMIN_MANUAL_SERVICE = 3; 240 + var message = rec.chatMessage;
  241 + var msgType = message.type;
240 242
241 var dom, 243 var dom,
242 tipText; 244 tipText;
243 245
244 switch (msgType) { 246 switch (msgType) {
245 -  
246 - case OUT_SERVICE: // 0是没上班  
247 - tipText = message.content +  
248 - '您也可以选择<a class="leave-msg">留言</a>'; 247 + case OUT_SERVICE:
  248 + tipText = receive.leaMsgTip(rec);
249 dom = tipTpl({ 249 dom = tipTpl({
250 content: tipText 250 content: tipText
251 }); 251 });
252 break; 252 break;
253 253
254 - case LINE_UP: // 1是需要排队  
255 - tipText = message.content +  
256 - '您也可以选择<a class="leave-msg">留言</a>'; 254 + case LINE_UP:
  255 + tipText = receive.leaMsgTip(rec);
257 dom = tipTpl({ 256 dom = tipTpl({
258 content: tipText 257 content: tipText
259 }); 258 });
@@ -264,7 +263,7 @@ var _loadPage = function() { @@ -264,7 +263,7 @@ var _loadPage = function() {
264 }); 263 });
265 break; 264 break;
266 265
267 - case MANUAL_SERVICE: // 2是接入人工成功 266 + case MANUAL_SERVICE:
268 tipText = message.content; 267 tipText = message.content;
269 dom = tipTpl({ 268 dom = tipTpl({
270 content: tipText 269 content: tipText
@@ -282,7 +281,7 @@ var _loadPage = function() { @@ -282,7 +281,7 @@ var _loadPage = function() {
282 }); 281 });
283 break; 282 break;
284 283
285 - case ADMIN_MANUAL_SERVICE: // 3是管理员分配客服成功 284 + case ADMIN_MANUAL_SERVICE:
286 tipText = message.content; 285 tipText = message.content;
287 dom = tipTpl({ 286 dom = tipTpl({
288 content: tipText 287 content: tipText
@@ -482,7 +481,7 @@ var _loadPage = function() { @@ -482,7 +481,7 @@ var _loadPage = function() {
482 break; 481 break;
483 482
484 case allTypes.LINK_SUCCESS: 483 case allTypes.LINK_SUCCESS:
485 - linkSuccess(msgType, message); 484 + linkSuccess(rec);
486 break; 485 break;
487 486
488 case allTypes.IN_QUNEUE: 487 case allTypes.IN_QUNEUE:
@@ -82,3 +82,21 @@ exports.preProcess = function(rec) { @@ -82,3 +82,21 @@ exports.preProcess = function(rec) {
82 break; 82 break;
83 } 83 }
84 }; 84 };
  85 +
  86 +/**
  87 + * 是否显示留言
  88 + * @param rec 接收对象
  89 + */
  90 +exports.leaMsgTip = function(rec) {
  91 + var val = rec.isLeaveMessage;
  92 + var chatMsg = rec.chatMessage;
  93 + var canLeave = val === 2;
  94 + var append = canLeave ? '您也可以选择<a class="leave-msg">留言</a>' : '';
  95 + var reg = /[,|,]$/g;
  96 +
  97 + chatMsg.content = canLeave ?
  98 + chatMsg.content :
  99 + (chatMsg.content = chatMsg.content.replace(reg, ""));
  100 +
  101 + return [chatMsg.content, append].join("");
  102 +};