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

fix: aibot

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