Authored by 陈轩

save

@@ -175,19 +175,6 @@ var chat = { @@ -175,19 +175,6 @@ var chat = {
175 * data: object //消息数据 175 * data: object //消息数据
176 * } 176 * }
177 * 177 *
178 - * 测试数据:  
179 - chat.sendMSG({  
180 - type: 'order',  
181 - data: {  
182 - data: '123123',  
183 - imgSrc: '123123123123',  
184 - orderCode: '123123123123',  
185 - cost: '123123123123',  
186 - createTime: '123123123123',  
187 - orderStatus: '123123123123'  
188 - }  
189 - })  
190 - *  
191 */ 178 */
192 sendMSG: function(msg) { 179 sendMSG: function(msg) {
193 if (!msg || !msg.data) { 180 if (!msg || !msg.data) {
@@ -198,6 +185,7 @@ var chat = { @@ -198,6 +185,7 @@ var chat = {
198 let arr; 185 let arr;
199 186
200 msg.type = msg.type || 'text'; 187 msg.type = msg.type || 'text';
  188 + msg.from = msg.from || 'customer';
201 189
202 msg.uid = uuid; 190 msg.uid = uuid;
203 cmEntity.uuid = uuid; 191 cmEntity.uuid = uuid;
@@ -300,9 +288,23 @@ var chat = { @@ -300,9 +288,23 @@ var chat = {
300 allTypes = socketConf.recType; 288 allTypes = socketConf.recType;
301 289
302 var uuid = rec.uuid; 290 var uuid = rec.uuid;
  291 + var viewData;
303 292
304 switch (recType) { 293 switch (recType) {
305 294
  295 + // 客服消息
  296 + case allTypes.CS_SEND:
  297 + case allTypes.ROBOT_SEND:
  298 + viewData = this.buildViewData(rec);
  299 + viewData && this._drawMSG(viewData);
  300 + break;
  301 +
  302 + // 系统消息
  303 + case allTypes.OFFLINE: break;
  304 + case allTypes.TRANSFER: break;
  305 + case allTypes.MANUAL_SERVICE: break;
  306 + case allTypes.CS_CHANGE_STATE: break;
  307 +
306 } 308 }
307 309
308 return this; 310 return this;
@@ -314,6 +316,11 @@ var chat = { @@ -314,6 +316,11 @@ var chat = {
314 */ 316 */
315 _drawMSG: function(viewData) { 317 _drawMSG: function(viewData) {
316 let chatWin = this.$chatWin[0]; 318 let chatWin = this.$chatWin[0];
  319 +
  320 + if (!$.isArray(viewData)) {
  321 + viewData = [viewData];
  322 + }
  323 +
317 let $html = $(this.messageT(viewData)); 324 let $html = $(this.messageT(viewData));
318 325
319 $html.appendTo(this.$chatWin); 326 $html.appendTo(this.$chatWin);
@@ -361,6 +368,10 @@ var chat = { @@ -361,6 +368,10 @@ var chat = {
361 }); 368 });
362 }, 369 },
363 370
  371 + switchService: function(type) {
  372 + this.renderHeader(type);
  373 + },
  374 +
364 /** 375 /**
365 * method: 渲染头部 376 * method: 渲染头部
366 * @param {string} type ["robot", "human"] 377 * @param {string} type ["robot", "human"]