Skip to content

Commit a729fbd

Browse files
lixinkuandcw1123
authored andcommitted
AI-1710 公有云:客服对接机器人平台解决/未解决评价 - 网页 (前端)(增加选择标签功能)
1 parent bc329a1 commit a729fbd

File tree

12 files changed

+1028
-38
lines changed

12 files changed

+1028
-38
lines changed

src/js/app/modules/apiHelper.js

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ function getArticleJson(data){
12351235
// 猜你想说 接口列表
12361236
function getGuessList(data){
12371237
var officialAccount = profile.currentOfficialAccount;
1238-
if(!officialAccount) return;
1238+
if(!officialAccount) return;
12391239
return new Promise(function(resolve, reject){
12401240
api("getGuessList", {
12411241
tenantId: config.tenantId,
@@ -1309,6 +1309,59 @@ function getStatisfyNo(robotAgentId, satisfactionCommentKey){
13091309
});
13101310
}
13111311

1312+
function getSatisfactionCommentTags(robotAgentId){
1313+
return new Promise(function(resolve, reject){
1314+
api("getSatisfactionCommentTags", {
1315+
tenantId: config.tenantId,
1316+
robotAgentId: robotAgentId
1317+
}, function(msg){
1318+
var status = utils.getDataByPath(msg, "data.status");
1319+
var entities = utils.getDataByPath(msg, "data.entities");
1320+
if(status === "OK"){
1321+
resolve(entities);
1322+
}
1323+
else{
1324+
reject(msg.data);
1325+
}
1326+
}, function(error){
1327+
reject(error);
1328+
});
1329+
});
1330+
}
1331+
function confirmSatisfaction(robotAgentId, satisfactionCommentKey, selected){
1332+
var data = {
1333+
satisfactionCommentKey: satisfactionCommentKey,
1334+
type: 2,
1335+
};
1336+
selected && (data.reasonTag = selected);
1337+
1338+
return new Promise(function(resolve, reject){
1339+
emajax({
1340+
url: "/v1/webimplugin/tenants/" + config.tenantId + "/robot-agents/" + robotAgentId + "/satisfaction-comment",
1341+
data: data,
1342+
type: "POST",
1343+
success: function(resp){
1344+
var parsed;
1345+
1346+
try{
1347+
parsed = JSON.parse(resp);
1348+
}
1349+
catch(e){}
1350+
1351+
if((parsed && parsed.status) === "OK"){
1352+
resolve(parsed.entity);
1353+
}
1354+
else{
1355+
reject(parsed);
1356+
}
1357+
},
1358+
error: function(e){
1359+
reject(e);
1360+
}
1361+
});
1362+
});
1363+
}
1364+
13121365
module.exports = {
13131366
getCurrentServiceSession: getCurrentServiceSession,
13141367
getToken: getToken,
@@ -1364,6 +1417,9 @@ module.exports = {
13641417
getStatisfyYes: getStatisfyYes,
13651418
getStatisfyNo: getStatisfyNo,
13661419
api: api,
1420+
getSatisfactionCommentTags: getSatisfactionCommentTags,
1421+
confirmSatisfaction: confirmSatisfaction,
1422+
13671423
setCacheItem: function(key, value){
13681424
cache[key] = value;
13691425
},

src/js/app/modules/chat.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var initPasteImage = require("./paste");
1313
var videoChat = require("./videoChat");
1414
var guessInfo = require("./guess/guessInfo");
1515

16+
var TagSelector = require("./chat/tagSelector");
1617
var initAgentInputStatePoller = require("./chat/initAgentInputStatePoller");
1718
var initAgentStatusPoller = require("./chat/initAgentStatusPoller");
1819
var initQueuingNumberPoller = require("./chat/initQueuingNumberPoller");
@@ -24,6 +25,7 @@ var emojiPanel = require("./chat/emojiPanel");
2425
var extendMessageSender = require("./chat/extendMessageSender");
2526
var TenantInfo = require("@/app/modules/tenantInfo/index");
2627
var tenantInfo;
28+
var tagSelector = new TagSelector();
2729

2830
var isMessageChannelReady;
2931
var config;
@@ -488,17 +490,23 @@ function _bindEvents(){
488490
var satisfactionCommentKey = this.getAttribute("data-satisfactionCommentInfo");
489491
var robotAgentId = this.getAttribute("data-agentId");
490492

491-
// this.tagSelector.show(msgId, multiTurnDialogueId);
492-
493-
apiHelper.getStatisfyNo(robotAgentId, satisfactionCommentKey).then(function(data){
494-
uikit.tip("谢谢");
495-
}, function(err){
496-
if(err.errorCode === "KEFU_ROBOT_INTEGRATION_0207"){
497-
uikit.tip("已评价");
493+
apiHelper.getSatisfactionCommentTags(robotAgentId, satisfactionCommentKey)
494+
.then(function(dat){
495+
if(dat.length > 0){
496+
// tagSelector = new TagSelector(dat, robotAgentId, satisfactionCommentKey);
497+
tagSelector.show(dat, robotAgentId, satisfactionCommentKey);
498+
}
499+
else{
500+
apiHelper.confirmSatisfaction(robotAgentId, satisfactionCommentKey)
501+
.then(function(){
502+
uikit.tip("谢谢");
503+
}, function(err){
504+
if(err.errorCode === "KEFU_ROBOT_INTEGRATION_0207"){
505+
uikit.tip("已评价");
506+
}
507+
});
498508
}
499509
});
500-
501-
// this.tagSelector.show(msgId, multiTurnDialogueId);
502510
});
503511

504512
utils.live("#em-article-close .icon-back", "click", function(){
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
var domUtils = require("@/common/domUtils");
2+
var classUtils = require("@/common/classUtils");
3+
var Dialog = require("@/common/uikit/dialog");
4+
var tips = require("@/common/uikit/tips");
5+
var uikit = require("../uikit");
6+
7+
// var profile = require("@/app/modules/tools/profile");
8+
var apiHelper = require("../apiHelper");
9+
var tpl = require("./template/tagsTpl.html");
10+
11+
var TagSelector = classUtils.createView({
12+
13+
dialog: null,
14+
msgId: "",
15+
hasTags: false,
16+
events: {
17+
"click li": "onTagClick"
18+
},
19+
20+
init: function(){
21+
var me = this;
22+
23+
24+
// 拿到 taglist
25+
// apiHelper.getSatisfactionCommentTags(robotAgentId)
26+
// .then(function(dat){
27+
// me.hasTags = dat && dat.length;
28+
// me.$el.innerHTML = _.template(tpl)({ tags: dat });
29+
// me.createDialog();
30+
// });
31+
},
32+
33+
createDialog: function(){
34+
this.dialog = new Dialog({
35+
contentDom: this.$el,
36+
className: "tag-selector" // 把 dialog 做小
37+
})
38+
.addButton({
39+
confirmText: "提交",
40+
confirm: _.bind(this.onConfirm, this)
41+
});
42+
},
43+
44+
onTagClick: function(e){
45+
var targetDom = e.target;
46+
domUtils.toggleClass(targetDom, "selected");
47+
e.stopPropagation();
48+
},
49+
50+
show: function(dat, robotAgentId, satisfactionCommentKey){
51+
this.$el.innerHTML = _.template(tpl)({ tags: dat });
52+
this.createDialog();
53+
54+
this.hasTags = dat && dat.length;
55+
this.robotAgentId = robotAgentId;
56+
this.satisfactionCommentKey = satisfactionCommentKey;
57+
// this.msgId = msgId;
58+
// this.multiTurnDialogueId = multiTurnDialogueId;
59+
if(this.hasTags){
60+
this.dialog.show();
61+
}
62+
else{
63+
tips.tip("需要管理员先设置问题标签");
64+
}
65+
},
66+
67+
hide: function(){
68+
this.dialog.hide();
69+
},
70+
71+
onConfirm: function(){
72+
var me = this;
73+
var selected = [];
74+
_.each(this.$el.querySelectorAll("li"), function(tagDom){
75+
if(domUtils.hasClass(tagDom, "selected")){
76+
selected.push(tagDom.innerText);
77+
}
78+
});
79+
// if(selected.length){
80+
// profile.getProp("sessionId").then(function(ssid){
81+
apiHelper.confirmSatisfaction(me.robotAgentId, me.satisfactionCommentKey, selected.join(","))
82+
.then(function(){
83+
uikit.tip("谢谢");
84+
}, function(err){
85+
if(err.errorCode === "KEFU_ROBOT_INTEGRATION_0207"){
86+
uikit.tip("已评价");
87+
}
88+
});
89+
90+
me.hide();
91+
// });
92+
// return true;
93+
// }
94+
// tips.tip("未解决您的问题的原因是?");
95+
return false;
96+
},
97+
98+
});
99+
100+
module.exports = TagSelector;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<p>未解决原因:</p>
2+
<ul class="em-taglist">
3+
<% _.each(tags, function(tag){ %>
4+
<li class="em-tag" tagId="<%= tag.id %>"><%= tag.name %></li>
5+
<% }) %>
6+
</ul>

0 commit comments

Comments
 (0)