diff --git a/miniprogram/pages/future/future.js b/miniprogram/pages/future/future.js index f6f01193514c397cbf0a9246b17d2969f58bbccc..ba2e12cce061f17ab95eebb85730ba2f4e93f4de 100644 --- a/miniprogram/pages/future/future.js +++ b/miniprogram/pages/future/future.js @@ -42,25 +42,30 @@ Component({ }, aiConfig: { avatarUrl: 'https://yongma16.xyz/staticFile/common/img/aiTop.jpg', - bgUrl: 'https://yongma16.xyz/staticFile/common/img/aiBg.jpg' + bgUrl: 'https://yongma16.xyz/staticFile/common/img/aiBg.jpg', + nickName: 'openai', }, searchOpenAiText: '', responseText: '', + reportText: '', // questions,answer,index chatObjConfig: { option: [{ question: '', answer: '', - isEdit: true + isEdit: true, + createTime: '' }], currentIndex: 0 }, - layoutConfig:{ - introduceText:'api介绍', - useText:'使用', - returnText:'返回介绍', - sendText:'发送', - searchText:'关键词查询' + layoutConfig: { + introduceText: 'api介绍', + useText: '使用', + returnText: '返回介绍', + sendText: '发送', + searchText: '关键词查询', + reportText: '复制数据', + copyText: '复制' } }, observers: { @@ -73,12 +78,12 @@ Component({ // 在当前同步流程结束后,下一个时间片执行 wx.nextTick(() => { wx.hideLoading({ - success: (res) => {}, + success: (res) => { }, }) - // 触发父组件事件 + // 触发父组件事件 this.triggerEvent('updateBottomNavigation', newVal === 'introduce') }) - + } }, lifetimes: { @@ -91,7 +96,7 @@ Component({ { chatObjConfig: openAiOptions, mode: app.wxProgramConfig.apiPageConfig.mode, - layoutConfig:app.wxProgramConfig.apiPageConfig.layoutConfig, + layoutConfig: app.wxProgramConfig.apiPageConfig.layoutConfig, } ) } @@ -142,11 +147,24 @@ Component({ }) }, scrollToBottom() { - const index=this.data.chatObjConfig.option.length-1 + const index = this.data.chatObjConfig.option.length - 1 this.setData({ - toView:`chat-mode${index}` + toView: `chat-mode${index}` }) }, + getCurrentTime() { + const now = new Date() + const year = now.getFullYear() + const month = now.getMonth() + const date = now.getDate() + const hour = now.getHours() + const minutes = now.getMinutes() + const second = now.getSeconds() + const formatNum = (n) => { + return n > 9 ? n.toString() : '0' + n + } + return `${year}-${formatNum(month + 1)}-${formatNum(date)} ${formatNum(hour)}:${formatNum(minutes)}:${formatNum(second)}` + }, getRemoteArticle: function (id) { this.setData({ isLoading: true @@ -193,27 +211,35 @@ Component({ }) }, bindKeyInput(e) { - const { columnIndex } = e.currentTarget.dataset - console.log('this.data.chatObjConfig', this.data.chatObjConfig) - const option = this.data.chatObjConfig.option - option.some((item, index) => { - if (columnIndex === index) { - item.question = e.detail.value - item.isEdit = true - return true - } - return false - }) this.setData({ - searchOpenAiText: e.detail.value, - chatObjConfig: { - option: option, - currentIndex: columnIndex - } + searchOpenAiText: e.detail.value }) }, + reportAnswerData() { + const data=this.data.chatObjConfig.option + wx.setClipboardData({ + data: JSON.stringify(data) + }) + console.log(wx.getClipboardData({ + success: (option) => { + console.log(option) + }, + })) + }, + + copyBtn(e) { + console.log('data', e) + const response = e.target.dataset.response + wx.setClipboardData({ + data: response + }) + console.log(wx.getClipboardData({ + success: (option) => { + console.log(option) + }, + })) + }, search(e) { - console.log(this.data.searchOpenAiText) this.scrollToBottom() if (!this.data.searchOpenAiText) { wx.showModal({ @@ -228,7 +254,6 @@ Component({ this.setData({ isLoading: true }) - console.log(e) const path = '/common-api/searchOpenAiText/' const headers = { 'Content-Type': 'application/json;charset=UTF-8' } const params = { @@ -252,26 +277,26 @@ Component({ option.some((item, index) => { if (currentIndex === index) { item.answer = answer + item.question = params.text + item.createTime = this.getCurrentTime() item.isEdit = false return true } return false }) - thisBack.createOpenRecord({ - wx_name: thisBack.data.currentUserInfo.nickName, - wx_img: thisBack.data.currentUserInfo.avatarUrl, - search_text: params.text, - search_response: answer - }) + // // 只保留30 条 缓存 + // if(option.length&&option.length>30){ + // option.shift() + // } const chatObjConfig = { option: option, currentIndex: currentIndex + 1 } - option.push({ - question: '', - answer: '', - isEdit: true - }) + // option.push({ + // question: '', + // answer: '', + // isEdit: true + // }) thisBack.setData( { isLoading: false, @@ -282,6 +307,14 @@ Component({ wx.hideLoading() thisBack.scrollToBottom() resolve(res) + setTimeout(() => { + thisBack.createOpenRecord({ + wx_name: thisBack.data.currentUserInfo.nickName, + wx_img: thisBack.data.currentUserInfo.avatarUrl, + search_text: params.text, + search_response: answer + }) + }, 10) }, fail: error => { thisBack.setData({ diff --git a/miniprogram/pages/future/future.wxml b/miniprogram/pages/future/future.wxml index 2303cb9aa7702cce72d05e56e73f0b65815753e9..4dbe750bb13c886d673221d1ebb757b05597c29f 100644 --- a/miniprogram/pages/future/future.wxml +++ b/miniprogram/pages/future/future.wxml @@ -1,17 +1,10 @@ - - - + - + @@ -27,45 +20,71 @@ - - + + + + + + - + + + {{item.createTime}} + - - - ({{currentUserInfo.nickName}}):$ - - - - - ({{currentUserInfo.nickName}}):$ {{item.question}} + + + + + {{item.question}} + + + + + + + + + + - - - - (openai):$ {{item.answer}} - - + + + + + + + + + + + + + {{item.answer}} + + + + + + + + + + - - + + + - - - - \ No newline at end of file diff --git a/miniprogram/pages/future/future.wxss b/miniprogram/pages/future/future.wxss index 3c41b035f4ad4bec6ffbc95bff82bba27e0933e6..4547a85c6ed0baaa05d0fa831c838f715200253e 100644 --- a/miniprogram/pages/future/future.wxss +++ b/miniprogram/pages/future/future.wxss @@ -3,13 +3,12 @@ position: relative; width: 100vw; height: 100vh; - /* background: linear-gradient(to right, rgba(1, 41, 116, 0.1) 1px, transparent 1px), linear-gradient(to bottom, rgba(1, 41, 116, 0.1) 1px, transparent 1px); + background: linear-gradient(to right, rgba(1, 41, 116, 0.1) 1px, transparent 1px), linear-gradient(to bottom, rgba(1, 41, 116, 0.1) 1px, transparent 1px); background-repeat: repeat; background-size: 10px 10px; - border: 1px solid #01c4ff; */ - background-image: url('https://yongma16.xyz/staticFile/common/img/aiBg.jpg'); - background-repeat: no-repeat; - background-size: cover; + /* background-image: url('https://yongma16.xyz/media/editor/wallhaven-we1xx7_20230331165330942057.jpg'); */ + /* background-repeat: no-repeat; + background-size: cover; */ overflow: hidden; box-sizing: border-box; } @@ -78,6 +77,8 @@ button { font-weight: normal; } + + .btn-default { color: #262626; flex: 1; @@ -103,8 +104,8 @@ button { .form-request { display: block; width: 100%; - color: #07c160; - background-color: rgba(37, 0, 97,.9); + color: #fff; + background-color: rgba(37, 0, 97,0); line-height: 50px; } @@ -114,12 +115,22 @@ button { margin-top: 10px; display: block; margin-bottom: 10px; - color: #07c160; - background-color: rgba(0, 72, 94,.9); + color: #fff; + background-color: rgba(0, 72, 94,0); box-sizing: border-box; min-height: 60px; } +.form-response-user{ + background-color: rgba(0, 72, 94,0); + color:#fff; +} + +.form-request-user{ + background-color: rgba(37, 0, 97,0); + color:#fff; +} + .form-class-submit { margin-top: 10px; display: block; @@ -140,10 +151,9 @@ button { overflow: auto; } .scroll-answer{ - height: calc(100vh - 90px); + height: calc(100vh - 140px); } .chat-container { - margin-top: 10px; width: 100%; height: calc(100vh - 40px); overflow-y: auto; @@ -172,6 +182,62 @@ button { border-radius: 50%; } +.questioned-box-container{ + display: flex; +} +.questioned-box{ + position: relative; + max-width: calc(100vw - 90px); + height: auto; + overflow-x: auto; + background-color:rgb(0, 114, 221); + border-radius: 10px; + right: -5px; + padding:0 10px; + z-index: 999; +} +.questioned-box-poly{ + position: relative; + top:15px; + width: 0; + height: 0; + border-radius: 5px; + border-top: 10px solid transparent; + border-bottom: 10px solid transparent; + border-left: 12px solid rgb(0, 114, 221); +} + +.send-btn{ + height: 60px;background: rgba(255,255,255,.8); + color:rgb(0, 114, 221); + padding-left: 10px; +} + +.form-response-box{ + position: relative; + max-width: calc(100vw - 90px); + word-break:keep-all; + height: auto; + overflow-x: auto; + background-color: rgb(0, 114, 221); + border-radius: 10px; + left: -5px; + padding:0 10px; + box-sizing: content-box; + z-index: 999; +} + +.form-response-box-poly{ + position: relative; + top:15px; + width: 0; + height: 0; + border-radius: 5px; + border-top: 10px solid transparent; + border-bottom: 10px solid transparent; + border-right: 12px solid rgb(0, 114, 221); +} + /* .loader-child:nth-of-type(1) { border-bottom: 3px solid #ffffff; }