Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yma16
yma16_miniprogram
提交
8b18f523
Y
yma16_miniprogram
项目概览
yma16
/
yma16_miniprogram
通知
11
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yma16_miniprogram
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8b18f523
编写于
2月 11, 2023
作者:
yma16
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add openAi remove dataView
上级
cdd17045
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
198 addition
and
28 deletion
+198
-28
miniprogram/pages/future/future.js
miniprogram/pages/future/future.js
+116
-3
miniprogram/pages/future/future.wxml
miniprogram/pages/future/future.wxml
+37
-20
miniprogram/pages/future/future.wxss
miniprogram/pages/future/future.wxss
+45
-5
未找到文件。
miniprogram/pages/future/future.js
浏览文件 @
8b18f523
...
...
@@ -16,8 +16,19 @@ Component({
content
:
'
子组件的content
'
,
btnType
:
'
map
'
,
homeHeaderItem
:
''
,
isLoading
:
true
,
article
:
{
'
key
'
:
12
}
isLoading
:
false
,
article
:
{
'
key
'
:
12
},
searchOpenAiText
:
''
,
responseText
:
''
,
// questions,answer,index
chatObjConfig
:{
option
:[{
question
:
''
,
answer
:
''
,
isEdit
:
true
}],
currentIndex
:
0
}
},
observers
:
{
...
...
@@ -25,10 +36,17 @@ Component({
lifetimes
:
{
// 生命周期函数,可以为函数,或一个在 methods 段中定义的方法名
attached
:
function
()
{
this
.
initData
()
if
(
wx
.
getStorageSync
(
'
openAiOptions
'
)){
this
.
setData
(
{
chatObjConfig
:
wx
.
getStorageSync
(
'
openAiOptions
'
)
}
)
}
},
moved
:
function
()
{
},
detached
:
function
()
{
wx
.
setStorageSync
(
'
openAiOptions
'
,
this
.
data
.
chatObjConfig
)
},
},
...
...
@@ -46,6 +64,101 @@ Component({
},
methods
:
{
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
}
})
},
search
(
e
){
console
.
log
(
this
.
data
.
searchOpenAiText
)
if
(
!
this
.
data
.
searchOpenAiText
){
wx
.
showModal
({
cancelColor
:
'
cancelColor
'
,
title
:
'
请输入!
'
})
}
wx
.
showLoading
({
title
:
'
加载中
'
,
})
this
.
setData
({
isLoading
:
true
})
console
.
log
(
e
)
const
path
=
'
/common-api/searchOpenAiText/
'
const
headers
=
{
'
Content-Type
'
:
'
application/json;charset=UTF-8
'
}
const
params
=
{
"
text
"
:
this
.
data
.
searchOpenAiText
}
const
thisBack
=
this
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
request
({
url
:
baseUrl
+
path
,
headers
:
headers
,
data
:
params
,
method
:
'
GET
'
,
success
:
(
res
)
=>
{
console
.
log
(
res
,
'
res
'
)
const
data
=
res
.
data
.
data
const
option
=
thisBack
.
data
.
chatObjConfig
.
option
const
currentIndex
=
thisBack
.
data
.
chatObjConfig
.
currentIndex
const
choices
=
data
.
choices
console
.
log
(
'
choices
'
,
choices
)
option
.
some
((
item
,
index
)
=>
{
if
(
currentIndex
===
index
){
item
.
answer
=
choices
?
choices
.
map
(
choicesItem
=>
{
return
choicesItem
.
text
}).
join
(
'
\n
'
):
'
。。。未知
'
item
.
isEdit
=
false
return
true
}
return
false
})
const
chatObjConfig
=
{
option
:
option
,
currentIndex
:
currentIndex
+
1
}
option
.
push
({
question
:
''
,
answer
:
''
,
isEdit
:
true
})
thisBack
.
setData
(
{
isLoading
:
false
,
chatObjConfig
:
chatObjConfig
}
)
setTimeout
(
function
()
{
wx
.
hideLoading
()
},
2000
)
resolve
(
res
)
},
fail
:
error
=>
{
thisBack
.
setData
({
isLoading
:
false
})
setTimeout
(
function
()
{
wx
.
hideLoading
()
},
2000
)
reject
(
error
)
}
});
})
},
clickHeadBtn
(
e
){
console
.
log
(
e
)
const
{
btnType
}
=
e
.
currentTarget
.
dataset
...
...
miniprogram/pages/future/future.wxml
浏览文件 @
8b18f523
<!--pages/future/future.wxml-->
<!--pages/blog/blog.wxml-->
<view class="container-future">
<view class="header-container"
>
<
view >
<view class="flex-container">
<!-- <view class="header-container"> --
>
<
!-- <view >
<view class="flex-container">
<view class='title'>疫情</view>
<view class="header-btn" class="{{btnType==='map'? 'actived':'btn-default'}}" bindtap="clickHeadBtn" data-btn-type='map'>地图</view>
<view class="header-btn" class="{{btnType==='line'? 'actived':'btn-default'}}" bindtap="clickHeadBtn" data-btn-type='line'>折线图</view>
<view class="header-btn" class="{{btnType==='blockInfo'? 'actived':'btn-default'}}" bindtap="clickHeadBtn" data-btn-type='blockInfo'>分类信息</view>
</view>
<view>
</view>
</view> -->
<view class="form-container-api">
<view>
<button style="width: 100%;" type="primary" formType="submit">openai调用</button>
</view>
<view class="chat-container">
<view wx:for="{{ chatObjConfig.option }}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="form-request">
<view wx:if="{{item.isEdit}}">问:$ <input bindinput="bindKeyInput" placeholder="输入关键词" data-column-index="{{index}}" disabled="{{isLoading}}" /></view>
<view wx:else class='questioned'>
<view>
问:$ {{item.question}}
</view>
</view>
</view>
<view class="form-response">
<view class='questioned'>openai回答:$ {{item.answer}}</view>
</view>
</view>
<view class="loading" wx:if="{{isLoading}}">
<view class="loader-child"/>
<view class="loader-child"/>
<view class="loader-child"/>
</view>
<view class="content-container" wx:if="{{!isLoading}}">
<geoMap wx:if="{{btnType==='map'}}" ></geoMap>
</view>
</view>
<view class="form-submit">
<button style="width: 100%;" type="primary" bindtap="search" loading="{{isLoading}}" disabled="{{isLoading}}">发送</button>
</view>
</view>
<view class="loading" wx:if="{{isLoading}}">
<view class="loader-child" />
<view class="loader-child" />
<view class="loader-child" />
</view>
<view class="content-container" wx:if="{{!isLoading}}">
<!-- <geoMap wx:if="{{btnType==='map'}}" ></geoMap>
<lineChart wx:elif="{{btnType==='line'}}" bindtap="clickBottomBtn"></lineChart>
<blockInfo wx:else="{{btnType==='blockInfo'}}" bindtap="clickBottomBtn"></blockInfo>
</view>
<blockInfo wx:else="{{btnType==='blockInfo'}}" bindtap="clickBottomBtn"></blockInfo>
-->
</view>
</view>
\ No newline at end of file
miniprogram/pages/future/future.wxss
浏览文件 @
8b18f523
...
...
@@ -3,13 +3,12 @@
position: relative;
width: 100vw;
height:100vh;
background: linear-gradient(to right,
#fff 1px, transparent 1px), linear-gradient(to bottom, #fff
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;
overflow: hidden;
box-sizing: border-box;
}
.loading{
...
...
@@ -24,20 +23,20 @@
}
.container-box{
position: relative;
width: 100
vw
;
width: 100
%
;
height: 100vh;
overflow: auto;
}
.header-container{
position: absolute;
height:30px;
width: 100
vw
;
width: 100
%
;
}
.content-container{
margin-top:30px;
position: absolute;
height:100vh;
width: 100
vw
;
width: 100
%
;
overflow: auto;
}
.flex-container{
...
...
@@ -80,3 +79,44 @@ button{
text-align: center;
background-color: rgb(8, 183, 252);
}
.form-container-api{
display: block;
height:auto;
width: 100%;
}
.form-request{
display: block;
width: 100%;
color:#07c160;
background-color: rgb(37, 0, 97);
}
.form-response{
position: relative;
width: 100%;
margin-top: 10px;
display: block;
margin-bottom: 10px;
color:#07c160;
background-color: rgb(0, 72, 94);
}
.form-class-submit{
margin-top: 10px;
display: block;
width: 100%;
background-color: rgb(248, 70, 0);
}
.form-submit-btn{
width: 100%;
display: block;
}
.chat-container{
margin-top:20px;
width: 100%;
height: 336px;
overflow: auto;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录