Skip to content

Commit 1009ff2

Browse files
lixinkuandcw1123
authored andcommitted
AI-1710 公有云:客服对接机器人平台解决/未解决评价 - 网页 (前端)
1 parent 5e62a37 commit 1009ff2

File tree

6 files changed

+120
-1
lines changed

6 files changed

+120
-1
lines changed

demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ <h1>测试</h1>
106106
};
107107
</script>
108108

109-
<script src="easemob.js"></script>
109+
<script src="easemob.js?configId=7c807d13-4c9a-42a7-a634-c4245da8059d"></script>
110110
</body>
111111
</html>

src/js/app/modules/apiHelper.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,67 @@ function getGuessList(data){
12481248
});
12491249
}
12501250

1251+
function getStatisfyYes(robotAgentId, satisfactionCommentKey){
1252+
return new Promise(function(resolve, reject){
1253+
emajax({
1254+
url: "/v1/webimplugin/tenants/" + config.tenantId + "/robot-agents/" + robotAgentId + "/satisfaction-comment",
1255+
data: {
1256+
satisfactionCommentKey: satisfactionCommentKey,
1257+
type: 1
1258+
},
1259+
type: "POST",
1260+
success: function(resp){
1261+
var parsed;
1262+
1263+
try{
1264+
parsed = JSON.parse(resp);
1265+
}
1266+
catch(e){}
1267+
1268+
if((parsed && parsed.status) === "OK"){
1269+
resolve(parsed.entity);
1270+
}
1271+
else{
1272+
reject(parsed);
1273+
}
1274+
},
1275+
error: function(e){
1276+
reject(e);
1277+
}
1278+
});
1279+
});
1280+
}
1281+
function getStatisfyNo(robotAgentId, satisfactionCommentKey){
1282+
return new Promise(function(resolve, reject){
1283+
emajax({
1284+
url: "/v1/webimplugin/tenants/" + config.tenantId + "/robot-agents/" + robotAgentId + "/satisfaction-comment",
1285+
data: {
1286+
satisfactionCommentKey: satisfactionCommentKey,
1287+
type: 2
1288+
},
1289+
type: "POST",
1290+
success: function(resp){
1291+
var parsed;
1292+
1293+
try{
1294+
parsed = JSON.parse(resp);
1295+
}
1296+
catch(e){}
1297+
1298+
if((parsed && parsed.status) === "OK"){
1299+
resolve(parsed.entity);
1300+
}
1301+
else{
1302+
reject(parsed);
1303+
}
1304+
},
1305+
error: function(e){
1306+
reject(e);
1307+
}
1308+
});
1309+
});
1310+
}
1311+
12511312
module.exports = {
12521313
getCurrentServiceSession: getCurrentServiceSession,
12531314
getToken: getToken,
@@ -1300,6 +1361,8 @@ module.exports = {
13001361
getGuessList: getGuessList,
13011362

13021363
initApiTransfer: initApiTransfer,
1364+
getStatisfyYes: getStatisfyYes,
1365+
getStatisfyNo: getStatisfyNo,
13031366
api: api,
13041367
setCacheItem: function(key, value){
13051368
cache[key] = value;

src/js/app/modules/channel.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ function _handleMessage(msg, options){
398398
: (!msg.from || (msg.from.toLowerCase() !== config.user.username.toLowerCase()));
399399
var officialAccount = utils.getDataByPath(msg, "ext.weichat.official_account");
400400
var marketingTaskId = utils.getDataByPath(msg, "ext.weichat.marketing.marketing_task_id");
401+
var satisfactionCommentInvitation = utils.getDataByPath(msg, "ext.weichat.extRobot.satisfactionCommentInvitation");
402+
var satisfactionCommentInfo = utils.getDataByPath(msg, "ext.weichat.extRobot.satisfactionCommentInfo");
403+
var agentId = utils.getDataByPath(msg, "ext.weichat.agent.userId");
401404
var officialAccountId = officialAccount && officialAccount.official_account_id;
402405
var videoTicket = utils.getDataByPath(msg, "ext.msgtype.sendVisitorTicket.ticket");
403406
var videoExtend = utils.getDataByPath(msg, "ext.msgtype.sendVisitorTicket.extend");
@@ -691,6 +694,18 @@ function _handleMessage(msg, options){
691694
noPrompt: noPrompt,
692695
});
693696

697+
// 是否发送解决未解决msg.ext.extRobot.satisfactionCommentInvitation
698+
if(satisfactionCommentInvitation && !isHistory){
699+
_appendMsg({
700+
data: "<p>此次服务是否已解决您的问题:</p><a class='statisfyYes' data-satisfactionCommentInfo='" + satisfactionCommentInfo + "' data-agentId='" + agentId + "'>解决</a>/<a class='statisfyNo' data-satisfactionCommentInfo='" + satisfactionCommentInfo + "' data-agentId='" + agentId + "'>未解决</a>",
701+
type: "txtLink",
702+
}, {
703+
isReceived: true,
704+
isHistory: false
705+
});
706+
}
707+
708+
694709
if(!isHistory){
695710
!noPrompt && _messagePrompt(message, targetOfficialAccount);
696711
// 兼容旧的消息格式

src/js/app/modules/chat.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,37 @@ function _bindEvents(){
470470
satisfaction.show(inviteId, serviceSessionId);
471471
});
472472

473+
// 解决
474+
utils.live("a.statisfyYes", "click", function(){
475+
var satisfactionCommentKey = this.getAttribute("data-satisfactionCommentInfo");
476+
var robotAgentId = this.getAttribute("data-agentId");
477+
apiHelper.getStatisfyYes(robotAgentId, satisfactionCommentKey).then(function(data){
478+
uikit.tip("谢谢");
479+
}, function(err){
480+
if(err.errorCode === "KEFU_ROBOT_INTEGRATION_0207"){
481+
uikit.tip("已评价");
482+
}
483+
});
484+
});
485+
486+
// 未解决
487+
utils.live("a.statisfyNo", "click", function(){
488+
var satisfactionCommentKey = this.getAttribute("data-satisfactionCommentInfo");
489+
var robotAgentId = this.getAttribute("data-agentId");
490+
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("已评价");
498+
}
499+
});
500+
501+
// this.tagSelector.show(msgId, multiTurnDialogueId);
502+
});
503+
473504
utils.live("#em-article-close .icon-back", "click", function(){
474505
var articleContainer = document.getElementById("em-article-container");
475506
var iframe = articleContainer.querySelector("iframe");

src/js/app/modules/tools/messageFactory.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ function genMsgContent(msg){
1818
// 历史消息以及收到的实时消息
1919
html = "<span class=\"text\">" + _.map(value, function(fragment){ return fragment.value; }).join("") + "</span>";
2020
break;
21+
case "txtLink":
22+
html = value;
23+
break;
2124
case "img":
2225
// todo: remove a
2326
html = "<a href=\"javascript:;\"><img class=\"em-widget-imgview\" src=\""

src/scss/chat.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,3 +535,10 @@
535535
transform: rotate(360deg)
536536
}
537537
}
538+
539+
.statisfyYes {
540+
cursor: pointer;
541+
}
542+
.statisfyNo {
543+
cursor: pointer;
544+
}

0 commit comments

Comments
 (0)