百度AI输入表单

This commit is contained in:
liuye
2024-04-25 12:05:54 +08:00
parent 8a7e2e3c88
commit acacb9510a
7 changed files with 1393 additions and 0 deletions

View File

@@ -0,0 +1,189 @@
<template>
<div class="AppAiInput">
<div class="content-info" v-if="text">{{text}}</div>
<div class="problem-list">
<p class="title">请一句话告诉我这些信息</p>
<div class="list-content">
<p>您排查的户主姓名</p>
<p>户主的性别</p>
<p>户主的联系电话</p>
<p>户主的出生日期</p>
<p>户主的民族</p>
<p>户主家里的家庭人口数</p>
<p>我要上报的事情</p>
</div>
</div>
<div class="microphone-info">
<p class="loading" v-if="isStart">语音录制中...</p>
<div class="microphone-img" @touchstart="start" @touchend="end">
<!-- <img src="./img/microphone.png" alt="" @longpress=""> -->
<u-icon name="mic" color="#fff" size="140" style="margin-top:20px;"></u-icon>
</div>
<p class="text">{{isStart ? '松开结束说话' : '按住说话'}}</p>
<!-- <div class="btn">
<p class="cancel" @click="cancel">取消</p>
<p class="confirm" @click="confirm" v-if="text">确定</p>
</div> -->
</div>
</div>
</template>
<script>
import {mapState, mapActions} from "vuex";
export default {
name: 'AppAiInput',
appName: '百度AI输入',
data() {
return {
isStart: false,
text: ''
}
},
computed: {
...mapState(['user']),
},
onLoad() {
this.text = ''
this.injectJWeixin(['startRecord','stopRecord', 'translateVoice'])
},
onShow() {
this.text = ''
document.title = '巡查上报'
},
methods: {
...mapActions(['injectJWeixin']),
start() {
wx.startRecord()
this.isStart = true
},
end() {
this.isStart = false
wx.stopRecord({
success: (res)=> {
wx.translateVoice({
localId: res.localId, // 需要识别的音频的本地Id由录音相关接口获得音频时长不能超过60秒
isShowProgressTips: 1, // 默认为1显示进度提示
success: (e)=> {
this.text = this.text + e.translateResult // 语音识别的结果
this.confirm()
}
});
}
});
},
confirm() {
uni.navigateTo({url: `./formEdit?word=${this.text}`})
},
cancel() {
wx.stopRecord()
this.text = ''
}
},
}
</script>
<style lang="scss" scoped>
uni-page-body {
min-height: 100%;
// height: 100vh;
padding-top: 32px;
background: #fff;
}
.AppAiInput {
.content-info {
margin: 0 0 32px 32px;
width: 686px;
height: 272px;
background-image: linear-gradient(157deg, #F7FAFD 2%, #EDF6FF 99%);
border-radius: 16px;
padding: 24px 28px 28px 28px;
font-family: PingFangSC-Regular;
font-size: 28px;
color: #222;
box-sizing: border-box;
overflow-y: scroll;
}
.problem-list {
margin: 0 0 32px 32px;
width: 686px;
background: #F5F6F8;
border-radius: 16px;
padding: 28px;
box-sizing: border-box;
.title {
line-height: 44px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 32px;
color: #6C768A;
text-align: center;
margin-bottom: 28px;
}
.list-content {
width: 630px;
background: #FFF;
border-radius: 12px;
overflow-y: scroll;
padding: 28px;
text-align: center;
box-sizing: border-box;
p {
font-family: PingFangSC-Regular;
font-size: 28px;
color: #222;
line-height: 56px;
}
}
}
.microphone-info {
position: fixed;
bottom: 48px;
left: 0;
width: 100%;
text-align: center;
.microphone-img {
width: 216px;
height: 216px;
border-radius: 50%;
background-image: linear-gradient(180deg, #0262F2 25%, #148AFF 99%);
text-align: center;
margin-left: 272px;
margin-bottom: 20px;
img {
width: 68px;
height: 96px;
margin-top: 62px;
}
}
.text {
font-family: PingFangSC-Regular;
font-size: 36px;
color: #222;
margin-bottom: 64px;
}
.loading {
font-family: PingFangSC-Regular;
font-size: 28px;
color: #666;
margin-bottom: 32px;
text-align: center;
}
.btn {
text-align: center;
font-family: PingFangSC-Regular;
font-size: 36px;
p {
display: inline-block;
}
.cancel {
color: #999;
}
.confirm {
color: #0262F2;
margin-left: 120px;
}
}
}
}
</style>

View File

@@ -0,0 +1,258 @@
<template>
<div class="formConfirm">
<div class="list-content">
<div class="item">
<span class="tips">*</span>
<div class="item-border">
<div class="label">户主姓名</div>
<div class="value">
<u-input type="text" class="right" placeholder="请输入" height="44" input-align="right" v-model="info.name"></u-input>
</div>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="item-border">
<div class="label">性别</div>
<div class="value" @click="showSex=true">
<span :class="info.sex == null ? 'color-999' : ''">{{ $dict.getLabel('sex', info.sex) || '请选择'}}</span>
<img src="./img/arrow-right.png" alt="">
</div>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="item-border">
<div class="label">联系电话</div>
<div class="value">
<u-input type="text" class="right" placeholder="请输入" height="44" input-align="right" v-model="info.phone"></u-input>
</div>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="item-border">
<div class="label">出生日期</div>
<div class="value" @click="showDate=true">
<span :class="info.birthday == null ? 'color-999' : ''">{{ info.birthday || '请选择'}}</span>
<img src="./img/arrow-right.png" alt="">
</div>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="item-border">
<div class="label">民族</div>
<div class="value" @click="showNation=true">
<span :class="info.nation == null ? 'color-999' : ''">{{ $dict.getLabel('nation', info.nation) || '请选择'}}</span>
<img src="./img/arrow-right.png" alt="">
</div>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="item-border">
<div class="label">家庭人口数</div>
<div class="value">
<u-input type="text" class="right" placeholder="请输入" height="44" input-align="right" v-model="info.householdNumber"></u-input>
</div>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="text-label">
<div class="label">我要上报的事情</div>
</div>
<div class="text-value">
<u-input type="textarea" placeholder="请输入" :height="300" input-align="left" v-model="info.reportThing" :clearable="false" maxlength="500"></u-input>
</div>
</div>
</div>
<div class="bottom-btn">
<!-- <div class="confirm" @click="confirm('保存成功')">保存内容</div> -->
<div class="confirm" @click="confirm('提交成功')">提交</div>
<div class="cancel" @click="back">返回录制</div>
</div>
<u-picker mode="time" v-model="showDate" :params="deteParams" start-year="1930" @confirm="dateConfirm">请选择</u-picker>
<u-select v-model="showSex" :list="$dict.getDict('sex')" label-name="dictName" value-name="dictValue" @confirm="confirmSex"/>
<u-select v-model="showNation" :list="$dict.getDict('nation')" label-name="dictName" value-name="dictValue" @confirm="confirmNation"/>
</div>
</template>
<script>
import {mapState} from "vuex";
export default {
name: 'formConfirm',
data() {
return {
word: '',
info: {},
showSex: false,
showNation: false,
showDate: false,
deteParams: {year: true, month: true, day: true, hour: false, minute: false, second: false},
}
},
computed: {
...mapState(['user']),
},
onLoad(option) {
this.info = JSON.parse(option.info)
this.$dict.load('sex', 'nation').then(() => {
// this.getInfo()
})
},
onShow() {
document.title = '巡查上报'
},
methods: {
getInfo() {
uni.showLoading({title: '读取中'})
this.$http.post(`/app/appbaiduai/queryByInfo?word=${this.word}`).then((res) => {
if (res.code === 0) {
this.info = {...res.data}
uni.hideLoading()
}
}).catch(res => {
this.$u.toast(res)
uni.hideLoading()
})
},
confirmSex(e) {
this.info.sex = e[0].value
},
confirmNation(e) {
this.info.nation = e[0].value
},
dateConfirm(e) {
this.info.birthday = `${e.year}-${e.month}-${e.day}`
},
confirm(successText) {
// if(this.info.name == null || !this.info.name) {
// return this.$u.toast('请输入户主姓名')
// }
// if(this.info.sex == null) {
// return this.$u.toast('请选择性别')
// }
// if(this.info.phone == null || !this.info.phone) {
// return this.$u.toast('请输入联系电话')
// }
// if(this.info.birthday == null) {
// return this.$u.toast('请选择出生日期')
// }
// if(this.info.nation == null) {
// return this.$u.toast('请选择民族')
// }
// if(this.info.householdNumber == null || !this.info.householdNumber) {
// return this.$u.toast('请输入家庭人口数')
// }
// this.showModel = true
this.$confirm('已流转到城管部门处理', '上报成功').then(() => {
this.back()
})
},
back() {
uni.navigateBack({delta: 2})
}
},
}
</script>
<style lang="scss" scoped>
uni-page-body {
height: 100vh;
background: #F5F5F5;
}
.formConfirm {
.list-content {
padding-bottom: 328px;
.item {
padding-left: 32px;
position: relative;
margin-bottom: 16px;
background-color: #fff;
.tips {
position: absolute;
top: 34px;
left: 8px;
font-family: PingFangSC-Regular;
font-size: 32px;
color: #F46;
}
.label {
font-family: PingFangSC-Regular;
font-size: 32px;
color: #333;
line-height: 44px;
width: 240px;
}
.item-border {
padding: 34px 32px 34px 0;
width: 100%;
box-sizing: border-box;
border-bottom: 1px solid #D8DDE6;
display: flex;
.value {
width: calc(100% - 240px);
text-align: right;
.u-input {
display: inline-block;
width: calc(100% - 40px);
vertical-align: sub;
}
img {
display: inline-block;
width: 32px;
height: 32px;
margin-left: 8px;
vertical-align: middle;
}
.color-999 {
color: rgb(192, 196, 204);
}
}
}
.text-label {
padding: 34px 32px 34px 0;
}
.text-value {
padding-right: 32px;
::v-deep .uni-textarea-textarea{
font-size: 28px;
}
}
}
}
.bottom-btn {
position: fixed;
bottom: 0;
left: 0;
background-color: #F5F5F5;
div {
margin-left: 32px;
width: 686px;
height: 88px;
border-radius: 44px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 34px;
text-align: center;
line-height: 86px;
margin-bottom: 32px;
}
.confirm {
background: #3975C6;
color: #fff;
}
.cancel {
background-color: #fff;
color: #666;
border: 1px solid #CCC;
}
}
::v-deep .u-input__right-icon {
display: none;
}
}
</style>

View File

@@ -0,0 +1,287 @@
<template>
<div class="formEdit">
<div class="title">
<span></span>请确认并校准您输入的内容
</div>
<div class="list-content">
<div class="item">
<div class="label">
<span>户主姓名</span>
<div class="edit" @click="editName=true">
<img src="./img/edit.png" alt="">修改
</div>
</div>
<div class="value">
<u-input type="text" class="right" placeholder="请输入" height="44" input-align="center" v-model="info.name" :clearable="false" v-if="editName"></u-input>
<span v-else>{{info.name || '请输入'}}</span>
</div>
</div>
<div class="item">
<div class="label">
<span>性别</span>
<div class="edit" @click="showSex=true">
<img src="./img/edit.png" alt="">修改
</div>
</div>
<div class="value">
<span>{{ $dict.getLabel('sex', info.sex) || '请选择'}}</span>
</div>
</div>
<div class="item">
<div class="label">
<span>联系电话</span>
<div class="edit" @click="editPhone=true">
<img src="./img/edit.png" alt="">修改
</div>
</div>
<div class="value">
<u-input type="text" class="right" placeholder="请输入" height="44" input-align="center" v-model="info.phone" :clearable="false" v-if="editPhone"></u-input>
<span v-else>{{info.phone || '请输入'}}</span>
</div>
</div>
<div class="item">
<div class="label">
<span>出生日期</span>
<div class="edit" @click="showDate=true">
<img src="./img/edit.png" alt="">修改
</div>
</div>
<div class="value">
<span>{{info.birthday || '请选择'}}</span>
</div>
</div>
<div class="item">
<div class="label">
<span>民族</span>
<div class="edit" @click="showNation=true">
<img src="./img/edit.png" alt="">修改
</div>
</div>
<div class="value">
<span>{{ $dict.getLabel('nation', info.nation) || '请选择'}}</span>
</div>
</div>
<div class="item">
<div class="label">
<span>家庭人口数</span>
<div class="edit" @click="editHouseholdNumber=true">
<img src="./img/edit.png" alt="">修改
</div>
</div>
<div class="value">
<u-input type="text" class="right" placeholder="请输入" height="44" input-align="center" v-model="info.householdNumber" :clearable="false" v-if="editHouseholdNumber"></u-input>
<span v-else>{{info.householdNumber || '请输入'}}</span>
</div>
</div>
<div class="item">
<div class="label">
<span>我要上报的事情</span>
<div class="edit" @click="editReportThing=true">
<img src="./img/edit.png" alt="">修改
</div>
</div>
<div class="value">
<u-input type="textarea" placeholder="请输入" :height="300" input-align="center" v-model="info.reportThing" :clearable="false" maxlength="500" v-if="editReportThing"></u-input>
<span v-else>{{info.reportThing || '请输入'}}</span>
</div>
</div>
</div>
<div class="bottom-btn">
<div class="confirm" @click="toConfirm">确认使用</div>
<div class="cancel" @click="back">取消输入</div>
</div>
<u-picker mode="time" v-model="showDate" :params="deteParams" start-year="1930" @confirm="dateConfirm">请选择</u-picker>
<u-select v-model="showSex" :list="$dict.getDict('sex')" label-name="dictName" value-name="dictValue" @confirm="confirmSex"/>
<u-select v-model="showNation" :list="$dict.getDict('nation')" label-name="dictName" value-name="dictValue" @confirm="confirmNation"/>
</div>
</template>
<script>
import {mapState} from "vuex";
export default {
name: 'formEdit',
data() {
return {
word: '',
info: {},
showSex: false,
showNation: false,
showDate: false,
deteParams: {year: true, month: true, day: true, hour: false, minute: false, second: false},
editName: false,
editPhone: false,
editHouseholdNumber: false,
editReportThing: false
}
},
computed: {
...mapState(['user']),
},
onLoad(option) {
this.word = option.word
this.$dict.load('sex', 'nation').then(() => {
this.getInfo()
})
},
onShow() {
document.title = '巡查上报'
},
methods: {
getInfo() {
uni.showLoading({title: '读取中'})
this.info = {}
this.$http.post(`/app/appbaiduai/queryByInfo?word=${this.word}`).then((res) => {
if (res.code === 0) {
this.info = {...res.data}
uni.hideLoading()
}
}).catch(res => {
uni.hideLoading()
this.$u.toast(res)
})
},
confirmSex(e) {
this.info.sex = e[0].value
},
confirmNation(e) {
this.info.nation = e[0].value
},
dateConfirm(e) {
this.info.birthday = `${e.year}-${e.month}-${e.day}`
},
toConfirm() {
// if(this.info.name == null || !this.info.name) {
// return this.$u.toast('请输入户主姓名')
// }
// if(this.info.sex == null) {
// return this.$u.toast('请选择性别')
// }
// if(this.info.phone == null || !this.info.phone) {
// return this.$u.toast('请输入联系电话')
// }
// if(this.info.birthday == null) {
// return this.$u.toast('请选择出生日期')
// }
// if(this.info.nation == null) {
// return this.$u.toast('请选择民族')
// }
// if(this.info.householdNumber == null || !this.info.householdNumber) {
// return this.$u.toast('请输入家庭人口数')
// }
var info = JSON.stringify(this.info)
uni.navigateTo({url: `./formConfirm?info=${info}`})
},
back() {
uni.navigateBack()
}
},
}
</script>
<style lang="scss" scoped>
uni-page-body {
height: 100vh;
background: #fff;
padding-top: 26px;
}
.formEdit {
.title {
padding-left: 32px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 32px;
color: #000;
line-height: 48px;
margin-bottom: 22px;
span {
display: inline-block;
width: 6px;
height: 28px;
background: #3399FF;
border-radius: 3px;
margin-right: 18px;
}
}
.list-content {
padding-bottom: 372px;
background-color: #fff;
.item {
text-align: center;
margin-bottom: 64px;
.label {
margin-bottom: 18px;
span {
color: #999;
font-size: 40px;
font-family: PingFangSC;
font-weight: 500;
line-height: 60px;
text-align: center;
}
.edit {
display: inline-block;
width: 150px;
text-align: right;
font-family: PingFangSC-Regular;
font-size: 28px;
color: #3072F5;
vertical-align: text-bottom;
img {
width: 28px;
height: 28px;
margin: 0 12px 0 32px;
vertical-align: middle;
}
}
}
.value {
.u-input, span{
display: inline-block;
width: 100%;
text-align: center;
color: #3975c6;
font-size: 40px;
font-family: PingFangSC;
font-weight: 500;
line-height: 60px;
}
::v-deep .uni-input-input,
::v-deep .uni-textarea-textarea{
color: #3975c6;
font-size: 40px;
font-family: PingFangSC;
font-weight: 500;
line-height: 60px;
}
}
}
}
.bottom-btn {
position: fixed;
bottom: 0;
left: 0;
background-color: #fff;
div {
margin-left: 32px;
width: 686px;
height: 88px;
border-radius: 44px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 34px;
text-align: center;
line-height: 86px;
margin-bottom: 32px;
}
.confirm {
background: #3975C6;
color: #fff;
}
.cancel {
color: #666;
border: 1px solid #CCC;
}
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,659 @@
<template>
<div class="AppVillageHead">
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scroll="scroll" v-if="messageList.length" :style="{height: scrollHeight+'px'}">
<div class="list-content">
<div v-for="(item, index) in messageList" :key="index">
<div :class="item.userType == 1 ? 'item-left' : 'item-right'" v-if="item.userType != 2">
<div class="item" :class="'item'+index">
<div class="img-div" v-if="item.sdkFileUrl">
<u-icon name="play-circle" :color="item.userType == 0 ? '#fff' : '#A8ADAE'" size="52" v-if="!item.isPlay" @click="play(item.sdkFileUrl, index)"></u-icon>
<u-icon name="pause-circle" :color="item.userType == 0 ? '#fff' : '#A8ADAE'" size="52" v-else @click="playStop(index)"></u-icon>
<img src="https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/recording-white.png" alt="" v-if="item.userType == 0">
<img src="https://cdn.cunwuyun.cn/wechat/biaopin/residentAssistant/recording-gray.png" alt="" v-else>
</div>
<p>{{item.content || ''}}</p>
</div>
</div>
<div class="statistics-content" v-if="item.userType == 2">
<div class="title">{{item.content['标题']}}</div>
<div class="mini-title">
<span></span>宣发情况
</div>
<div class="flex-info">
<div class="info">宣发数据<span>{{item.content['宣发条数']}}</span></div>
</div>
<div class="flex-info mar-b12">
<div class="info">触达居民群数
<div>
<span>{{item.content['宣发触达居民群数'] || 0}}</span>
</div>
</div>
<div class="info">触达居民
<div>
<span>{{item.content['宣发触达居民']}}</span>
</div>
</div>
</div>
<div class="mini-title">
<span></span>AI问答
</div>
<div class="flex-info">
<div class="info">居民累计提问
<div>
<span>{{item.content['昨日累计提问']}}</span>
</div>
</div>
<div class="info">居民平均提问
<div>
<span>{{item.content['昨日居民平均提问']}}</span>/
</div>
</div>
</div>
<div class="flex-info mar-b12">
<div class="info">最活跃群提问
<div>
<span>{{item.content['昨日最活跃群提问']}}</span>
</div>
</div>
</div>
<div class="title">近7天居民群数据</div>
<div class="flex-total">
<div class="item-total">
<p>服务居民数</p>
<div><span>{{item.content['服务居民数']}}</span></div>
</div>
<div class="item-total">
<p>回答问题总数</p>
<div><span>{{item.content['7天回答问题总数']}}</span></div>
</div>
<div class="item-total">
<p>覆盖群聊</p>
<div><span>{{item.content['7天覆盖群聊']}}</span></div>
</div>
</div>
<div class="hot" v-if="item.content['热点话题'] && item.content['热点话题'].length">
<div class="mini-title">
<span></span>热点话题
</div>
<div class="item-hot" v-for="(items, indexs) in item.content['热点话题']" :key="indexs" v-if="indexs < 6">
<div @click="getTagList(items.tag)"><span :class="'color'+indexs">{{indexs+1}}.</span>{{items.tag}}</div>
</div>
</div>
</div>
</div>
</div>
</scroll-view>
<AiEmpty description="暂无数据" v-if="!messageList.length"/>
<div class="fixed-bottom">
<div class="type-text" v-if="type == 'text'">
<u-input type="text" placeholder="输入您的问题…" height="80" input-align="left" :clearable="false" :border="true" placeholder-style="color:#666;" v-model="content"></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-popup v-model="showMask" mode="center" width="85%" height="900" border-radius="14" :closeable="true">
<div class="mask-content">
<div class="mini-title">
<span></span>热点话题
</div>
<div class="list-info">
<div class="item" v-for="(item, index) in tagList" :key="index">
<div class="name">{{item.user_name}}-{{item.room_name}}</div>
<div class="time">{{item.msg_send_time}}</div>
<div class="content">{{item.content}}</div>
</div>
</div>
</div>
</u-popup>
</div>
</template>
<script>
import {mapState} from "vuex";
import Recorder from 'recorder-core'
import 'recorder-core/src/engine/mp3'
import 'recorder-core/src/engine/mp3-engine'
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
export default {
name: 'AppVillageHead',
appName: '村长coplite',
data() {
return {
recorder: null,
type: 'text',
isStart: false,
content: '',
isFlag: false,
voiceUrl: 'http://test87ftp.cunwuyun.cn/20240109/filename-20240109111547.mp3',
voiceId: '0678a73c50b74bdcb8398e14ffbb35e5',
messageList: [
// {
// userType: 0,
// sdkFileUrl: 'http://test87ftp.cunwuyun.cn/20240104/output.mp3',
// isPlay: false
// }
],
current: 1,
pages: 2,
scrollTop: 0,
scrollHeight: '',
preveHeight: '',
showMask: false,
tagList: []
}
},
computed: {
...mapState(['user']),
},
onLoad() {
this.scrollHeight = uni.getSystemInfoSync().windowHeight
this.getHistoryList()
// var res = ["http://test87ftp.cunwuyun.cn/20240109/filename-20240109111547.mp3;0678a73c50b74bdcb8398e14ffbb35e5"]
// this.voiceUrl = res[0].split(';')[0]
// this.voiceId = res[0].split(';')[1]
// this.sendVoice()
},
onShow() {
document.title = '村长copilot'
},
methods: {
startRecord() {
this.isStart = true
this.recorder = Recorder({
type: 'mp3',
sampleRate: 16000,
bitRate: 16
})
this.recorder.open(() => {
this.recorder.start()
})
},
endRecord() {
this.recorder.stop((blob) => {
var formData = new FormData();
formData.append('file', blob, 'filename.mp3');
this.$http.post('/admin/file/add', formData, {
withoutToken: true,
}).then((res) => {
uni.hideLoading()
if (res?.data) {
this.voiceUrl = res.data[0].split(';')[0]
this.voiceId = res.data[0].split(';')[1]
this.isStart = false
this.sendVoice()
}
}).catch(res => {
this.$u.toast(res)
uni.hideLoading()
})
this.recorder.close()
this.recorder = null
}, msg => {
console.log('录音失败:' + msg)
this.recorder.close()
this.recorder = null
})
},
microPhone() {
this.type = 'voice'
this.isStart = false
},
keyboardClick() {
if(this.isStart) return
this.type = 'text'
this.content = ''
},
scroll(e) {
if(e.detail.scrollTop == 0) {
if(this.current > this.pages) {
return this.$u.toast('已加载完成,没有更多数据')
}else {
this.current ++
this.getHistoryList()
}
}
},
sendMsg() {
this.$loading()
this.$http.post("/app/appaigccopilotinfo/add", {content: this.content, appType: 1}).then(res => {
if(res.code == 0) {
this.content = ''
this.messageList.push(res.data[0])
this.messageList.push(res.data[1])
this.$nextTick(() => {
uni.createSelectorQuery().select(".list-content").boundingClientRect((res) => {
this.scrollTop = res.height - this.scrollHeight
}).exec();
})
this.$hideLoading()
}
})
},
sendVoice() {
this.$loading()
this.$http.post("/app/appaigccopilotinfo/add", {sdkFileUrl: this.voiceUrl, fileId: this.voiceId, appType: 1}).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])
this.$nextTick(() => {
uni.createSelectorQuery().select(".list-content").boundingClientRect((res) => {
this.scrollTop = res.height - this.scrollHeight
}).exec();
})
this.$hideLoading()
}
})
},
getHistoryList() {
this.$loading()
uni.createSelectorQuery().select(".list-content").boundingClientRect((res) => {
this.preveHeight = res.height
}).exec();
this.$http.post(`/app/appaigccopilotinfo/list?current=${this.current}&size=10`).then(res => {
if(res.code == 0 && res.data.records.length) {
res.data.records.map((item) => {
if(item.sdkFileUrl) {
item.isPlay = false
}
if(item.userType == 2) { //统计数据
item.content = JSON.parse(item.content)
console.log(item.content)
}
})
this.messageList = this.current == 1 ? res.data.records : [...res.data.records, ...this.messageList]
this.pages = res.data.pages
this.$nextTick(() => {
uni.createSelectorQuery().select(".list-content").boundingClientRect((res) => {
if(this.current == 1) {
this.scrollTop = res.height - this.scrollHeight
}else {
this.scrollTop = res.height - this.preveHeight
}
}).exec();
})
this.$hideLoading()
}
})
},
play(src, index) {
innerAudioContext.stop();
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
})
},
getTagList(tag) {
this.$http.post(`/app/appmasssendingtaskbaidu/logsByTag?tag=${tag}`).then(res => {
if(res.code == 0) {
this.tagList = res.data
if(this.tagList.length) {
this.showMask = true
}else {
this.$u.toast('暂未查询到热点话题信息')
}
}
})
}
},
}
</script>
<style lang="scss" scoped>
.AppVillageHead {
height: 100vh;
// padding-top: 32px;
background-color: #fff;
.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: 20px;
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;
}
}
}
.statistics-content {
width: 686px;
background: #F1F4F8;
border-radius: 12px 12px 12px 0;
padding: 32px;
box-sizing: border-box;
color: #222;
margin-bottom: 32px;
.title {
line-height: 44px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 32px;
margin-bottom: 24px;
}
.mini-title {
line-height: 44px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 32px;
margin-bottom: 16px;
span {
display: inline-block;
width: 8px;
height: 32px;
background: #3975C6;
border-radius: 4px;
margin-right: 16px;
vertical-align: middle;
}
}
.info {
font-size: 28px;
font-family: PingFangSC;
line-height: 48px;
margin-bottom: 20px;
span {
color: #0D63F2;
}
}
.mar-b12 {
margin-bottom: 12px;
}
.flex-info {
display: flex;
justify-content: space-between;
}
.down-flex {
display: block;
justify-content: normal;
.info {
display: inline-block;
width: 50%;
}
}
.flex-total {
display: flex;
justify-content: space-between;
margin-bottom: 32px;
.item-total {
p {
font-size: 28px;
font-family: PingFangSC;
line-height: 40px;
margin-bottom: 8px;
}
div {
line-height: 48px;
span {
color: #0D63F2;
}
}
}
}
.hot {
.item-hot {
display: inline-block;
width: 50%;
line-height: 60px;
font-family: PingFangSC-Regular;
font-size: 28px;
color: #0D63F2;
span {
display: inline-block;
margin-right: 16px;
font-family: fantasy;
}
.color0{
color: #EABD2C;
}
.color1{
color: #95A2A6;
}
.color2{
color: #B89383;
}
.color3,
.color4{
color: #666666;
}
}
}
}
.list-content {
padding: 32px 32px 364px;
overflow: hidden;
background-color: #fff;
.item {
max-width: 600px;
border-radius: 24px 24px 0 24px;
padding: 24px 32px;
box-sizing: border-box;
margin-bottom: 32px;
.img-div {
margin-bottom: 4px;
img {
width: 136px;
height: 28px;
margin-left: 26px;
}
}
p {
word-break: break-all;
line-height: 48px;
font-family: SourceHanSansCN-Regular;
font-size: 32px;
}
}
.item-right {
display: flex;
justify-content: flex-end;
.item {
background-image: linear-gradient(-76deg, #569EF0 0%, #276FEC 100%);
}
p {
color: #fff;
}
}
.item-left {
.item {
background-color: #F1F4F8;
}
p {
color: #222;
}
}
}
.fixed-bottom {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
padding-bottom: 64px;
border-top: 1px solid #eee;
background-color: #fff;
.type-text {
padding: 24px 0 24px 32px;
display: flex;
.u-input {
width: calc(100% - 112px);
height: 80px;
background: #F4F6FA;
border-radius: 40px;
padding-left: 32px;
border-radius: 40px;
box-sizing: border-box;
}
img {
width: 80px;
height: 80px;
padding: 0 16px;
}
}
.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;
}
}
}
.mask-content {
padding: 32px 32px 8px 32px;
box-sizing: border-box;
.mini-title {
line-height: 44px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 32px;
margin-bottom: 16px;
span {
display: inline-block;
width: 8px;
height: 32px;
background: #3975C6;
border-radius: 4px;
margin-right: 16px;
vertical-align: middle;
}
}
.list-info {
max-height: 800px;
overflow-y: scroll;
}
.item {
font-family: PingFangSC-Regular;
margin-bottom: 32px;
padding-left: 20px;
.name {
font-size: 28px;
color: #222;
line-height: 40px;
margin-bottom: 8px;
}
.time {
line-height: 28px;
font-size: 20px;
color: #999;
margin-bottom: 8px;
}
.content {
display: inline-block;
line-height: 44px;
font-size: 32px;
color: #333;
background: #C7E7FE;
border-radius: 8px 8px 8px 0;
padding: 14px 12px 14px 20px;
}
}
}
}
</style>