Commit 55b85a53 by 前端

fixed

1 parent 18542391
...@@ -122,14 +122,22 @@ Page({ ...@@ -122,14 +122,22 @@ Page({
this.setData({ this.setData({
chatList, chatList,
showSpeechPopup: false showSpeechPopup: false
}) },()=>{
this.getSparring(content); this.getSparring(content);
this.getEnhancement(content); this.getEnhancement(content);
})
}, },
//获取改进建议和润色表达 //获取改进建议和润色表达
getEnhancement(last_message) { getEnhancement(last_message) {
aiApi.enhancement({last_message}).then(res=>{ aiApi.enhancement({last_message}).then(res=>{
console.log(res) const {refine_the_expression,suggestions_for_improvement} = res;
const {chatList} = this.data;
const len = chatList.length - 2;
chatList[len].loading = false;
chatList[len].refine_the_expression = refine_the_expression
chatList[len].suggestions_for_improvement = suggestions_for_improvement
this.setData({chatList})
}) })
}, },
//获取防守建议 //获取防守建议
...@@ -138,38 +146,51 @@ Page({ ...@@ -138,38 +146,51 @@ Page({
this.setData({scriptList:[1,2,3]}) this.setData({scriptList:[1,2,3]})
}) })
}, },
getHistory() {
const {chatList} = this.data;
let history = ''
chatList.forEach(item=>{
if(item.role == 1) {
history+=`客户说:${item.content}`
}else {
history+=`销售说:${item.content}`
}
})
return history
},
//获取灵感建议 //获取灵感建议
getInspiration() { getInspiration() {
aiApi.inspiration({}).then(res=>{ const {step } = this.data
const history_message = this.getHistory()
aiApi.inspiration({history_message,step,inspiration:''}).then(res=>{
this.setData({ this.setData({
inspirationContent: '当然,我很高兴能为您提供帮助。我们的新款车型性能优越,安全性能出色,而且售后服务也非常完善。您可以放心购买,我们会为您提供最优质的购车体验。您有什么特别需求或偏好吗?' inspirationContent: res
}) })
}) })
}, },
//提供相应的建议 //提供相应的建议
getSparring(user_message) { getSparring(user_message) {
const {step} = this.data const {step,chatList} = this.data
let history_message console.log(chatList)
if(!user_message) { let history_message = this.getHistory()
history_message = WELCOME chatList.push({
}else { role: 1,
history_message = '5' content: '',
} })
this.setData({chatList})
aiApi.sparring({ aiApi.sparring({
user_message, user_message,
history_message, history_message,
step, step,
main_point: 4, main_point: "0",
defense_step: 4, defense_step: 0,
round: 0 round: 0
}).then(res => { }).then(res => {
const {chatList} = this.data; const {chatList} = this.data;
const len = chatList.length - 1
const {sale_message} = res const {sale_message} = res
chatList.push({ chatList[len].content = sale_message
role: 1, chatList[len].time = Math.floor(sale_message.length / 3)
content: sale_message,
time: Math.floor(sale_message.length / 3)
})
this.setData({chatList}) this.setData({chatList})
}) })
}, },
...@@ -207,7 +228,6 @@ Page({ ...@@ -207,7 +228,6 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
this.getSparring('')
}, },
/** /**
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</view> </view>
</view> </view>
<view class="chat-item" wx:for="{{chatList}}"> <view class="chat-item" wx:for="{{chatList}}">
<view class="chat-left" wx:if="{{item.role == 1}}"> <view class="chat-left" wx:if="{{item.role == 1 && item.content}}">
<gl-image class="avatar-icon" src="/aiCheck/setting-icon.png"></gl-image> <gl-image class="avatar-icon" src="/aiCheck/setting-icon.png"></gl-image>
<view class="chat-box"> <view class="chat-box">
<audio-tts audioInfo="{{item}}"></audio-tts> <audio-tts audioInfo="{{item}}"></audio-tts>
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<gl-image class="suggest-icon" src="/aiCheck/suggest-icon.png"></gl-image> <gl-image class="suggest-icon" src="/aiCheck/suggest-icon.png"></gl-image>
改进建议 改进建议
</view> </view>
<view class="text">销售时应该更多地关注客户的需求和偏好,建议在推荐产品时提供更多相关信息,以便客户做出更好的决定。另外,可以通过问一些问题来了解客户的具体需求。</view> <view class="text">{{item.suggestions_for_improvement}}</view>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view class="polish"> <view class="polish">
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
<gl-image class="suggest-icon" src="/aiCheck/polish-icon.png"></gl-image> <gl-image class="suggest-icon" src="/aiCheck/polish-icon.png"></gl-image>
润色表达 润色表达
</view> </view>
<view class="text">你好,欢迎来到我们店里!在为您推荐产品之前,我想了解一下您对新车的具体需求和偏好,比如您对车辆功能、价格范围、品牌偏好等方面有什么考虑吗?</view> <view class="text">{{item.refine_the_expression}}</view>
</view> </view>
</view> </view>
......
...@@ -31,13 +31,9 @@ class Request { ...@@ -31,13 +31,9 @@ class Request {
data = _this.getData(data, method, noSignAttr , domainName == 'merchants') data = _this.getData(data, method, noSignAttr , domainName == 'merchants')
url = `${domain[domainName]}${requestPath || path}?method=${method}`; url = `${domain[domainName]}${requestPath || path}?method=${method}`;
}else { }else {
const queryString = qs.stringify(data, { header = {
arrayFormat: 'indices', 'content-type': 'application/json'
allowDots: true, }
encodeValuesOnly: true
})
url = `${domain[domainName]}${requestPath || path}?${queryString}`
data = null
} }
// console.log('reqData',data?.sessionId); // console.log('reqData',data?.sessionId);
// delete // delete
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!