讨论数量:
体验后,移除了,聊一次天给我弹一次弹窗广告,真优秀
各位看看代码就知道,点击发送触发的是 showAds
,在广告显示或者显示失败的时候就已经把ChatGPT的请求发过去了,你就算不看广告,也不会中断,因为ChatGPT的请求时间长,加上了广告打发时间而已,有可能你的广告看完了,你的请求还没有回来
@anchonghuang
// 发送信息
send() {
let that = this
if (!this.content) {
uni.showToast({
title: '请输入有效的内容',
icon: 'none'
})
return;
}
// 将当前发送信息 添加到消息列表。
let data = {
"id": ++this.contentId,
"content": this.content,
"type": 1,
"pic": "/static/people.png"
}
this.talkList.push(data);
data = {
"id": ++this.contentId,
"content": "正在与ChatGPT沟通...",
"type": 0,
"pic": "/static/chat_gpt.png"
}
this.talkList.push(data);
this.$u.api.postChatGPTCompletions({
contentId: this.contentId,
content: this.content
}).then(res => {
that.talkList[that.talkList.length - 1]['content'] = res.data.result
})
this.$nextTick(() => {
// 清空内容框中的内容
this.content = '';
uni.pageScrollTo({
scrollTop: 999999, // 设置一个超大值,以保证滚动条滚动到底部
duration: 0
});
})
},
showAds() {
let that = this
if (videoAd) {
videoAd.show().then(() => {
that.send()
}).catch(() => {
// 失败重试
videoAd.load()
.then(() => videoAd.show())
.catch(err => {
that.send()
})
})
}
},
推荐文章: