提交 fe15b014 编写于 作者: yma16's avatar yma16

fix: aibot

上级 33851d29
......@@ -4,6 +4,10 @@ App({
homePageArticleId: 32,
lifePageArricleId: 35,
wxProgramConfig: {
"aiBotConfig":{
"saveKey":"aiBot",
"searchOpenAiText":"画一只猫",
},
authorPageConfig: {
cloudEmail: "1575057249@qq.com",
cloudPwd: "U2FsdGVkX1+jfEkF2OXTQ5iIG4mrYc5/TLOiIntyENU=",
......@@ -12,12 +16,16 @@ App({
loginTitle: '点击授权',
detailInfo: '关于:code笔记',
nextPage: "/pages/home/home",
basePage: "/pages/home/home",
userPrefix: '昵称:',
userName: '月牙天冲',
designPlaceholder: '自定义名称',
joinTitle: '微信登录',
shopBtnTitle: '虚拟资产',
isOldVersion: false
isOldVersion: false,
"isShowBottom": true,
"isShowBot":true,
"isShowShop":true,
},
homePageConfig: {
headBackground: [
......@@ -171,6 +179,8 @@ App({
})
if (res.data.data && res.data.data[0].option) {
that.wxProgramConfig = JSON.parse(res.data.data[0].option)
console.log('that.wxProgramConfig',that.wxProgramConfig)
that.basePage=that.wxProgramConfig.authorPageConfig.basePage||that.basePage
wx.navigateTo({
url: that.basePage,
success: function (res) {
......
......@@ -13,8 +13,8 @@ Page({
},
saveKey: 'aiBot',
baseCloudUrl: app.remoteConfig.baseCloudUrl,
password: app.remoteConfig.cloudPwd || "U2FsdGVkX1+jfEkF2OXTQ5iIG4mrYc5/TLOiIntyENU=",
username: app.remoteConfig.cloudEmail || "1575057249@qq.com",
password: "U2FsdGVkX1+jfEkF2OXTQ5iIG4mrYc5/TLOiIntyENU=",
username: "1575057249@qq.com",
token: '',
currenTime: '',
isLoading: false,
......@@ -44,7 +44,7 @@ Page({
pasteText: '粘贴',
upText: "",
downText: "",
errorMsg: 'openai的服务器异常!',
errorMsg: 'bot ai服务器异常!',
emptyText: '欢迎使用aibot',
storageKey: 'openAiOptionsConfig',
permissionTitle: '很抱歉您没有权限!',
......@@ -112,6 +112,13 @@ Page({
search(e) {
this.scrollToBottom()
if(this.data.isLoading){
wx.showModal({
cancelColor: 'cancelColor',
title: '正在响应中,请稍等...'
})
return
}
if (!this.data.searchOpenAiText) {
wx.showModal({
cancelColor: 'cancelColor',
......@@ -143,8 +150,8 @@ Page({
const data = res.data.data
const option = that.data.chatObjConfig.option
console.log('data', data)
const choices = data.messages[2]
const answer = choices?.content
const choices = data.messages?.[2]
const answer = choices?.content || that.data.layoutConfig.errorMsg
option.push({
question: that.data.searchOpenAiText,
answer: answer,
......@@ -181,6 +188,16 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const aiBotConfig = app.wxProgramConfig.aiBotConfig
console.log('aiBotConfig', aiBotConfig)
this.setData({
saveKey: aiBotConfig.saveKey,
searchOpenAiText: aiBotConfig.searchOpenAiText,
password: aiBotConfig.cloudPwd || "U2FsdGVkX1+jfEkF2OXTQ5iIG4mrYc5/TLOiIntyENU=",
username: aiBotConfig.cloudEmail || "1575057249@qq.com",
})
this.getUserToken()
this.setData({
currenTime: this.getCurrentTime()
......@@ -233,7 +250,7 @@ Page({
// 缓存
if (this.data.openAiOptionsConfig) {
wx.setStorageSync(this.data.saveKey, this.data.openAiOptionsConfig)
wx.setStorageSync(app.wxProgramConfig.aiBotConfig.saveKey, this.data.openAiOptionsConfig)
}
},
......
......@@ -77,7 +77,7 @@
<view class='submit-input'>
<textarea class='send-input' bindinput="bindKeyInput" placeholder="{{layoutConfig.searchText}}" bindconfirm="search" value="{{searchOpenAiText}}" disabled="{{isLoading||isTruth}}" />
</view>
<view class='send-btn' type="primary" bindtap="search" loading="{{isLoading}}">{{layoutConfig.sendText}}</view>
<view class='send-btn' type="primary" bindtap="search" loading="{{isLoading}}" disabled="{{isLoading}}">{{layoutConfig.sendText}}</view>
</view>
</view>
......
......@@ -3,6 +3,8 @@
const app = getApp()
Page({
data: {
isShowBot: true,
isShowShop: true,
baseUrl: app.remoteConfig.baseUrl,
baseCloudUrl: app.remoteConfig.baseCloudUrl,
baseLoginCloudPath: 'userModel/register',
......@@ -262,6 +264,8 @@ Page({
joinTitle: authorPageConfig.joinTitle,
shopBtnTitle: authorPageConfig.shopBtnTitle,
isShowBottom: authorPageConfig.isShowBottom,
isShowBot: authorPageConfig.isShowBot,
isShowShop: authorPageConfig.isShowShop,
loginErrorTitle: authorPageConfig.loginErrorTitle,
loginErrorContent: authorPageConfig.loginErrorContent
})
......
......@@ -36,15 +36,13 @@
<button type="primary" plain="true" bindtap="getUserProfile" class="user-login" bindgetuserinfo="getUserInfoBtn" wx:if="{{isOldVersion}}">{{loginTitle}}</button>
<button type="primary" plain="true" bindtap="getUserProfile" bindtap="joinProfile" class="user-login" wx:else>{{joinTitle}}</button>
<button type="primary" plain="true"
bindtap="clickBotBtn" class="bot-btn" >{{botBtnTitle}}</button>
<button type="primary" plain="true" bindtap="clickBotBtn" class="bot-btn" wx:if="{{isShowBot}}">{{botBtnTitle}}</button>
<button type="primary" plain="true"
bindtap="clickShopBtn" class="shop-btn" >{{shopBtnTitle}}</button>
<button type="primary" plain="true" bindtap="clickShopBtn" class="shop-btn" wx:if="{{isShowShop}}">{{shopBtnTitle}}</button>
</view>
</view>
<view class="loading-container">
<view class="loading" wx:if="isloading">
<view class="loading" wx:if="{{isloading}}">
<view class="loader-child" />
<view class="loader-child" />
<view class="loader-child" />
......
......@@ -39,7 +39,7 @@ page {
}
.shop-btn{
margin-top: 160px;
margin-top: 80px;
width:120px !important;
color: #fff !important;
border-color: #fff !important;
......@@ -47,7 +47,7 @@ page {
.bot-btn{
margin-top: 120px;
margin-top: 60px;
width:120px !important;
color: #fff !important;
border-color: #fff !important;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册