Commit cc15a1f0 by 前端

api

1 parent 76ee2511
import api from "~/utils/request/request.js";
export default {
//处理对练环节的请求,并根据不同的环节提供相应的建议或执行相应的操作。
sparring(data = {}) {
return api.post(
"",
data,
[],
"/router/sparring",
"/router/sparring/1.0.0",
"AI"
);
},
//获取防守建议
defense(data = {}) {
return api.post(
"",
data,
[],
"/router/defense",
"/router/defense/1.0.0",
"AI"
);
},
//通过POST请求获取灵感建议。
inspiration(data = {}) {
return api.post(
"",
data,
[],
"/router/inspiration/1.0.0",
"AI"
);
},
//异步函数,通过分析历史消息来获取改进建议和润色表达的提示。
enhancement(data = {}) {
return api.post(
"",
data,
[],
"/router/enhancement/1.0.0",
"AI"
);
},
//根据提供的历史消息、用户ID、批次ID和持续时间,获取销售能力模拟评测的结果,并将结果数据存储数据库。
scoring(data = {}) {
return api.post(
"",
data,
[],
"/router/scoring/1.0.0",
"AI"
);
},
......
......@@ -23,29 +23,21 @@ const productList = [{
}
]
import aiApi from '../../../aiApi'
import {WELCOME} from './data'
Page({
/**
* 页面的初始数据
*/
data: {
productInfo: {},
step: 'reception',// 当前对练的环节,可选值为"reception"(接待)、"defense"(攻防)、"referral"(转介)、"over"(结束),用于指示当前处理的环节。
navStyle: 'background-image: linear-gradient(0deg, #FAFAFA 0%, #EBF3FF 100%);',
showChat: false, // false 展示介绍页,true展示聊天页
showScenePopup: false, // 场弹窗
showSpeechPopup: false, // 语音弹窗
popType: '', // script 话术攻防,inspiration 对话灵感,scene 场景
controlBoxStyle: '', // 控制控制台的层级
chatList: [{
role: 1,
content: '控制控制台的层级',
time: 5,
}, {
role: 2,
content: '控制控制台的层级',
time: 5,
show:false,
loading:false
}],
chatList: [],
scriptList: [ // 话术攻防数据
{
content: '这个车我用两年就换了,没必要买延保。'
......@@ -100,11 +92,11 @@ Page({
popType: type,
controlBoxStyle
})
setTimeout(() => {
this.setData({
inspirationContent: '当然,我很高兴能为您提供帮助。我们的新款车型性能优越,安全性能出色,而且售后服务也非常完善。您可以放心购买,我们会为您提供最优质的购车体验。您有什么特别需求或偏好吗?'
})
}, 3000)
if(type == 'inspiration') {
this.getInspiration()
}else {
this.getDefense()
}
},
// 弹窗取消
cancel() {
......@@ -113,47 +105,109 @@ Page({
})
},
send(e) {
const {result:content,filePath} = e.detail
const {chatList} = this.data;
const {
result: content,
filePath
} = e.detail
const {
chatList
} = this.data;
chatList.push({
role:2,
role: 2,
content,
filePath,
loading: false,
show:false,
loading: true,
show: false,
})
this.setData({
chatList,
showSpeechPopup:false
showSpeechPopup: false
})
aiApi.sparring({}).then(res=>{
this.getSparring(content);
this.getEnhancement(content);
},
//获取改进建议和润色表达
getEnhancement(last_message) {
aiApi.enhancement({last_message}).then(res=>{
console.log(res)
})
},
//获取防守建议
getDefense() {
aiApi.inspiration({}).then(res=>{
this.setData({scriptList:[1,2,3]})
})
},
//获取灵感建议
getInspiration() {
aiApi.inspiration({}).then(res=>{
this.setData({
inspirationContent: '当然,我很高兴能为您提供帮助。我们的新款车型性能优越,安全性能出色,而且售后服务也非常完善。您可以放心购买,我们会为您提供最优质的购车体验。您有什么特别需求或偏好吗?'
})
})
},
//提供相应的建议
getSparring(user_message) {
const {step} = this.data
let history_message
if(!user_message) {
history_message = WELCOME
}else {
history_message = '5'
}
aiApi.sparring({
user_message,
history_message,
step,
main_point: 4,
defense_step: 4,
round: 0
}).then(res => {
const {chatList} = this.data;
const {sale_message} = res
chatList.push({
role: 1,
content: sale_message,
time: Math.floor(sale_message.length / 3)
})
this.setData({chatList})
})
},
//重置
resetChat() {
const {chatList} = this.data;
const {
chatList
} = this.data;
chatList.pop();
chatList.pop();
this.setData({chatList})
this.setData({
chatList
})
},
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})
this.setData({
chatList
})
},
// 点击说话
handleSpeak() {
this.setData({
showSpeechPopup: true
showSpeechPopup: true,
controlBoxStyle:'z-index: 0;'
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getSparring('')
},
/**
......
export const WELCOME =
`
销售说:您好,张先生,我是这里的质保经理李强。首先,恭喜您提车,成为我们M7车型的尊贵车主!在您享受驾驶乐趣的同时,稍后我会向您详细介绍车辆的使用注意事项以及我们提供的保养和质保相关服务。
`
\ No newline at end of file
......@@ -6,6 +6,7 @@ import {
} from './http.js'
// console.log(secretKey, 'secretKey')
import util from '~/utils/util.js'
import qs from '~/utils/lib/qs'
/**接口 */
class Request {
get(method, data, noSignAttr, requestPath, domainName) {
......@@ -24,16 +25,27 @@ class Request {
{
'content-type': 'application/x-www-form-urlencoded'
} :
{}
if(domainName != 'AI')
data = _this.getData(data, method, noSignAttr , domainName == 'merchants')
{};
let url = `${domain[domainName]}${requestPath || path}`;
if(method) {
data = _this.getData(data, method, noSignAttr , domainName == 'merchants')
url = `${domain[domainName]}${requestPath || path}?method=${method}`;
}else {
const queryString = qs.stringify(data, {
arrayFormat: 'indices',
allowDots: true,
encodeValuesOnly: true
})
url = `${domain[domainName]}${requestPath || path}?${queryString}`
data = null
}
// console.log('reqData',data?.sessionId);
// delete
// if (data?.sessionId) {
// delete data?.sessionId
// }
wx.request({
url: `${domain[domainName]}${requestPath || path}?method=${method}`,
url,
data,
method: RequestMethods,
header,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!