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