小助理
This commit is contained in:
97
src/project/baidu/AppDialogue/AppDialogue.vue
Normal file
97
src/project/baidu/AppDialogue/AppDialogue.vue
Normal file
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<div class="AppDialogue">
|
||||
<div class="footer-tab">
|
||||
<div class="item" v-for="(item, index) in tabList" :key="index" @click="tabClick(index)">
|
||||
<img :src="tabIndex == index ? item.selectIcon : item.icon" alt="">
|
||||
<p :class="tabIndex == index ? 'active' : ''">{{item.text}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<Talk v-if="!tabIndex && !showDetail" />
|
||||
<Record v-if="tabIndex && !showDetail" @toDetail="toDetail" />
|
||||
<Detail v-if="showDetail" :params="params" @back="back" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from "vuex";
|
||||
import Talk from './Talk'
|
||||
import Record from './Record'
|
||||
import Detail from './Detail'
|
||||
export default {
|
||||
name: "AppDialogue",
|
||||
appName: "Copilot小助理",
|
||||
data() {
|
||||
return {
|
||||
tabList: [
|
||||
{
|
||||
icon: require('./img/talk.png'),
|
||||
selectIcon: require('./img/talk_selected.png'),
|
||||
text: '对话',
|
||||
},
|
||||
{
|
||||
icon: require('./img/record.png'),
|
||||
selectIcon: require('./img/record_selected.png'),
|
||||
text: '记录'
|
||||
}
|
||||
],
|
||||
tabIndex: 0,
|
||||
showDetail: false
|
||||
};
|
||||
},
|
||||
components: {Talk, Record, Detail},
|
||||
computed: {
|
||||
...mapState(["user"]),
|
||||
},
|
||||
onLoad() {
|
||||
},
|
||||
onShow() {
|
||||
document.title = "Copilot小助理"
|
||||
},
|
||||
methods: {
|
||||
tabClick(index) {
|
||||
this.tabIndex = index
|
||||
},
|
||||
toDetail(e) {
|
||||
this.params = e
|
||||
this.showDetail = true
|
||||
},
|
||||
back() {
|
||||
this.showDetail = false
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.AppDialogue {
|
||||
.footer-tab {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
padding-bottom: 68px;
|
||||
background: #fff;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 9;
|
||||
display: flex;
|
||||
.item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
img {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin: 12px 0 8px 0;
|
||||
}
|
||||
p {
|
||||
font-family: PingFangSC-Regular;
|
||||
font-weight: 400;
|
||||
font-size: 20px;
|
||||
color: #8A929F;
|
||||
}
|
||||
.active {
|
||||
color: #026AF2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
285
src/project/baidu/AppDialogue/Detail.vue
Normal file
285
src/project/baidu/AppDialogue/Detail.vue
Normal file
@@ -0,0 +1,285 @@
|
||||
<template>
|
||||
<div class="Detail">
|
||||
<AiTopFixed>
|
||||
<div class="back">
|
||||
<div class="top-select" @click="back">
|
||||
<u-icon name="arrow-left" color="#fff" size="28"></u-icon>返回
|
||||
</div>
|
||||
<p>模型应用:文本助理</p>
|
||||
</div>
|
||||
<div class="search-content">
|
||||
<u-search v-model="searchVal" :clearabled="true" placeholder="请输入搜索关键词…" :show-action="false"
|
||||
bg-color="#fff" search-icon-color="#666" color="#666" height="72" @search="getSearchList" @clear="handerClear">
|
||||
</u-search>
|
||||
</div>
|
||||
</AiTopFixed>
|
||||
<div class="list-content">
|
||||
<div v-for="(item, index) in messageList" :key="index">
|
||||
<div class="send-time">{{item.createTime.substring(5, 16)}}</div>
|
||||
<div :class="item.userType == 1 ? 'item-left' : 'item-right'">
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/baiduAI/user-img.png" alt="" class="user-img" v-if="item.userType == 1">
|
||||
<div class="item" :class="'item'+index">
|
||||
<u-icon name="play-right-fill" color="#CCE2FF" size="20" v-if="item.userType != 1" class="u-icon-right"></u-icon>
|
||||
<u-icon name="play-left-fill" color="#F3F5F7" size="20" v-if="item.userType == 1" class="u-icon-left"></u-icon>
|
||||
<div class="voice-div" v-if="item.sdkFileUrl" @click="play(item.sdkFileUrl, index)">
|
||||
<span>8”</span>
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/baiduAI/play-d.gif" alt="" v-if="item.isPlay">
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/baiduAI/play-j.png" alt="" v-else>
|
||||
</div>
|
||||
<p v-if="!item.sdkFileUrl">{{item.content || ''}}</p>
|
||||
</div>
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/baiduAI/user-img.png" alt="" class="user-img" v-if="item.userType != 1">
|
||||
</div>
|
||||
</div>
|
||||
<AiEmpty v-if="!messageList.length"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {mapState} from "vuex";
|
||||
export default {
|
||||
name: 'Detail',
|
||||
props: ['params'],
|
||||
data() {
|
||||
return {
|
||||
backgroundNavbar: {
|
||||
background: 'url(https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/header-bg.jpeg) no-repeat',
|
||||
backgroundSize: 'cover',
|
||||
},
|
||||
searchVal: '',
|
||||
messageList: [
|
||||
// {
|
||||
// userType: 0,
|
||||
// sdkFileUrl: 'http://test87ftp.cunwuyun.cn/20240104/output.mp3',
|
||||
// isPlay: false
|
||||
// }
|
||||
],
|
||||
current: 1,
|
||||
pages: 2,
|
||||
aiConfigId: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['user']),
|
||||
},
|
||||
mounted() {
|
||||
this.getHistoryList()
|
||||
},
|
||||
onShow() {
|
||||
document.title = 'Copilot小助理'
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if(this.current > this.pages) {
|
||||
return this.$u.toast('没有更多记录')
|
||||
}
|
||||
this.current = this.current + 1
|
||||
this.getHistoryList()
|
||||
},
|
||||
methods: {
|
||||
getHistoryList() {
|
||||
if(!this.user.token) {
|
||||
return this.$u.toast("请先进行登录")
|
||||
}
|
||||
this.$loading()
|
||||
this.$http.post(`/app/appaicopilotinfo/list?current=${this.current}&size=10&content=${this.searchVal}&aiConfigId=${this.params.aiConfigId}`).then(res => {
|
||||
if(res.code == 0 && res.data.records.length) {
|
||||
res.data.records.map((item) => {
|
||||
if(item.sdkFileUrl) {
|
||||
item.isPlay = false
|
||||
}
|
||||
})
|
||||
this.messageList = this.current == 1 ? res.data.records : [...res.data.records, ...this.messageList]
|
||||
var idPage = res.data.records.length-1
|
||||
this.$nextTick(() => {
|
||||
uni.pageScrollTo({
|
||||
duration: 300,
|
||||
selector: this.current == 1 ? `.item${this.messageList.length-1}` : `.item${idPage}`
|
||||
});
|
||||
})
|
||||
this.pages = res.data.pages
|
||||
this.$hideLoading()
|
||||
}else {
|
||||
if(this.current == 1) {
|
||||
this.messageList = []
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
getSearchList() {
|
||||
this.current = 1
|
||||
this.getHistoryList()
|
||||
},
|
||||
handerClear() {
|
||||
this.searchVal = ''
|
||||
this.getSearchList()
|
||||
},
|
||||
play(src, index) {
|
||||
innerAudioContext.stop();
|
||||
if(this.messageList[index].isPlay) {
|
||||
innerAudioContext.onStop(() => {
|
||||
this.messageList[index].isPlay = false
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.messageList.map((item) => {
|
||||
if(item.sdkFileUrl) {
|
||||
item.isPlay = false
|
||||
}
|
||||
})
|
||||
this.messageList[index].isPlay = true
|
||||
innerAudioContext.src = src;
|
||||
|
||||
this.$nextTick(() => {
|
||||
innerAudioContext.play();
|
||||
})
|
||||
innerAudioContext.onEnded(() => {
|
||||
this.messageList[index].isPlay = false
|
||||
})
|
||||
},
|
||||
playStop(index) {
|
||||
innerAudioContext.stop();
|
||||
innerAudioContext.onStop(() => {
|
||||
this.messageList[index].isPlay = false
|
||||
})
|
||||
},
|
||||
back() {
|
||||
this.$emit('back')
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
page {
|
||||
height: 100%;
|
||||
}
|
||||
.Detail {
|
||||
height: 100vh;
|
||||
background-color: #fff;
|
||||
position: relative;
|
||||
.back {
|
||||
position: relative;
|
||||
padding-top: 28px;
|
||||
.top-select {
|
||||
line-height: 64px;
|
||||
background: #026AF2;
|
||||
border-radius: 32px;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 28px;
|
||||
text-align: center;
|
||||
padding: 0 24px;
|
||||
font-family: PingFangSC-Medium;
|
||||
font-weight: 500;
|
||||
font-size: 28px;
|
||||
color: #FFF;
|
||||
z-index: 9;
|
||||
::v-deep .u-icon {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
p {
|
||||
text-align: center;
|
||||
font-family: PingFangSC-Regular;
|
||||
font-size: 24px;
|
||||
color: #708099;
|
||||
line-height: 64px;
|
||||
}
|
||||
}
|
||||
.search-content {
|
||||
padding: 32px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
::v-deep .u-search {
|
||||
box-shadow: 0 0 8px 0 #00000005;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.list-content {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
padding: 144px 32px 364px;
|
||||
.send-time {
|
||||
display: block;
|
||||
width: 100%;
|
||||
line-height: 28px;
|
||||
font-family: PingFangSC-Regular;
|
||||
font-weight: 400;
|
||||
font-size: 20px;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
.user-img {
|
||||
display: inline-block;
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.item {
|
||||
display: inline-block;
|
||||
max-width: 440px;
|
||||
border-radius: 8px;
|
||||
padding: 18px;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 28px;
|
||||
position: relative;
|
||||
.voice-div {
|
||||
img {
|
||||
width: 26px;
|
||||
height: 28px;
|
||||
}
|
||||
span {
|
||||
display: inline-block;
|
||||
color: #333;
|
||||
font-size: 28px;
|
||||
font-family: PingFangSC;
|
||||
line-height: 28px;
|
||||
margin-right: 68px;
|
||||
}
|
||||
}
|
||||
p {
|
||||
word-break: break-all;
|
||||
line-height: 40px;
|
||||
font-family: SourceHanSansCN-Regular;
|
||||
font-size: 32px;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
.item-right {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
.item {
|
||||
background-color: #CCE2FF;
|
||||
}
|
||||
.user-img {
|
||||
margin-left: 24px;
|
||||
}
|
||||
.u-icon-right {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: -12px;
|
||||
}
|
||||
}
|
||||
.item-left {
|
||||
.item {
|
||||
background-color: #F3F5F7;
|
||||
}
|
||||
.user-img {
|
||||
margin-right: 24px;
|
||||
}
|
||||
.u-icon-left {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
left: -12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
187
src/project/baidu/AppDialogue/Record.vue
Normal file
187
src/project/baidu/AppDialogue/Record.vue
Normal file
@@ -0,0 +1,187 @@
|
||||
<template>
|
||||
<div class="Record">
|
||||
<div class="search-content">
|
||||
<u-search v-model="searchVal" :clearabled="true" placeholder="请输入搜索关键词…" :show-action="false"
|
||||
bg-color="#F4F6FA" search-icon-color="#666" color="#666" height="72" @search="getSearchList" @clear="handerClear">
|
||||
</u-search>
|
||||
</div>
|
||||
<div class="list-content">
|
||||
<div class="item" v-for="(item, index) in messageList" :key="index">
|
||||
<p class="item-text">{{item.content}}</p>
|
||||
<div class="time-flex">
|
||||
<p class="time-text">{{item.createTime}}</p>
|
||||
<div class="item-view">
|
||||
<p @click="toDetail(item)">查看对话</p>
|
||||
<div class="del-btn" @click="del(item)">
|
||||
<img src="./img/del-img.png" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<AiEmpty v-if="!messageList.length"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {mapState} from "vuex";
|
||||
export default {
|
||||
customNavigation: true,
|
||||
enablePullDownRefresh: true,
|
||||
name: 'AppRecord',
|
||||
appName: 'Copilot小助理(记录)',
|
||||
data() {
|
||||
return {
|
||||
backgroundNavbar: {
|
||||
background: 'url(https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/header-bg.jpeg) no-repeat',
|
||||
backgroundSize: 'cover',
|
||||
},
|
||||
searchVal: '',
|
||||
messageList: [
|
||||
// {
|
||||
// userType: 0,
|
||||
// sdkFileUrl: 'http://test87ftp.cunwuyun.cn/20240104/output.mp3',
|
||||
// isPlay: false
|
||||
// }
|
||||
],
|
||||
current: 1,
|
||||
pages: 2,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['user', 'token']),
|
||||
},
|
||||
mounted() {
|
||||
this.getHistoryList()
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if(this.current > this.pages) {
|
||||
return this.$u.toast('没有更多记录')
|
||||
}
|
||||
this.current = this.current + 1
|
||||
this.getHistoryList()
|
||||
},
|
||||
methods: {
|
||||
getHistoryList() {
|
||||
if(!this.user.token) {
|
||||
return this.$u.toast("请先进行登录")
|
||||
}
|
||||
this.$loading()
|
||||
this.$http.post(`/app/appaicopilotinfo/listHistory?current=${this.current}&size=10&content=${this.searchVal}`).then(res => {
|
||||
if(res.code == 0 && res.data.records.length) {
|
||||
res.data.records.map((item) => {
|
||||
if(item.sdkFileUrl) {
|
||||
item.isPlay = false
|
||||
}
|
||||
})
|
||||
this.messageList = this.current == 1 ? res.data.records : [...res.data.records, ...this.messageList]
|
||||
var idPage = res.data.records.length-1
|
||||
this.$nextTick(() => {
|
||||
uni.pageScrollTo({
|
||||
duration: 300,
|
||||
selector: this.current == 1 ? `.item${this.messageList.length-1}` : `.item${idPage}`
|
||||
});
|
||||
})
|
||||
this.pages = res.data.pages
|
||||
this.$hideLoading()
|
||||
}else {
|
||||
if(this.current == 1) {
|
||||
this.messageList = []
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
getSearchList() {
|
||||
this.current = 1
|
||||
this.getHistoryList()
|
||||
},
|
||||
handerClear() {
|
||||
this.searchVal = ''
|
||||
this.getSearchList()
|
||||
},
|
||||
toDetail(e) {
|
||||
// uni.navigateTo({url: `./Detail?aiConfigId=${e.aiConfigId}`})
|
||||
this.$emit('toDetail', {aiConfigId: e.aiConfigId})
|
||||
},
|
||||
del(e) {
|
||||
this.$confirm('确定删除该数据?').then(() => {
|
||||
uni.showLoading()
|
||||
this.$http.post(`appaicopilotinfo/deleteConversation?conversationId=${e.conversationId}`).then((res) => {
|
||||
if (res.code == 0) {
|
||||
this.$u.toast('删除成功!')
|
||||
this.getSearchList()
|
||||
}
|
||||
uni.hideLoading()
|
||||
})
|
||||
}).catch(() => {
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
page {
|
||||
height: 100%;
|
||||
}
|
||||
.Record {
|
||||
height: 100vh;
|
||||
background-color: #fff;
|
||||
position: relative;
|
||||
.search-content {
|
||||
padding: 32px;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
box-sizing: border-box;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
z-index: 99;
|
||||
}
|
||||
.list-content {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
padding: 144px 32px 364px;
|
||||
.item {
|
||||
.item-text {
|
||||
line-height: 40px;
|
||||
font-family: PingFangSC-Regular;
|
||||
font-size: 28px;
|
||||
color: #333;
|
||||
padding: 18px;
|
||||
background-color: #CCE2FF;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.time-flex {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
line-height: 40px;
|
||||
font-family: PingFangSC-Regular;
|
||||
font-size: 24px;
|
||||
.time-text {
|
||||
color: #999;
|
||||
padding-top: 34px;
|
||||
}
|
||||
.item-view {
|
||||
p {
|
||||
display: inline-block;
|
||||
font-size: 28px;
|
||||
color: #216AFD;
|
||||
}
|
||||
div {
|
||||
display: inline-block;
|
||||
padding: 34px 0 34px 38px;
|
||||
img {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
644
src/project/baidu/AppDialogue/Talk.vue
Normal file
644
src/project/baidu/AppDialogue/Talk.vue
Normal file
@@ -0,0 +1,644 @@
|
||||
<template>
|
||||
<div class="Talk">
|
||||
<!-- <u-navbar title="Copilot小助理" title-color="#000" title-width="300" title-size="32" :title-bold="true" :background="backgroundNavbar" :is-back="false" height="88"></u-navbar> -->
|
||||
<!-- <scroll-view scroll-y="true" class="scroll-Y" @scroll="scroll"> -->
|
||||
<div class="top-select" @click="showType=true">
|
||||
{{aiConfigName || '选择应用'}} <u-icon name="arrow-down" color="#fff" size="28"></u-icon>
|
||||
</div>
|
||||
<div class="service-content" v-if="!messageList.length">
|
||||
<div class="text-content">
|
||||
<div class="text-left">
|
||||
<div>嘿,你好呀!</div>
|
||||
<p>我是您的<span>「Copilot小助理」</span>,</p>
|
||||
<p>有什么问题都可以问我哟~</p>
|
||||
</div>
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/service.png" alt="" class="service-img">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="list-bg" v-if="messageList.length"></div> -->
|
||||
<div class="list-content" v-if="messageList.length">
|
||||
<div v-for="(item, index) in messageList" :key="index">
|
||||
<div class="send-time">{{item.createTime.substring(5, 16)}}</div>
|
||||
<div :class="item.userType == 1 ? 'item-left' : 'item-right'">
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/baiduAI/user-img.png" alt="" class="user-img" v-if="item.userType == 1">
|
||||
<div class="item" :class="'item'+index">
|
||||
<u-icon name="play-right-fill" color="#CCE2FF" size="20" v-if="item.userType != 1" class="u-icon-right"></u-icon>
|
||||
<u-icon name="play-left-fill" color="#F3F5F7" size="20" v-if="item.userType == 1" class="u-icon-left"></u-icon>
|
||||
<div class="voice-div" v-if="item.sdkFileUrl" @click="play(item.sdkFileUrl, index)">
|
||||
<span>8”</span>
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/baiduAI/play-d.gif" alt="" v-if="item.isPlay">
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/baiduAI/play-j.png" alt="" v-else>
|
||||
</div>
|
||||
<p v-if="!item.sdkFileUrl">{{item.content || ''}}</p>
|
||||
</div>
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/baiduAI/user-img.png" alt="" class="user-img" v-if="item.userType != 1">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </scroll-view> -->
|
||||
<div class="fixed-bottom">
|
||||
<div class="type-text" v-if="type == 'text'">
|
||||
<u-input type="text" placeholder="输入您的问题…" height="80" input-align="left" :clearable="false" placeholder-style="color:#666;" v-model="content" @confirm="sendMsg" :adjust-position="false"></u-input>
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/send.png" alt="" v-if="content.length" @click="sendMsg">
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/microphone-btn.png" alt="" v-else @click="microPhone">
|
||||
</div>
|
||||
<div class="type-record" v-else>
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/keyboard-btn.png" alt="" class="keyboard-btn" @click="keyboardClick">
|
||||
<div v-if="!isStart" @click="startRecord">
|
||||
<p>点击开始录音</p>
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/record-btn.png" alt="" class="record-btn">
|
||||
</div>
|
||||
<div v-else @click="endRecord">
|
||||
<p>正在录音中</p>
|
||||
<div class="tips-text">点击下方,停止录音</div>
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/shengbo.gif" alt="" class="recording">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<u-select v-model="showType" :list="typeList" value-name="dictValue"
|
||||
label-name="dictName" @confirm="confirmType"></u-select>
|
||||
<!-- <u-popup v-model="showPopup" mode="bottom">
|
||||
<div class="popup-content">
|
||||
<div class="pop-header">
|
||||
<img src="https://cdn.cunwuyun.cn/wechat/baiduAI/question-icon.png" alt=""> 慧知会言
|
||||
</div>
|
||||
<p class="pop-title">申请获取你当前的位置信息</p>
|
||||
<div class="pop-text">
|
||||
<p>微信位置信息</p>
|
||||
<u-icon name="checkbox-mark" color="#2EC871" size="36"></u-icon>
|
||||
</div>
|
||||
<div class="pop-btn">
|
||||
<div>拒绝</div>
|
||||
<div class="pop-confirm">接受</div>
|
||||
</div>
|
||||
</div>
|
||||
</u-popup> -->
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
import {mapActions, mapState} from "vuex";
|
||||
const recorderManager = uni.getRecorderManager();
|
||||
const innerAudioContext = uni.createInnerAudioContext();
|
||||
innerAudioContext.autoplay = true;
|
||||
export default {
|
||||
// customNavigation: true,
|
||||
// enablePullDownRefresh: true,
|
||||
name: 'Talk',
|
||||
data() {
|
||||
return {
|
||||
backgroundNavbar: {
|
||||
background: 'url(https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/header-bg.jpeg) no-repeat',
|
||||
backgroundSize: 'cover',
|
||||
},
|
||||
recorderManager: null,
|
||||
type: 'text',
|
||||
isStart: false,
|
||||
content: '',
|
||||
isFlag: false,
|
||||
voiceUrl: '',
|
||||
voiceId: '',
|
||||
messageList: [
|
||||
// {
|
||||
// userType: 0,
|
||||
// sdkFileUrl: 'http://test87ftp.cunwuyun.cn/20240104/output.mp3',
|
||||
// isPlay: false
|
||||
// }
|
||||
],
|
||||
current: 1,
|
||||
pages: 2,
|
||||
areaId: '',
|
||||
statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
|
||||
typeList: [],
|
||||
aiConfigId: '',
|
||||
aiConfigName: '',
|
||||
showType: false,
|
||||
showPopup: true,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['user', 'token']),
|
||||
},
|
||||
onLoad() {
|
||||
recorderManager.onStop((res)=> {
|
||||
this.upLoad(res.tempFilePath)
|
||||
});
|
||||
},
|
||||
mounted() {
|
||||
this.getAiTypeList()
|
||||
this.getHistoryList()
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if(this.current > this.pages) {
|
||||
return this.$u.toast('没有更多记录')
|
||||
}
|
||||
this.current = this.current + 1
|
||||
this.getHistoryList()
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['autoLogin', 'getUserInfo']),
|
||||
startRecord() {
|
||||
if(this.isFlag) return
|
||||
this.isStart = true
|
||||
uni.authorize({
|
||||
scope: 'scope.record',
|
||||
success() {
|
||||
// const options = {
|
||||
// duration: 10000,
|
||||
// sampleRate: 44100,
|
||||
// numberOfChannels: 1,
|
||||
// encodeBitRate: 192000,
|
||||
// format: 'aac',
|
||||
// frameSize: 50
|
||||
// }
|
||||
const options = {
|
||||
duration: 60000,
|
||||
sampleRate: 16000,
|
||||
format: 'mp3'
|
||||
}
|
||||
recorderManager.start(options);
|
||||
|
||||
},
|
||||
fail(err) {
|
||||
this.isStart = false
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "您的录音权限未开启",
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
endRecord() {
|
||||
this.isStart = false
|
||||
setTimeout(() => {
|
||||
this.isFlag = false
|
||||
}, 6000)
|
||||
recorderManager.stop();
|
||||
},
|
||||
microPhone() {
|
||||
this.type = 'voice'
|
||||
this.isStart = false
|
||||
},
|
||||
keyboardClick() {
|
||||
if(this.isStart) return
|
||||
this.type = 'text'
|
||||
this.content = ''
|
||||
},
|
||||
upLoad(filePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: `${this.$http.defaults.baseURL}/admin/file/add`,
|
||||
filePath,
|
||||
fileType: 'audio',
|
||||
name: 'file',
|
||||
success: uploadFileRes => {
|
||||
this.voiceUrl = JSON.parse(uploadFileRes.data).data[0].split(';')[0]
|
||||
this.voiceId = JSON.parse(uploadFileRes.data).data[0].split(';')[1]
|
||||
this.sendVoice()
|
||||
resolve(uploadFileRes)
|
||||
},
|
||||
fail: err => {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
sendMsg() {
|
||||
if(!this.user.token) {
|
||||
return this.$u.toast("请先进行登录")
|
||||
}
|
||||
this.$loading()
|
||||
this.$http.post("/app/appaicopilotinfo/add", {content: this.content, appType: 0, areaId: this.areaId, aiConfigId: this.aiConfigId}).then(res => {
|
||||
if(res.code == 0) {
|
||||
this.content = ''
|
||||
this.messageList.push(res.data[0])
|
||||
this.messageList.push(res.data[1])
|
||||
this.$nextTick(() => {
|
||||
uni.pageScrollTo({
|
||||
duration: 300,
|
||||
selector: `.item${this.messageList.length-1}`
|
||||
});
|
||||
})
|
||||
this.$hideLoading()
|
||||
}
|
||||
})
|
||||
},
|
||||
sendVoice() {
|
||||
if(!this.user.token) {
|
||||
return this.$u.toast("请先进行登录")
|
||||
}
|
||||
this.$loading()
|
||||
this.$http.post("/app/appaicopilotinfo/add", {sdkFileUrl: this.voiceUrl, fileId: this.voiceId, appType: 0, aiConfigId: this.aiConfigId}).then(res => {
|
||||
if(res.code == 0) {
|
||||
this.voiceUrl = ''
|
||||
this.voiceId = ''
|
||||
res.data.map((item) => {
|
||||
if(item.sdkFileUrl) {
|
||||
item.isPlay = false
|
||||
}
|
||||
})
|
||||
this.messageList.push(res.data[0])
|
||||
this.messageList.push(res.data[1])
|
||||
uni.pageScrollTo({
|
||||
duration: 300,
|
||||
selector: `.item${this.messageList.length-1}`
|
||||
});
|
||||
this.$hideLoading()
|
||||
}
|
||||
})
|
||||
},
|
||||
getHistoryList() {
|
||||
if(!this.user.token) {
|
||||
return this.$u.toast("请先进行登录")
|
||||
}
|
||||
this.$loading()
|
||||
this.$http.post(`/app/appaicopilotinfo/list?current=${this.current}&size=10&aiConfigId=${this.aiConfigId}`).then(res => {
|
||||
if(res.code == 0 && res.data.records.length) {
|
||||
res.data.records.map((item) => {
|
||||
if(item.sdkFileUrl) {
|
||||
item.isPlay = false
|
||||
}
|
||||
})
|
||||
this.messageList = this.current == 1 ? res.data.records : [...res.data.records, ...this.messageList]
|
||||
var idPage = res.data.records.length-1
|
||||
this.$nextTick(() => {
|
||||
uni.pageScrollTo({
|
||||
duration: 300,
|
||||
selector: this.current == 1 ? `.item${this.messageList.length-1}` : `.item${idPage}`
|
||||
});
|
||||
})
|
||||
this.pages = res.data.pages
|
||||
this.$hideLoading()
|
||||
}
|
||||
})
|
||||
},
|
||||
play(src, index) {
|
||||
innerAudioContext.stop();
|
||||
if(this.messageList[index].isPlay) {
|
||||
innerAudioContext.onStop(() => {
|
||||
this.messageList[index].isPlay = false
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.messageList.map((item) => {
|
||||
if(item.sdkFileUrl) {
|
||||
item.isPlay = false
|
||||
}
|
||||
})
|
||||
this.messageList[index].isPlay = true
|
||||
innerAudioContext.src = src;
|
||||
|
||||
this.$nextTick(() => {
|
||||
innerAudioContext.play();
|
||||
})
|
||||
innerAudioContext.onEnded(() => {
|
||||
this.messageList[index].isPlay = false
|
||||
})
|
||||
},
|
||||
playStop(index) {
|
||||
innerAudioContext.stop();
|
||||
innerAudioContext.onStop(() => {
|
||||
this.messageList[index].isPlay = false
|
||||
})
|
||||
},
|
||||
confirmType(val) {
|
||||
this.aiConfigId = val[0].value
|
||||
this.aiConfigName = val[0].label
|
||||
},
|
||||
getAiTypeList() {
|
||||
this.$http.post(`/app/appaiconfiginfo/list?status=1`).then(res => {
|
||||
if(res.code == 0) {
|
||||
res.data.records.map((item) => {
|
||||
item.dictName = item.appName
|
||||
item.dictValue = item.id
|
||||
})
|
||||
this.typeList = res.data.records
|
||||
this.aiConfigId = this.typeList[0].dictValue
|
||||
this.aiConfigName = this.typeList[0].dictName
|
||||
this.getHistoryList()
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
page {
|
||||
height: 100%;
|
||||
}
|
||||
.Talk {
|
||||
height: 100vh;
|
||||
background-color: #fff;
|
||||
position: relative;
|
||||
.top-select {
|
||||
line-height: 64px;
|
||||
background: #026AF2;
|
||||
border-radius: 32px;
|
||||
position: fixed;
|
||||
left: 28px;
|
||||
top: 32px;
|
||||
text-align: center;
|
||||
padding: 0 24px;
|
||||
font-family: PingFangSC-Medium;
|
||||
font-weight: 500;
|
||||
font-size: 28px;
|
||||
color: #FFF;
|
||||
z-index: 9;
|
||||
u-icon {
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
.service-content {
|
||||
width: 100%;
|
||||
height: 420px;
|
||||
// background-image: url("https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/content-top-bg.png");
|
||||
// background-size: 100vw;
|
||||
// background-repeat: no-repeat;
|
||||
padding-top: 116px;
|
||||
box-sizing: border-box;
|
||||
.text-content {
|
||||
margin: 0 0 0 32px;
|
||||
width: 686px;
|
||||
height: 260px;
|
||||
background-image: url("https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/service-content-bg.png");
|
||||
background-size: 100vw;
|
||||
background-repeat: no-repeat;
|
||||
padding: 32px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 32px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
.text-left {
|
||||
width: calc(100% - 192px);
|
||||
div {
|
||||
line-height: 54px;
|
||||
font-family: SourceHanSansCN-Bold;
|
||||
font-weight: 700;
|
||||
font-size: 36px;
|
||||
// background: linear-gradient(to bottom, #2A6EE9, #58A5F7);
|
||||
// -webkit-background-clip: text;
|
||||
// -webkit-text-fill-color: transparent;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
p {
|
||||
color: #222;
|
||||
font-size: 28px;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 44px;
|
||||
span {
|
||||
display: inline-block;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
}
|
||||
.service-img {
|
||||
display: inline-block;
|
||||
width: 192px;
|
||||
height: 170px;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
.list-bg {
|
||||
width: 100%;
|
||||
height: 420px;
|
||||
background-image: url("https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/content-top-bg.png");
|
||||
position: fixed;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
background-size: 100vw;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.list-content {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
padding: 128px 32px 364px;
|
||||
.send-time {
|
||||
display: block;
|
||||
width: 100%;
|
||||
line-height: 28px;
|
||||
font-family: PingFangSC-Regular;
|
||||
font-weight: 400;
|
||||
font-size: 20px;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
.user-img {
|
||||
display: inline-block;
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.item {
|
||||
display: inline-block;
|
||||
max-width: 440px;
|
||||
border-radius: 8px;
|
||||
padding: 18px;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 28px;
|
||||
position: relative;
|
||||
.voice-div {
|
||||
img {
|
||||
width: 26px;
|
||||
height: 28px;
|
||||
}
|
||||
span {
|
||||
display: inline-block;
|
||||
color: #333;
|
||||
font-size: 28px;
|
||||
font-family: PingFangSC;
|
||||
line-height: 28px;
|
||||
margin-right: 68px;
|
||||
}
|
||||
}
|
||||
p {
|
||||
word-break: break-all;
|
||||
line-height: 40px;
|
||||
font-family: SourceHanSansCN-Regular;
|
||||
font-size: 32px;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
.item-right {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
.item {
|
||||
background-color: #CCE2FF;
|
||||
}
|
||||
.user-img {
|
||||
margin-left: 24px;
|
||||
}
|
||||
.u-icon-right {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: -12px;
|
||||
}
|
||||
}
|
||||
.item-left {
|
||||
.item {
|
||||
background-color: #F3F5F7;
|
||||
}
|
||||
.user-img {
|
||||
margin-right: 24px;
|
||||
}
|
||||
.u-icon-left {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
left: -12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fixed-bottom {
|
||||
position: fixed;
|
||||
bottom: 168px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
border-top: 1px solid #eee;
|
||||
background-color: #fff;
|
||||
.type-text {
|
||||
padding: 24px 0 24px 32px;
|
||||
display: flex;
|
||||
img {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
padding-right: 16px;
|
||||
}
|
||||
}
|
||||
::v-deep .u-input {
|
||||
width: calc(100% - 112px);
|
||||
height: 80px;
|
||||
background: #F4F6FA;
|
||||
border-radius: 40px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
::v-deep .u-input__input {
|
||||
padding-left: 32px;
|
||||
}
|
||||
.type-record {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
padding-top: 36px;
|
||||
.keyboard-btn {
|
||||
width: 48px;
|
||||
height: 36px;
|
||||
position: absolute;
|
||||
top: 32px;
|
||||
right: 32px;
|
||||
}
|
||||
p {
|
||||
line-height: 58px;
|
||||
font-family: SourceHanSansCN-Medium;
|
||||
font-weight: 500;
|
||||
font-size: 40px;
|
||||
color: #222;
|
||||
}
|
||||
.record-btn {
|
||||
width: 156px;
|
||||
height: 156px;
|
||||
margin-top: 24px;
|
||||
}
|
||||
.tips-text {
|
||||
line-height: 40px;
|
||||
font-family: SourceHanSansCN-Regular;
|
||||
font-size: 28px;
|
||||
color: #999;
|
||||
margin-top: 16px;
|
||||
}
|
||||
.recording {
|
||||
padding-top: 48px;
|
||||
width: 204px;
|
||||
height: 96px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.login-btn {
|
||||
position: fixed;
|
||||
bottom: 500px;
|
||||
left: 0;
|
||||
width: 144px;
|
||||
height: 64px;
|
||||
background: #B8B8B8;
|
||||
border-top-right-radius: 44px;
|
||||
border-bottom-right-radius: 44px;
|
||||
padding: 12px 16px;
|
||||
box-sizing: border-box;
|
||||
line-height: 40px;
|
||||
font-family: PingFangSC-Medium;
|
||||
font-weight: 500;
|
||||
font-size: 28px;
|
||||
color: #FFF;
|
||||
z-index: 999;
|
||||
img {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
vertical-align: bottom;
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
.popup-content {
|
||||
padding: 32px 28px 68px;
|
||||
box-sizing: border-box;
|
||||
.pop-header {
|
||||
padding-bottom: 28px;
|
||||
line-height: 20px;
|
||||
font-family: PingFangSC-Medium;
|
||||
font-weight: 500;
|
||||
font-size: 28px;
|
||||
color: #222;
|
||||
img {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 50%;
|
||||
margin-right: 16px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
.pop-title {
|
||||
line-height: 44px;
|
||||
font-family: PingFangSC-Medium;
|
||||
font-weight: 500;
|
||||
font-size: 32px;
|
||||
color: #222;
|
||||
padding-bottom: 28px;
|
||||
border-bottom: 1px solid #DEDEDE;
|
||||
}
|
||||
.pop-text {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 38px 0;
|
||||
border-bottom: 1px solid #DEDEDE;
|
||||
p {
|
||||
line-height: 40px;
|
||||
font-family: PingFangSC-Regular;
|
||||
font-size: 28px;
|
||||
color: #222;
|
||||
}
|
||||
}
|
||||
.pop-btn {
|
||||
padding: 56px 0;
|
||||
div {
|
||||
display: inline-block;
|
||||
width: calc(50% - 38px);
|
||||
line-height: 72px;
|
||||
background: #F2F2F2;
|
||||
border-radius: 8px;
|
||||
font-family: PingFangSC-Regular;
|
||||
font-weight: 400;
|
||||
font-size: 28px;
|
||||
color: #222;
|
||||
text-align: center;
|
||||
}
|
||||
.pop-confirm {
|
||||
margin-left: 38px;
|
||||
background-color: #2EC871;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
BIN
src/project/baidu/AppDialogue/img/del-img.png
Normal file
BIN
src/project/baidu/AppDialogue/img/del-img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 679 B |
BIN
src/project/baidu/AppDialogue/img/record.png
Normal file
BIN
src/project/baidu/AppDialogue/img/record.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 795 B |
BIN
src/project/baidu/AppDialogue/img/record_selected.png
Normal file
BIN
src/project/baidu/AppDialogue/img/record_selected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 806 B |
BIN
src/project/baidu/AppDialogue/img/talk.png
Normal file
BIN
src/project/baidu/AppDialogue/img/talk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src/project/baidu/AppDialogue/img/talk_selected.png
Normal file
BIN
src/project/baidu/AppDialogue/img/talk_selected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Reference in New Issue
Block a user