Commit 66dcb2f6 by 张立顺

Merge branch 'SAAS+V4.43-0807' of http://192.168.3.233:8090/saas_plus/dj-car-bou…

…tique-work-wechat into SAAS+V4.43-0807
2 parents 847eb7e6 7b9711e6
......@@ -8,7 +8,7 @@ module.exports = {
},
/**微信登录 */
ssoLogin(data) {
return api.post("scrm.api.sso.weapp.jscode.login", data, [],
return api.post("scrm.api.sso.weapp.jscode.getOpenId", data, [],
"/rop-scrm-sso/router",
"scrm",false);
},
......
......@@ -36,7 +36,7 @@ if (systemInfo.platform != "devtools") {
case "develop":
break;
case "trial":
index = manual ? index : 4;
index = manual ? index : 2;
break;
case "release":
index = release ? index : 3;
......
......@@ -11,8 +11,7 @@ const VOICE = {
let timer = null;
let duration = 0;
import aiApi from "../../../aiApi";
const linkChainList = [
{
const linkChainList = [{
id: 1,
name: "接待",
iconUrl: "icon-reception",
......@@ -41,6 +40,21 @@ const linkChainList = [
desc: " 此环节模拟驻店专员已完成了延保产品的介绍,即将根据客户是否展示购买意愿进行话术演练,建议对明显展示不想购买意愿的客户使用逼单话术进行进一步沟通!",
},
];
import {
speechEmoji,
soundEmoji,
definitionEmoji,
toneWords,
SpeechRateValue,
calculateStars,
calculateEmotion,
speechSpeed_MIN,
speechSpeed_MAX,
Emotion_MIN,
Emotion_MAX,
calculateIntonation,
} from "../contant";
Page({
/**
* 页面的初始数据
......@@ -104,25 +118,252 @@ Page({
isVisible: false,
});
},
handleSure() {
handleSure: wx.$util.throttle(async function (e) {
this.handleCancel()
wx.$util.showLoading()
const history_message = this.getHistoryAll();
const sensitiveRes = await aiApi.getSensitive({
history_message,
});
const is_sensitive = sensitiveRes.is_sensitive;
const audioBox = this.selectComponent("#audioBox");
const chatList = JSON.stringify(audioBox.data.list);
wx.setStorageSync("chatList", chatList);
wx.setStorageSync("history_message", history_message);
const { batch_id, roleType, step, sparringTaskId, entry } = this.data;
// wx.$router.go("/packageEquity/pages/aiCheck/result/result", {
// roleType,
// duration,
// history_message,
// batch_id,
// sparringLink: step,
// sparringTaskId,
// entry
// })
wx.redirectTo({
url: `/packageEquity/pages/aiCheck/result/result?roleType=${roleType}&duration=${duration}&batch_id=${batch_id}&sparringLink=${step}&sparringTaskId=${sparringTaskId}&entry=${entry}`,
const chatList = audioBox.data.list;
this.handleSave(chatList, duration, is_sensitive);
}, 1000),
convertSecondsToMinutesAndSeconds(seconds, isSymbol) {
var minutes = Math.floor(seconds / 60); // 计算分钟数
var remainingSeconds = seconds % 60; // 计算剩余的秒数
// 如果剩余的秒数小于10,则前面添加0以保持格式一致
if (remainingSeconds < 10) {
remainingSeconds = "0" + remainingSeconds;
}
let res = minutes + "分" + remainingSeconds + "秒";
if (isSymbol) {
res = minutes + ":" + remainingSeconds;
}
return res;
},
getSentencesDetail(Sentences, totalTime, redundantWord) {
let totalSpeed = 0;
let totalEmotionValue = 0;
let axisX = [];
let axisY_SpeechRate = [];
let axisY_EmotionValue = [];
if (Sentences.length == 0) {
return;
}
if (Sentences.length > 2) {
Sentences.forEach((i, k) => {
totalSpeed += i.SpeechRate;
totalEmotionValue += i.EmotionValue;
if (k == 0) {
axisX.push("0:00");
} else if (k == Sentences.length - 1) {
axisX.push(this.convertSecondsToMinutesAndSeconds(totalTime, true));
} else {
axisX.push(k);
}
axisY_SpeechRate.push(i.SpeechRate);
axisY_EmotionValue.push(i.EmotionValue);
});
if (Sentences.length == 2) {
axisX.push(this.convertSecondsToMinutesAndSeconds(totalTime, true));
axisY_SpeechRate.push(Sentences[1].SpeechRate);
axisY_EmotionValue.push(Sentences[1].EmotionValue);
}
} else {
axisX = [
"0:00",
1,
this.convertSecondsToMinutesAndSeconds(totalTime, true),
];
axisY_SpeechRate = [
Sentences[0].SpeechRate,
Sentences[0].SpeechRate,
Sentences[0].SpeechRate,
];
axisY_EmotionValue = [
Sentences[0].EmotionValue,
Sentences[0].EmotionValue,
Sentences[0].EmotionValue,
];
totalSpeed = Sentences[0].SpeechRate;
totalEmotionValue = Sentences[0].EmotionValue;
}
const averageSpeed = totalSpeed / Sentences.length;
const averageEmotionValue = totalEmotionValue / Sentences.length;
const speechSpeed = {
star: calculateStars(averageSpeed),
x: axisX,
y: axisY_SpeechRate,
min: speechSpeed_MIN,
max: speechSpeed_MAX,
};
const definition = {
x: axisX,
y: axisY_EmotionValue,
star: calculateEmotion(averageEmotionValue, true),
min: Emotion_MIN,
max: Emotion_MAX,
};
const axisY_Intonation = axisY_EmotionValue.map((currentValue, index) => {
if (index < axisY_EmotionValue.length - 1) {
const mul = Math.ceil(axisY_EmotionValue[index + 1] - currentValue) + 1;
return mul > 0 ? mul : 0;
} else {
return 1;
}
});
const intonation_star = calculateIntonation(axisY_EmotionValue, true);
let intonation_min, intonation_max;
if (intonation_star == 1) {
intonation_min = axisY_Intonation[0] + 3;
intonation_max = axisY_Intonation[0] + 5;
} else {
intonation_min = Math.min(...axisY_Intonation);
intonation_max = Math.max(...axisY_Intonation) + 1;
}
const intonation = {
x: axisX,
y: axisY_Intonation,
star: intonation_star,
min: intonation_min,
max: intonation_max,
};
const redundantWords = this.getWord(redundantWord);
return {
speechSpeed,
redundantWords,
definition,
intonation,
};
},
getWord(words) {
const sentences = words.split(/[,。,]/);
const regex = new RegExp(`(${toneWords.join("|")})\\1+`, "g");
const filteredSentences = sentences.filter((sentence) => {
return sentence.match(regex);
});
const regex_num = new RegExp(
`(${toneWords
.map((str) => str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"))
.join("|")})\\1+`,
"g"
);
const matches = words.match(regex_num) || [];
const wordNum = matches.reduce((cur, prev) => {
return cur + (prev.length - 1);
}, 0);
let star = 5 - Math.ceil(wordNum / 2);
if (star < 1) {
star = 1;
}
const content = filteredSentences.join(",");
return {
star,
content,
};
},
handleSave(list, sparringDuration, triggerSensitive) {
let totalTime = 0;
let Sentences = [];
let content = "";
list.forEach((i) => {
if (i.role == 2) {
totalTime += i.times;
content += i.content;
Sentences = [...Sentences, ...i.Sentences];
}
});
const {
speechSpeed,
redundantWords,
definition,
intonation
} =
this.getSentencesDetail(Sentences, totalTime, content) || {};
const {
sparringTaskId,
roleType,
sparringLink,
entry
} = this.data;
const {
merchantId,
uuid
} = wx.$util.getUserInfo();
const fluency = {
speechSpeed: JSON.stringify(speechSpeed),
redundantWords: JSON.stringify(redundantWords),
};
const deliver = {
definition: JSON.stringify(definition),
intonation: JSON.stringify(intonation),
};
const details = list.map((i) => {
const {
role,
content,
suggestions_for_improvement: improve,
refine_the_expression: polish,
voiceUrl,
times: voiceDuration,
spkTime,
speed,
intonation,
definition,
redundant,
} = i;
return {
sparringLink,
voiceDuration,
role,
voiceUrl,
content,
improve,
polish,
spkTime,
speed,
intonation,
definition,
redundant,
};
});
const openId = wx.$util.getOpenId();
carLifeApi
.sparringCommit({
openId,
staffUuid: uuid,
sparringTaskId: sparringTaskId || -1,
roleType,
sparringDuration: sparringDuration * 1000,
yqMerchantId: merchantId,
fluency,
deliver,
triggerSensitive,
details: JSON.stringify(details),
})
.then((res) => {
const id = res.data.sparringRecordId
wx.$util.hideLoading()
wx.requestSubscribeMessage({
tmplIds: ["WH1kEKtvU_RbHFu6_DRm3G9sqUhky_hZHjevxrz8GK8"],
success(res) {
wx.showToast({
title: "订阅成功",
icon: "none",
});
wx.redirectTo({
url: `/packageEquity/pages/aiCheck/result/result?roleType=${roleType}&id=${id}&entry=${entry}`,
});
},
fail(res) {
wx.redirectTo({
url: `/packageEquity/pages/aiCheck/result/result?roleType=${roleType}&id=${id}&entry=${entry}`,
});
}
});
});
},
toBottom() {
setTimeout(() => {
......@@ -144,7 +385,10 @@ Page({
},
//选择攻防话术
async handleScript() {
const { attackScript, scriptList } = this.data;
const {
attackScript,
scriptList
} = this.data;
const audioBox = this.selectComponent("#audioBox");
const list = audioBox.data.list;
let isCan = true;
......@@ -171,8 +415,7 @@ Page({
});
const content = Phrases.similar_words;
this.data.isSend = true;
audioBox.setList(
{
audioBox.setList({
content,
times: Math.ceil(content.length / 4),
spkTime: new Date().format("yyyy-MM-dd hh:mm:ss"),
......@@ -252,7 +495,11 @@ Page({
}
},
send(e) {
const { result: content, filePath, times } = e.detail;
const {
result: content,
filePath,
times
} = e.detail;
console.log(filePath);
const addVal = {
role: 2,
......@@ -267,8 +514,7 @@ Page({
const audioBox = this.selectComponent("#audioBox");
const idx = audioBox.data.list.length;
audioBox.addList(addVal);
this.setData(
{
this.setData({
inspirationContent: "",
showSpeechPopup: false,
},
......@@ -290,8 +536,13 @@ Page({
},
//获取改进建议和润色表达
getEnhancement(last_message, idx, retryCount = 0) {
const { batch_id } = this.data;
const { uuid, name } = wx.$util.getUserInfo();
const {
batch_id
} = this.data;
const {
uuid,
name
} = wx.$util.getUserInfo();
aiApi
.enhancement({
last_message,
......@@ -314,8 +565,7 @@ Page({
}
);
const audioBox = this.selectComponent("#audioBox");
audioBox.setSuggest(
{
audioBox.setSuggest({
loading: false,
refine_the_expression,
suggestions_for_improvement,
......@@ -332,7 +582,10 @@ Page({
});
},
getHistory() {
let { step, defenseIndex } = this.data;
let {
step,
defenseIndex
} = this.data;
const audioBox = this.selectComponent("#audioBox");
return audioBox.getList(step, defenseIndex);
},
......@@ -341,8 +594,13 @@ Page({
* 如果进入攻防状态(defense),直接拿对应的灵感
*/
getInspiration() {
const { step, inspirationContent, roleInspiration, attackScript } =
this.data;
const {
step,
inspirationContent,
roleInspiration,
attackScript
} =
this.data;
console.log(inspirationContent, roleInspiration, "inspirationContent");
if (step == "defense") {
this.setData({
......@@ -352,8 +610,13 @@ Page({
}
if (inspirationContent) return;
const history_message = this.getHistory();
const { batch_id, roleDetail } = this.data;
const { uuid } = wx.$util.getUserInfo();
const {
batch_id,
roleDetail
} = this.data;
const {
uuid
} = wx.$util.getUserInfo();
const user_info = JSON.stringify({
user_sex: roleDetail.replace(/.*性别:(.).*/, "$1"),
});
......@@ -395,7 +658,9 @@ Page({
if (retryCount == 0) {
audioBox.addList(addVal);
}
const { uuid } = wx.$util.getUserInfo();
const {
uuid
} = wx.$util.getUserInfo();
aiApi
.sparring({
person_type,
......@@ -411,10 +676,14 @@ Page({
round,
})
.then((res) => {
const { sale_message, round, defense_step, step: next_step } = res;
const {
sale_message,
round,
defense_step,
step: next_step
} = res;
console.log("batch_id", batch_id, "uuid", uuid);
audioBox.setList(
{
audioBox.setList({
content: sale_message.replace(/,/g, ","),
times: Math.ceil(sale_message.length / 4),
spkTime: new Date().format("yyyy-MM-dd hh:mm:ss"),
......@@ -445,8 +714,12 @@ Page({
});
},
handleShow(e) {
const { index } = e.currentTarget.dataset;
const { chatList } = this.data;
const {
index
} = e.currentTarget.dataset;
const {
chatList
} = this.data;
chatList[index].show = true;
this.setData({
chatList,
......@@ -458,7 +731,9 @@ Page({
wx.$util.showToast("AI还未回复");
return;
}
const { speakLoading } = this.data;
const {
speakLoading
} = this.data;
if (speakLoading) return;
this.setData({
speakLoading: true,
......@@ -524,7 +799,13 @@ Page({
*/
async onLoad(options) {
this.getIsPlay();
let { roleType: type, stage, roleName: name, isDemo, entry } = options;
let {
roleType: type,
stage,
roleName: name,
isDemo,
entry
} = options;
let params = {
roleType: type,
};
......@@ -574,7 +855,10 @@ Page({
});
},
async getIsPlay() {
const { merchantId, uuid } = wx.$util.getUserInfo();
const {
merchantId,
uuid
} = wx.$util.getUserInfo();
const res = await aiApi.setSparringVerify({
staffUuid: uuid,
yqMerchantId: merchantId,
......@@ -640,4 +924,4 @@ Page({
}
});
},
});
});
\ No newline at end of file
......@@ -92,7 +92,10 @@ Page({
// 头部返回上一级
back() {
console.log(111111);
if(this.data.backStatus) {
wx.$router.reLaunch('packageEquity.equityPage')
return
}
const pages = getCurrentPages();
const prevPage = pages[pages.length - 2];
console.log(prevPage.route);
......@@ -174,33 +177,25 @@ Page({
})
.exec();
},
setRemind() {
wx.requestSubscribeMessage({
tmplIds: ["ctivVQAIoDzv1OKlcI9cXiJpyKZBUP1XamO8sBP8ij0"],
success(res) {
wx.showToast({
title: "订阅成功",
icon: "none",
});
wx.p.router.back();
},
});
},
/**
* 生命周期函数--监听页面加载+
*
*/
async onLoad(options) {
this.setRemind();
const {
duration,
batch_id,
let {
roleType,
id,
sparringLink,
sparringTaskId,
entry,
} = options;
this.getAvatar(roleType);
if(entry == "notice") {
this.setData({
backStatus:true
})
entry = 'other'
}
this.setData({
id,
entry,
......@@ -208,10 +203,6 @@ Page({
sparringLink,
sparringTaskId,
});
this.getAvatar(roleType);
const { uuid } = wx.$util.getUserInfo();
if (id) {
this.setData({
duration: false,
});
......@@ -219,18 +210,7 @@ Page({
this.getChatDetail({
id,
});
} else {
const history_message = wx.getStorageSync("history_message");
const sensitiveRes = await aiApi.getSensitive({
history_message,
});
const is_sensitive = sensitiveRes.is_sensitive;
const chatList = JSON.parse(wx.getStorageSync("chatList"));
this.setData({
chatList,
});
this.handleSave(chatList, duration, is_sensitive);
}
console.log(windowW);
},
......
......@@ -66,7 +66,7 @@ class Request {
if (thisPage.route != 'pages/wxLogin/wxLogin') {
getApp().login(true)
}
} else if (code == -1 && failTips) {
} else if (code == -1) {
wx.showToast({
title: message || '网络请求失败',
icon: 'none'
......
......@@ -114,7 +114,7 @@ const setOpenId = openId => {
wx.setStorageSync('dj_boutique_openId', openId)
}
const getOpenId = () => {
wx.getStorageSync('dj_boutique_openId', openId)
return wx.getStorageSync('dj_boutique_openId')
}
const removeStorage = () => {
wx.removeStorageSync('noSignInUuid')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!