fix: 修复部分问题

This commit is contained in:
white 2024-10-08 15:24:28 +08:00
parent fc777ef92d
commit a8129bb967
24 changed files with 4099 additions and 3065 deletions

View File

@ -2,7 +2,7 @@
<template> <template>
<view class=""> <view class="">
<tm-nav-bar left-icon="arrow-left" :title="desc? getNameByKey(desc) : getNameByKey(activeType)" @clickLeft="back" /> <tm-nav-bar left-icon="arrow-left" :title="desc? getNameByKey(desc) : getNameByKey(activeType)" @clickLeft="back" :rbgs="false"/>
<view class="content"> <view class="content">
<view class="over" style="margin-top: 30rpx" @click="flag = !flag"> <view class="over" style="margin-top: 30rpx" @click="flag = !flag">
<text>日期筛选</text> <text>日期筛选</text>
@ -56,7 +56,7 @@
<view>总胆固醇{{(item.data_msg.cholesterol/100).toFixed(2)}} </view> <view>总胆固醇{{(item.data_msg.cholesterol/100).toFixed(2)}} </view>
<view>甘油三脂{{(item.data_msg.triacylglycerol/100).toFixed(2)}} </view> <view>甘油三脂{{(item.data_msg.triacylglycerol/100).toFixed(2)}} </view>
<view>高密度脂蛋白:{{(item.data_msg.highDensity/100).toFixed(2)}}</view> <view>高密度脂蛋白:{{(item.data_msg.highDensity/100).toFixed(2)}}</view>
<view>胆固醇{{(item.data_msg.lowDensity/100).toFixed(2)}} </view> <view>密度脂蛋白{{(item.data_msg.lowDensity/100).toFixed(2)}} </view>
</view> </view>
<view v-if="activeType == 'ECGData'" style="font-size: 24rpx;"> <view v-if="activeType == 'ECGData'" style="font-size: 24rpx;">
<view>心率:{{item.data_msg.meanHeartRate || item.data_msg.heartRate}} /</view> <view>心率:{{item.data_msg.meanHeartRate || item.data_msg.heartRate}} /</view>
@ -77,7 +77,7 @@
<detail_components :key_name="activeType" :item="item"></detail_components> <detail_components :key_name="activeType" :item="item"></detail_components>
</view> </view>
</view> </view>
<view class="" style="height: 30rpx;"></view> <view class="end">到底了</view>
</view> </view>
<ecg-info ref="popShow" :ecgData="ecgData"></ecg-info> <ecg-info ref="popShow" :ecgData="ecgData"></ecg-info>
@ -251,6 +251,7 @@
} }
} }
.content { .content {
margin: 0rpx 100rpx;
.over { .over {
margin: 0rpx 30rpx; margin: 0rpx 30rpx;
background-color: #fff; background-color: #fff;
@ -264,6 +265,7 @@
} }
.time { .time {
width: 100%; width: 100%;
margin-bottom: 100rpx;
} }
.list { .list {
background-color: #fff; background-color: #fff;

View File

@ -121,12 +121,14 @@
background-color: #fff; background-color: #fff;
border-radius: 40rpx; border-radius: 40rpx;
padding: 30rpx; padding: 30rpx;
margin: 20rpx; margin: 20rpx 50rpx 100rpx 50rpx;
} }
.cankao{ .cankao{
padding: 0rpx 100rpx;
.top_title{ .top_title{
padding-bottom: 20rpx; padding-bottom: 20rpx;
font-size: 36rpx;
font-weight: 800;
} }
.lt_title{ .lt_title{
padding:20rpx 60rpx; padding:20rpx 60rpx;
@ -140,7 +142,7 @@
} }
.ck_tb{ .ck_tb{
.tb_tt{ .tb_tt{
font-size: 24rpx; font-size: 30rpx;
} }
.zzt{ .zzt{
position: relative; position: relative;

View File

@ -16,50 +16,55 @@
</view> </view>
<view style="height: 40rpx;background-color: #fff;"></view> <view style="height: 40rpx;background-color: #fff;"></view>
<!-- 图表 --> <view class="page-view" v-if="this.pageData.data_msg">
<view class="charts"> <!-- 图表 -->
<l-echart ref="chartRef" @finished="init"></l-echart> <view class="charts">
</view> <l-echart ref="chartRef" @finished="init"></l-echart>
<overview v-if="dataConfig[pageData.type].overviewData" :overviewData="dataConfig[pageData.type].overviewData"></overview>
<cankao v-if="dataConfig[pageData.type].cankaoData" :cankaoData="dataConfig[pageData.type].cankaoData" ></cankao>
<view class="flx total_box" v-if="pageData.type == 'stepIndex'">
<view class="distance b1">
<view class="flx">
<view class="" style="font-size: 36rpx;font-weight: 600;">
{{ pageData.data_msg.distance/1000 }}
</view>
<view class="" style="font-size: 24rpx;margin-top: 10rpx;margin-left: 4rpx;font-weight: 300;">
公里
</view>
</view>
<view class="" style="font-size: 24rpx;color: #999;">
距离
</view>
<view class="flx" style="justify-content: end;">
<image src="../../static/image/juli.jpg" style="width: 200rpx;" mode="widthFix"></image>
</view>
</view> </view>
<view class="calorie b1">
<view class="flx"> <overview v-if="dataConfig[pageData.type].overviewData" :overviewData="dataConfig[pageData.type].overviewData"></overview>
<view class="" style="font-size: 36rpx;font-weight: 600;"> <cankao v-if="dataConfig[pageData.type].cankaoData" :cankaoData="dataConfig[pageData.type].cankaoData" ></cankao>
{{ pageData.data_msg.calorie / 10 }}
<view class="flx total_box" v-if="pageData.type == 'stepIndex' && pageData.data_msg">
<view class="distance b1">
<view class="flx">
<view class="" style="font-size: 48rpx;font-weight: 600;">
{{ pageData.data_msg.distance/1000 }}
</view>
<view class="sport-title" style="font-size: 34rpx;margin-top: 10rpx;margin-left: 4rpx;font-weight: 300;">
公里
</view>
</view> </view>
<view class="" style="font-size: 24rpx;margin-top: 10rpx;margin-left: 4rpx;font-weight: 300;"> <view class="sport-jvli" style="font-size: 40rpx;color: #999;">
千卡 距离
</view>
<view class="flx" style="justify-content: end;">
<image src="../../static/image/juli.jpg" style="width: 300rpx;" mode="widthFix"></image>
</view> </view>
</view> </view>
<view class="" style="font-size: 24rpx;color: #999;"> <view class="calorie b1">
卡路里 <view class="flx">
</view> <view class="" style="font-size: 48rpx;font-weight: 600;">
<view class="flx" style="justify-content: end;"> {{ pageData.data_msg.calorie / 10 }}
<image src="../../static/image/kalvli.jpg" style="width: 200rpx;" mode="widthFix"></image> </view>
<view class="" style="font-size: 34rpx;margin-top: 10rpx;margin-left: 4rpx;font-weight: 300;">
千卡
</view>
</view>
<view class="" style="font-size: 40rpx;color: #999;">
卡路里
</view>
<view class="flx" style="justify-content: end;">
<image src="../../static/image/kalvli.jpg" style="width: 300rpx;" mode="widthFix"></image>
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="end">
到底了
</view>
</view> </view>
</template> </template>
@ -117,7 +122,7 @@ import { mapGetters } from "vuex";
] ]
}, },
stepIndex:{ stepIndex:{
name:'每日动', name:'每日动',
color:"#29cf6f", color:"#29cf6f",
unit:'毫摩尔/升', unit:'毫摩尔/升',
}, },
@ -1097,11 +1102,13 @@ import { mapGetters } from "vuex";
} }
.total_box{ .total_box{
padding: 20rpx; height: 400rpx;
margin: 0rpx 100rpx;
justify-content: space-between;
padding-bottom: 80rpx;
.b1{ .b1{
width: 300rpx; width: 40%;
height: 250rpx; height: 200rpx;
padding: 20rpx;
border-radius: 20rpx; border-radius: 20rpx;
background-color: #fff; background-color: #fff;
margin-right: 20rpx; margin-right: 20rpx;
@ -1146,9 +1153,22 @@ import { mapGetters } from "vuex";
} }
.charts { .charts {
margin: 0rpx 100rpx;
border: 1rpx solid gray;
border-radius: 20px; border-radius: 20px;
padding: 20px 0px; padding: 20px 0px;
margin: 100rpx 50rpx 0rpx 50rpx;
}
.page-view {
border-radius: 20px;
margin: 0rpx 100rpx;
border: 1rpx solid gray;
}
.sport-title {
font-size: 50rpx;
}
.sport-jvli {
font-size: 50rpx;
} }
</style> </style>

View File

@ -20,7 +20,7 @@
<view class="btn"> <view class="btn">
<liu-data-select elementId="data-select3" :dataList="deviceList" @change="changeDev" bgColor="#fff" <liu-data-select elementId="data-select3" :dataList="deviceList" @change="changeDev" bgColor="#fff"
color="#000"> color="#000">
<view id="data-select3" class="btn-info1">{{name2? name2 : '选择设备'}}</view> <view id="data-select3" class="btn-info1">{{name2? '设备:' + name2 : '选择设备'}}</view>
</liu-data-select> </liu-data-select>
</view> </view>
<view class="btn" @click="outlogin"> <view class="btn" @click="outlogin">
@ -597,7 +597,7 @@
.row-time { .row-time {
position: absolute; position: absolute;
bottom: 30rpx; bottom: 30rpx;
right: 30rpx; left: 60rpx;
font-size: 28rpx; font-size: 28rpx;
color: grey; color: grey;
} }
@ -724,7 +724,6 @@
} }
.btn-info1 { .btn-info1 {
width: 300rpx;
border-radius: 12rpx; border-radius: 12rpx;
} }
.card { .card {

View File

@ -10,13 +10,13 @@
</view> </view>
</view> </view>
<view class="flx flx_sb flx_ac tb_content" v-for="(v,i) in overviewData.data" :key="i" style="margin-top: 40rpx;"> <view class="flx flx_sb flx_ac tb_content" v-for="(v,i) in overviewData.data" :key="i" style="margin-top: 40rpx;">
<view class="tb_val" style="font-size: 24rpx;"> <view class="tb_val" style="font-size: 30rpx;">
{{v.name}} {{v.name}}
</view> </view>
<view class="tb_val" :style="'border-radius: 40rpx;padding: 4rpx;font-size:24rpx;color:'+v.color + ';background-color:'+v.bgColor"> <view class="tb_val" :style="'border-radius: 40rpx;padding: 4rpx;font-size:30rpx;color:'+v.color + ';background-color:'+v.bgColor">
{{v.value}} {{v.value}}
</view> </view>
<view class="tb_val" :style="'font-size:24rpx;color:'+v.color"> <view class="tb_val" :style="'font-size:30rpx;color:'+v.color">
{{v.average}} {{v.average}}
</view> </view>
</view> </view>
@ -43,9 +43,15 @@
background-color: #fff; background-color: #fff;
border-radius: 40rpx; border-radius: 40rpx;
padding: 30rpx; padding: 30rpx;
margin: 20rpx; margin: 20rpx 100rpx 100rpx 100rpx;
} }
.top_title {
font-size: 36rpx;
font-weight: 800;
}
.over{ .over{
.tb_head{ .tb_head{
margin-top: 20rpx; margin-top: 20rpx;

View File

@ -44,10 +44,10 @@
<div id="AiButton"> <div id="AiButton">
<!-- 录制 --> <!-- 录制 -->
<div class="buttons startRec">开始</div> <div class="buttons startRec">点击说话</div>
<!-- 录制中 --> <!-- 录制中 -->
<div class="buttons runRec">暂停</div> <!-- <div class="buttons runRec">暂停</div> -->
<!-- 停止 --> <!-- 停止 -->
<div class="buttons endRec">停止</div> <div class="buttons endRec">停止</div>
@ -222,9 +222,9 @@
// 点击事件 // 点击事件
var startRec = document.getElementsByClassName('startRec')[0]; var startRec = document.getElementsByClassName('startRec')[0];
var runRec = document.getElementsByClassName('runRec')[0];
var endRec = document.getElementsByClassName('endRec')[0]; var endRec = document.getElementsByClassName('endRec')[0];
endRec.style.display = "none";
var token = null; var token = null;
let times = null; let times = null;
@ -283,7 +283,7 @@
// 监听识别结果的变化 // 监听识别结果的变化
voiceTxt.value = text; voiceTxt.value = text;
statusTxt.value = '正在听…'; statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭 // 3秒钟内没有说话就自动关闭
if (text) { if (text) {
clearTimeout(times); clearTimeout(times);
@ -291,6 +291,7 @@
times = setTimeout(() => { times = setTimeout(() => {
this.stop(); this.stop();
// voice.stop(); // voice.stop();
statusTxt.value = '正在说话';
const params = { msg: text }; const params = { msg: text };
@ -298,10 +299,13 @@
const result = parseHealthQuery(params.msg); const result = parseHealthQuery(params.msg);
if (result) { if (result) {
DetailDay(result.dataKey, result.date).then(res => { DetailDay(result.dataKey, result.date).then(res => {
// if (res?.data?.data) {
// speed(params.msg)
// return
// };
let TargetData = res.data.data; let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg); var QSindex = containsKeywordRegex(params.msg);
Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)},data_msg为值hour_minute为检测时间 #限制回复用户的内容中不要出现Null。#限制:回复不要带英文,要都转化成汉语。#限制监测结果为Null的数据不做分析回复。` Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)},data_msg为值hour_minute为检测时间 #限制回复用户的内容中不要出现Null。#限制:回复不要带英文,要都转化成汉语。#限制监测结果为Null的数据不做分析回复。`
/* /*
@ -351,6 +355,9 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
@ -361,7 +368,7 @@
replayVideoSegment(60, 120); replayVideoSegment(60, 120);
// 计算所需时间 // 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text); const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
// 开始倒计时 // 开始倒计时
var totalTime = speakingTime; var totalTime = speakingTime;
@ -370,6 +377,9 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -379,10 +389,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
endRec.style.opacity = 'none';
} }
}; };
xhr.send(data); xhr.send(data);
@ -431,12 +437,16 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
statusTxt.value = '正在说话';
startRec.style.display = "none";
endRec.style.display = "block";
// 字幕文字 // 字幕文字
voiceTxt.value = filterString(str.output.text, ['*', ' ']); voiceTxt.value = filterString(str.output.text, ['*', ' ']);
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
// 播放音频 // 播放音频
audioElement.play(); audioElement.play();
@ -444,8 +454,8 @@
replayVideoSegment(60, 120); replayVideoSegment(60, 120);
// 计算所需时间 // 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text); const speakingTime = calculateSpeakingTime(voiceTxt.value);
// 开始倒计时 // 开始倒计时
var totalTime = speakingTime; var totalTime = speakingTime;
var countdown = setInterval(function() { var countdown = setInterval(function() {
@ -453,6 +463,9 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -462,18 +475,12 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
endRec.style.opacity = 'none';
} }
}; };
xhr.send(data); xhr.send(data);
isCallbackExecuted = true; isCallbackExecuted = true;
return return
} }
statusTxt.value = '';
}, 3000); }, 3000);
} }
} }
@ -481,20 +488,20 @@
}); });
// 暂停 // 暂停
runRec.addEventListener("click", function() { // runRec.addEventListener("click", function() {
voiceTxt.value = ''; // voiceTxt.value = '';
voice.start(); // voice.start();
isCallbackExecuted = false; // isCallbackExecuted = false;
// 先静音即可处理解决(提前做交互) // // 先静音即可处理解决(提前做交互)
audioElement.muted = false; // audioElement.muted = false;
audioElement.pause(); // audioElement.pause();
startRec.style.display = 'none'; // startRec.style.display = 'none';
runRec.style.display = 'block'; // runRec.style.display = 'block';
endRec.style.display = 'none'; // endRec.style.display = 'none';
showModal() // showModal()
}); // });
// 开始识别 // 开始识别
@ -510,8 +517,8 @@
audioElement.currentTime = 0; audioElement.currentTime = 0;
startRec.style.display = 'none'; startRec.style.display = 'none';
runRec.style.display = 'block';
endRec.style.display = 'none'; endRec.style.display = 'none';
console.log(endRec.style)
showModal() showModal()
}); });
@ -520,7 +527,10 @@
endRec.addEventListener("click", function() { endRec.addEventListener("click", function() {
/**关闭识别**/ /**关闭识别**/
voiceTxt.value = ''; voiceTxt.value = '';
statusTxt.value = '';
voice.stop(); voice.stop();
// 音频 // 音频
audioElement.pause(); audioElement.pause();
audioElement.currentTime = 0; audioElement.currentTime = 0;
@ -530,8 +540,7 @@
isCallbackExecuted = false; isCallbackExecuted = false;
startRec.style.display = 'block'; startRec.style.display = 'block';
runRec.style.display = 'none'; endRec.style.display = 'none';
// endRec.style.opacity = 0;
hideModal() hideModal()
}); });
@ -547,7 +556,7 @@
function hideModal() { function hideModal() {
// overlay.style.display = 'none'; // overlay.style.display = 'none';
modal.style.display = 'none'; modal.style.display = 'none';
dialog.style.display = 'none'; dialog.style.display = 'none';
} }
// 查询详情数据 // 查询详情数据
@ -627,6 +636,7 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
console.log('计算结束')
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -636,9 +646,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
} }
// 防抖 // 防抖
@ -787,7 +794,7 @@
align-items: center; align-items: center;
justify-content: space-around; justify-content: space-around;
text-align: center; text-align: center;
margin-top: 30px; margin-bottom: 30px;
} }
#AiButton > img { #AiButton > img {
width: 120px; width: 120px;
@ -954,7 +961,7 @@
position: fixed; position: fixed;
bottom: 0px; bottom: 0px;
width: 100%; width: 100%;
background-color: #000; /* background-color: #000; */
} }
.voice-box { .voice-box {
width: 100%; width: 100%;

View File

@ -62,7 +62,7 @@
<view>总胆固醇{{(item.data_msg.cholesterol/100).toFixed(2)}} </view> <view>总胆固醇{{(item.data_msg.cholesterol/100).toFixed(2)}} </view>
<view>甘油三脂{{(item.data_msg.triacylglycerol/100).toFixed(2)}} </view> <view>甘油三脂{{(item.data_msg.triacylglycerol/100).toFixed(2)}} </view>
<view>高密度脂蛋白:{{(item.data_msg.highDensity/100).toFixed(2)}}</view> <view>高密度脂蛋白:{{(item.data_msg.highDensity/100).toFixed(2)}}</view>
<view>胆固醇{{(item.data_msg.lowDensity/100).toFixed(2)}} </view> <view>密度脂蛋白{{(item.data_msg.lowDensity/100).toFixed(2)}} </view>
</view> </view>
<view v-if="type == 'ECGData'" style="font-size: 24rpx;"> <view v-if="type == 'ECGData'" style="font-size: 24rpx;">
<view>心率:{{item.data_msg.meanHeartRate}} /</view> <view>心率:{{item.data_msg.meanHeartRate}} /</view>

View File

@ -117,7 +117,7 @@ import { mapGetters } from "vuex";
] ]
}, },
step:{ step:{
name:'每日动', name:'每日动',
color:"#29cf6f", color:"#29cf6f",
unit:'毫摩尔/升', unit:'毫摩尔/升',
}, },

View File

@ -273,7 +273,7 @@
height: 100vh; height: 100vh;
overflow: hidden; overflow: hidden;
background-color: #fff; background-color: #fff;
z-index: 99; z-index: 9999;
} }
.flex_data{ .flex_data{
display: flex; display: flex;

View File

@ -1,7 +1,7 @@
<template> <template>
<view> <view>
<!-- 返回 --> <!-- 返回 -->
<tm-nav-bar left-icon="arrow-left" title="登陆账号" @clickLeft="back" /> <tm-nav-bar left-icon="arrow-left" title="登陆账号" :rbgs="false" :width="`100%`"/>
<view class="login flx flx_jc"> <view class="login flx flx_jc">
<view class="flx flx_jc flx_ac" style="width:100%; height: 100vh;"> <view class="flx flx_jc flx_ac" style="width:100%; height: 100vh;">
<view class="content" style="height: 50vh"> <view class="content" style="height: 50vh">

View File

@ -74,3 +74,11 @@ $uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:26px; $uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色 $uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:15px; $uni-font-size-paragraph:15px;
.end {
text-align: center;
margin-top: 50rpx;
margin-bottom: 100rpx;
opacity: .5;
}

View File

@ -2,7 +2,7 @@
<view class="uni-navbar" :style="{zIndex: 999999}"> <view class="uni-navbar" :style="{zIndex: 999999}">
<!-- 顶部导航栏 --> <!-- 顶部导航栏 -->
<view class="tm-navbar__content" :class="{ 'tm-navbar--fixed': fixed}" <view class="tm-navbar__content" :class="{ 'tm-navbar--fixed': fixed}"
:style="{ height: height + 'px', color: titleColor, 'fontSize': fontSize + 'px', background: backgroundColor }"> :style="{ height: height + 'px', color: titleColor, 'fontSize': fontSize + 'px', background: backgroundColor, width: width }">
<!-- 背景图 --> <!-- 背景图 -->
<img class="tm-navbar__header-bg" v-if="backgroundType" :src="backgroundImgUrl" alt=""> <img class="tm-navbar__header-bg" v-if="backgroundType" :src="backgroundImgUrl" alt="">
<!-- 左侧图标按钮 --> <!-- 左侧图标按钮 -->
@ -22,11 +22,10 @@
<slot /> <slot />
</view> </view>
<!-- 右侧图标按钮 --> <!-- 右侧图标按钮 -->
<view @tap="onClickRight" class="tm-navbar__header-btns tm-navbar__header-btns-right"> <view @tap="onClickRight" class="tm-navbar__header-btns tm-navbar__header-btns-right" :style="rbgs? 'background-color: #000' : 'background-color: transparent'">
<uni-icons v-if="rightIcon.length" :color="rightColor" :type="rightIcon" :size="iconSize" /> <uni-icons v-if="rightIcon.length" :color="rightColor" :type="rightIcon" :size="iconSize" />
<text class="tm-navbar-btn-text" v-if="rightText.length" <text class="tm-navbar-btn-text" v-if="rightText.length" :style="{ color: rightColor, fontSize: fontSize + 'px' }">{{ rightText }}</text>
:style="{ color: rightColor, fontSize: fontSize + 'px' }">{{ rightText }}</text>
<slot name="right" /> <slot name="right" />
</view> </view>
</view> </view>
@ -56,6 +55,12 @@
return 54 return 54
// #endif // #endif
} }
},
width: {
type: String,
default () {
return '60%'
}
}, },
title: { title: {
type: String, type: String,
@ -90,8 +95,14 @@
leftColor: { leftColor: {
type: String, type: String,
default () { default () {
return '#333' return '#fff'
} }
},
rbgs: {
type: Boolean,
default () {
return true
}
}, },
rightText: { rightText: {
type: String, type: String,
@ -136,7 +147,7 @@
}, },
fixed: { fixed: {
type: [Boolean, String], type: [Boolean, String],
default: false default: true
}, },
statusBar: { statusBar: {
type: [Boolean, String], type: [Boolean, String],
@ -158,7 +169,10 @@
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.uni-navbar {
}
.tm-navbar__content { .tm-navbar__content {
width: 100%; width: 100%;
display: flex; display: flex;
@ -185,7 +199,7 @@
.tm-navbar__header-title { .tm-navbar__header-title {
text-align: center; text-align: center;
letter-spacing: 2upx; letter-spacing: 2upx;
font-size: 36rpx; font-size: 46rpx;
font-weight: 800; font-weight: 800;
} }
@ -195,14 +209,20 @@
min-width: 60upx; min-width: 60upx;
flex-shrink: 0; flex-shrink: 0;
display: flex; display: flex;
align-items: center; align-items: center;
background-color: #06193a;
color: #fff !important;
padding: 10rpx 20rpx;
border-radius: 20rpx;
&.tm-navbar__header-btns-left { &.tm-navbar__header-btns-left {
justify-content: flex-start; justify-content: flex-start;
color: #fff !important;
} }
.tm-navbar-btn-text { .tm-navbar-btn-text {
margin: 0 5rpx; margin: 0 5rpx;
color: #fff !important;
font-size: 30rpx !important;
} }
} }
} }
@ -210,6 +230,7 @@
.tm-navbar--fixed { .tm-navbar--fixed {
position: fixed; position: fixed;
z-index: 998; z-index: 998;
width: 60%;
} }
.tm-navbar__place {} .tm-navbar__place {}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,19 +38,25 @@
style="width: 100% height: 10px"> style="width: 100% height: 10px">
</audio> </audio>
<div class="status">
<input class="voice-input" type="search" name="voice" id="status-txt" style="pointer-events: none"/>
</div>
<div id="AiButton"> <div id="AiButton">
<!-- 录制 --> <!-- 录制 -->
<img class="startRec" src="https://img.agrimedia.cn/bmsc/apps/start-tuya.png"> <div class="buttons startRec">点击说话</div>
<!-- 录制中 --> <!-- 录制中 -->
<img class="runRec" src="https://img.agrimedia.cn/bmsc/apps/runnig-tuya.png"> <!-- <div class="buttons runRec">暂停</div> -->
<!-- 停止 --> <!-- 停止 -->
<img class="endRec" src="https://img.agrimedia.cn/bmsc/apps/end-tuya.png"> <div class="buttons endRec">停止</div>
</div> </div>
<!-- 讯飞测试 --> <!-- 讯飞测试 -->
<div style="opacity: 1"> <div class="voice">
<div class="voice-box"> <div class="voice-box scroll-text">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none"/> <input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none" value="我是您的健康助手, 请问您有什么帮助吗?"/>
</div> </div>
</div> </div>
</div> </div>
@ -216,9 +222,9 @@
// 点击事件 // 点击事件
var startRec = document.getElementsByClassName('startRec')[0]; var startRec = document.getElementsByClassName('startRec')[0];
var runRec = document.getElementsByClassName('runRec')[0];
var endRec = document.getElementsByClassName('endRec')[0]; var endRec = document.getElementsByClassName('endRec')[0];
endRec.style.display = "none";
var token = null; var token = null;
let times = null; let times = null;
@ -240,6 +246,7 @@
// 文本输入框 // 文本输入框
const statusTxt = document.querySelector('#status-txt');
const voiceTxt = document.querySelector('#voice-txt'); const voiceTxt = document.querySelector('#voice-txt');
// 防止多次请求 // 防止多次请求
@ -274,9 +281,9 @@
onTextChange: function (text) { onTextChange: function (text) {
// 监听识别结果的变化 // 监听识别结果的变化
console.log(text, '监听')
voiceTxt.value = text; voiceTxt.value = text;
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭 // 3秒钟内没有说话就自动关闭
if (text) { if (text) {
clearTimeout(times); clearTimeout(times);
@ -284,6 +291,7 @@
times = setTimeout(() => { times = setTimeout(() => {
this.stop(); this.stop();
// voice.stop(); // voice.stop();
statusTxt.value = '正在说话';
const params = { msg: text }; const params = { msg: text };
@ -291,10 +299,13 @@
const result = parseHealthQuery(params.msg); const result = parseHealthQuery(params.msg);
if (result) { if (result) {
DetailDay(result.dataKey, result.date).then(res => { DetailDay(result.dataKey, result.date).then(res => {
// if (res?.data?.data) {
// speed(params.msg)
// return
// };
let TargetData = res.data.data; let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg); var QSindex = containsKeywordRegex(params.msg);
Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)},data_msg为值hour_minute为检测时间 #限制回复用户的内容中不要出现Null。#限制:回复不要带英文,要都转化成汉语。#限制监测结果为Null的数据不做分析回复。` Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)},data_msg为值hour_minute为检测时间 #限制回复用户的内容中不要出现Null。#限制:回复不要带英文,要都转化成汉语。#限制监测结果为Null的数据不做分析回复。`
/* /*
@ -344,6 +355,9 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
@ -354,7 +368,7 @@
replayVideoSegment(60, 120); replayVideoSegment(60, 120);
// 计算所需时间 // 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text); const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
// 开始倒计时 // 开始倒计时
var totalTime = speakingTime; var totalTime = speakingTime;
@ -363,6 +377,9 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -372,10 +389,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
} }
}; };
xhr.send(data); xhr.send(data);
@ -424,9 +437,16 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
statusTxt.value = '正在说话';
startRec.style.display = "none";
endRec.style.display = "block";
// 字幕文字
voiceTxt.value = filterString(str.output.text, ['*', ' ']);
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
// 播放音频 // 播放音频
audioElement.play(); audioElement.play();
@ -434,8 +454,8 @@
replayVideoSegment(60, 120); replayVideoSegment(60, 120);
// 计算所需时间 // 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text); const speakingTime = calculateSpeakingTime(voiceTxt.value);
// 开始倒计时 // 开始倒计时
var totalTime = speakingTime; var totalTime = speakingTime;
var countdown = setInterval(function() { var countdown = setInterval(function() {
@ -443,6 +463,9 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -452,10 +475,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
} }
}; };
xhr.send(data); xhr.send(data);
@ -468,6 +487,22 @@
} }
}); });
// 暂停
// runRec.addEventListener("click", function() {
// voiceTxt.value = '';
// voice.start();
// isCallbackExecuted = false;
// // 先静音即可处理解决(提前做交互)
// audioElement.muted = false;
// audioElement.pause();
// startRec.style.display = 'none';
// runRec.style.display = 'block';
// endRec.style.display = 'none';
// showModal()
// });
// 开始识别 // 开始识别
startRec.addEventListener("click", function() { startRec.addEventListener("click", function() {
@ -482,8 +517,8 @@
audioElement.currentTime = 0; audioElement.currentTime = 0;
startRec.style.display = 'none'; startRec.style.display = 'none';
runRec.style.display = 'block'; endRec.style.display = 'none';
// endRec.style.opacity = 0; console.log(endRec.style)
showModal() showModal()
}); });
@ -492,7 +527,10 @@
endRec.addEventListener("click", function() { endRec.addEventListener("click", function() {
/**关闭识别**/ /**关闭识别**/
voiceTxt.value = ''; voiceTxt.value = '';
statusTxt.value = '';
voice.stop(); voice.stop();
// 音频 // 音频
audioElement.pause(); audioElement.pause();
audioElement.currentTime = 0; audioElement.currentTime = 0;
@ -502,8 +540,7 @@
isCallbackExecuted = false; isCallbackExecuted = false;
startRec.style.display = 'block'; startRec.style.display = 'block';
runRec.style.display = 'none'; endRec.style.display = 'none';
// endRec.style.opacity = 0;
hideModal() hideModal()
}); });
@ -519,7 +556,7 @@
function hideModal() { function hideModal() {
// overlay.style.display = 'none'; // overlay.style.display = 'none';
modal.style.display = 'none'; modal.style.display = 'none';
dialog.style.display = 'none'; dialog.style.display = 'none';
} }
// 查询详情数据 // 查询详情数据
@ -577,6 +614,9 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.value = str;
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
@ -596,6 +636,7 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
console.log('计算结束')
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -605,9 +646,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
} }
// 防抖 // 防抖
@ -649,7 +687,9 @@
// 个人信息 // 个人信息
function userInfo(user) { function userInfo(user) {
return `年龄${user.birthday}, 身高${user.height}, 体重${user.weight}` if (user) {
return `年龄${user.birthday}, 身高${user.height}, 体重${user.weight}`
}
} }
// 解析文字 // 解析文字
@ -696,8 +736,8 @@
dataKey: key, dataKey: key,
date: formattedDate date: formattedDate
}; };
} }
} }
// 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null // 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null
return null; return null;
@ -714,7 +754,7 @@
width: 100%; width: 100%;
height: 100vh; height: 100vh;
overflow: hidden; overflow: hidden;
background-image: url('https://img.agrimedia.cn/bmsc/index/ai-persion-bg-tuya.jpeg'); background-image: url('https://img.agrimedia.cn/bmsc/bg-cideo-tuya.png');
background-size: 100% 100%; background-size: 100% 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -727,7 +767,7 @@
width: 80%; width: 80%;
top: 10%; top: 10%;
height: auto; height: auto;
background-image: url('https://img.agrimedia.cn/bmsc/index/video-bg.png'); background-image: url('https://img.agrimedia.cn/bmsc/bg-cideo-tuya.png');
background-size: 100% 100%; background-size: 100% 100%;
margin: 0 auto; margin: 0 auto;
padding: 20px; padding: 20px;
@ -754,13 +794,27 @@
align-items: center; align-items: center;
justify-content: space-around; justify-content: space-around;
text-align: center; text-align: center;
margin-top: 30px; margin-bottom: 30px;
} }
#AiButton > img { #AiButton > img {
width: 120px; width: 120px;
height: 30px; height: 30px;
} }
.status > .btn {
text-align: center;
font-size: 30px;
color: #fff;
}
.buttons {
border: 2px solid #fff;
color: #fff;
font-size: 28px;
padding: 4px 20px;
border-radius: 5px;
}
/* 遮罩样式 */ /* 遮罩样式 */
.overlay { .overlay {
position: fixed; position: fixed;
@ -903,6 +957,27 @@
font-weight: 800; font-weight: 800;
} }
.voice {
position: fixed;
bottom: 0px;
width: 100%;
/* background-color: #000; */
}
.voice-box {
width: 100%;
animation: textRoll linear 10s infinite; // 文字滚动动画
white-space: nowrap; // 文字不换行
}
@keyframes textRoll {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(-100%);
}
}
</style> </style>
</body> </body>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,19 +38,25 @@
style="width: 100% height: 10px"> style="width: 100% height: 10px">
</audio> </audio>
<div class="status">
<input class="voice-input" type="search" name="voice" id="status-txt" style="pointer-events: none"/>
</div>
<div id="AiButton"> <div id="AiButton">
<!-- 录制 --> <!-- 录制 -->
<img class="startRec" src="https://img.agrimedia.cn/bmsc/apps/start-tuya.png"> <div class="buttons startRec">点击说话</div>
<!-- 录制中 --> <!-- 录制中 -->
<img class="runRec" src="https://img.agrimedia.cn/bmsc/apps/runnig-tuya.png"> <!-- <div class="buttons runRec">暂停</div> -->
<!-- 停止 --> <!-- 停止 -->
<img class="endRec" src="https://img.agrimedia.cn/bmsc/apps/end-tuya.png"> <div class="buttons endRec">停止</div>
</div> </div>
<!-- 讯飞测试 --> <!-- 讯飞测试 -->
<div style="opacity: 1"> <div class="voice">
<div class="voice-box"> <div class="voice-box scroll-text">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none"/> <input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none" value="我是您的健康助手, 请问您有什么帮助吗?"/>
</div> </div>
</div> </div>
</div> </div>
@ -216,9 +222,9 @@
// 点击事件 // 点击事件
var startRec = document.getElementsByClassName('startRec')[0]; var startRec = document.getElementsByClassName('startRec')[0];
var runRec = document.getElementsByClassName('runRec')[0];
var endRec = document.getElementsByClassName('endRec')[0]; var endRec = document.getElementsByClassName('endRec')[0];
endRec.style.display = "none";
var token = null; var token = null;
let times = null; let times = null;
@ -240,6 +246,7 @@
// 文本输入框 // 文本输入框
const statusTxt = document.querySelector('#status-txt');
const voiceTxt = document.querySelector('#voice-txt'); const voiceTxt = document.querySelector('#voice-txt');
// 防止多次请求 // 防止多次请求
@ -274,9 +281,9 @@
onTextChange: function (text) { onTextChange: function (text) {
// 监听识别结果的变化 // 监听识别结果的变化
console.log(text, '监听')
voiceTxt.value = text; voiceTxt.value = text;
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭 // 3秒钟内没有说话就自动关闭
if (text) { if (text) {
clearTimeout(times); clearTimeout(times);
@ -284,6 +291,7 @@
times = setTimeout(() => { times = setTimeout(() => {
this.stop(); this.stop();
// voice.stop(); // voice.stop();
statusTxt.value = '正在说话';
const params = { msg: text }; const params = { msg: text };
@ -291,10 +299,13 @@
const result = parseHealthQuery(params.msg); const result = parseHealthQuery(params.msg);
if (result) { if (result) {
DetailDay(result.dataKey, result.date).then(res => { DetailDay(result.dataKey, result.date).then(res => {
// if (res?.data?.data) {
// speed(params.msg)
// return
// };
let TargetData = res.data.data; let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg); var QSindex = containsKeywordRegex(params.msg);
Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)},data_msg为值hour_minute为检测时间 #限制回复用户的内容中不要出现Null。#限制:回复不要带英文,要都转化成汉语。#限制监测结果为Null的数据不做分析回复。` Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)},data_msg为值hour_minute为检测时间 #限制回复用户的内容中不要出现Null。#限制:回复不要带英文,要都转化成汉语。#限制监测结果为Null的数据不做分析回复。`
/* /*
@ -344,6 +355,9 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
@ -354,7 +368,7 @@
replayVideoSegment(60, 120); replayVideoSegment(60, 120);
// 计算所需时间 // 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text); const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
// 开始倒计时 // 开始倒计时
var totalTime = speakingTime; var totalTime = speakingTime;
@ -363,6 +377,9 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -372,10 +389,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
} }
}; };
xhr.send(data); xhr.send(data);
@ -424,9 +437,16 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
statusTxt.value = '正在说话';
startRec.style.display = "none";
endRec.style.display = "block";
// 字幕文字
voiceTxt.value = filterString(str.output.text, ['*', ' ']);
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
// 播放音频 // 播放音频
audioElement.play(); audioElement.play();
@ -434,8 +454,8 @@
replayVideoSegment(60, 120); replayVideoSegment(60, 120);
// 计算所需时间 // 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text); const speakingTime = calculateSpeakingTime(voiceTxt.value);
// 开始倒计时 // 开始倒计时
var totalTime = speakingTime; var totalTime = speakingTime;
var countdown = setInterval(function() { var countdown = setInterval(function() {
@ -443,6 +463,9 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -452,10 +475,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
} }
}; };
xhr.send(data); xhr.send(data);
@ -468,6 +487,22 @@
} }
}); });
// 暂停
// runRec.addEventListener("click", function() {
// voiceTxt.value = '';
// voice.start();
// isCallbackExecuted = false;
// // 先静音即可处理解决(提前做交互)
// audioElement.muted = false;
// audioElement.pause();
// startRec.style.display = 'none';
// runRec.style.display = 'block';
// endRec.style.display = 'none';
// showModal()
// });
// 开始识别 // 开始识别
startRec.addEventListener("click", function() { startRec.addEventListener("click", function() {
@ -482,8 +517,8 @@
audioElement.currentTime = 0; audioElement.currentTime = 0;
startRec.style.display = 'none'; startRec.style.display = 'none';
runRec.style.display = 'block'; endRec.style.display = 'none';
// endRec.style.opacity = 0; console.log(endRec.style)
showModal() showModal()
}); });
@ -492,7 +527,10 @@
endRec.addEventListener("click", function() { endRec.addEventListener("click", function() {
/**关闭识别**/ /**关闭识别**/
voiceTxt.value = ''; voiceTxt.value = '';
statusTxt.value = '';
voice.stop(); voice.stop();
// 音频 // 音频
audioElement.pause(); audioElement.pause();
audioElement.currentTime = 0; audioElement.currentTime = 0;
@ -502,8 +540,7 @@
isCallbackExecuted = false; isCallbackExecuted = false;
startRec.style.display = 'block'; startRec.style.display = 'block';
runRec.style.display = 'none'; endRec.style.display = 'none';
// endRec.style.opacity = 0;
hideModal() hideModal()
}); });
@ -519,7 +556,7 @@
function hideModal() { function hideModal() {
// overlay.style.display = 'none'; // overlay.style.display = 'none';
modal.style.display = 'none'; modal.style.display = 'none';
dialog.style.display = 'none'; dialog.style.display = 'none';
} }
// 查询详情数据 // 查询详情数据
@ -577,6 +614,9 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.value = str;
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
@ -596,6 +636,7 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
console.log('计算结束')
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -605,9 +646,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
} }
// 防抖 // 防抖
@ -649,7 +687,9 @@
// 个人信息 // 个人信息
function userInfo(user) { function userInfo(user) {
return `年龄${user.birthday}, 身高${user.height}, 体重${user.weight}` if (user) {
return `年龄${user.birthday}, 身高${user.height}, 体重${user.weight}`
}
} }
// 解析文字 // 解析文字
@ -696,8 +736,8 @@
dataKey: key, dataKey: key,
date: formattedDate date: formattedDate
}; };
} }
} }
// 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null // 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null
return null; return null;
@ -714,7 +754,7 @@
width: 100%; width: 100%;
height: 100vh; height: 100vh;
overflow: hidden; overflow: hidden;
background-image: url('https://img.agrimedia.cn/bmsc/index/ai-persion-bg-tuya.jpeg'); background-image: url('https://img.agrimedia.cn/bmsc/bg-cideo-tuya.png');
background-size: 100% 100%; background-size: 100% 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -727,7 +767,7 @@
width: 80%; width: 80%;
top: 10%; top: 10%;
height: auto; height: auto;
background-image: url('https://img.agrimedia.cn/bmsc/index/video-bg.png'); background-image: url('https://img.agrimedia.cn/bmsc/bg-cideo-tuya.png');
background-size: 100% 100%; background-size: 100% 100%;
margin: 0 auto; margin: 0 auto;
padding: 20px; padding: 20px;
@ -754,13 +794,27 @@
align-items: center; align-items: center;
justify-content: space-around; justify-content: space-around;
text-align: center; text-align: center;
margin-top: 30px; margin-bottom: 30px;
} }
#AiButton > img { #AiButton > img {
width: 120px; width: 120px;
height: 30px; height: 30px;
} }
.status > .btn {
text-align: center;
font-size: 30px;
color: #fff;
}
.buttons {
border: 2px solid #fff;
color: #fff;
font-size: 28px;
padding: 4px 20px;
border-radius: 5px;
}
/* 遮罩样式 */ /* 遮罩样式 */
.overlay { .overlay {
position: fixed; position: fixed;
@ -903,6 +957,27 @@
font-weight: 800; font-weight: 800;
} }
.voice {
position: fixed;
bottom: 0px;
width: 100%;
/* background-color: #000; */
}
.voice-box {
width: 100%;
animation: textRoll linear 10s infinite; // 文字滚动动画
white-space: nowrap; // 文字不换行
}
@keyframes textRoll {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(-100%);
}
}
</style> </style>
</body> </body>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,19 +38,25 @@
style="width: 100% height: 10px"> style="width: 100% height: 10px">
</audio> </audio>
<div class="status">
<input class="voice-input" type="search" name="voice" id="status-txt" style="pointer-events: none"/>
</div>
<div id="AiButton"> <div id="AiButton">
<!-- 录制 --> <!-- 录制 -->
<img class="startRec" src="https://img.agrimedia.cn/bmsc/apps/start-tuya.png"> <div class="buttons startRec">点击说话</div>
<!-- 录制中 --> <!-- 录制中 -->
<img class="runRec" src="https://img.agrimedia.cn/bmsc/apps/runnig-tuya.png"> <!-- <div class="buttons runRec">暂停</div> -->
<!-- 停止 --> <!-- 停止 -->
<img class="endRec" src="https://img.agrimedia.cn/bmsc/apps/end-tuya.png"> <div class="buttons endRec">停止</div>
</div> </div>
<!-- 讯飞测试 --> <!-- 讯飞测试 -->
<div style="opacity: 1"> <div class="voice">
<div class="voice-box"> <div class="voice-box scroll-text">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none"/> <input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none" value="我是您的健康助手, 请问您有什么帮助吗?"/>
</div> </div>
</div> </div>
</div> </div>
@ -216,9 +222,9 @@
// 点击事件 // 点击事件
var startRec = document.getElementsByClassName('startRec')[0]; var startRec = document.getElementsByClassName('startRec')[0];
var runRec = document.getElementsByClassName('runRec')[0];
var endRec = document.getElementsByClassName('endRec')[0]; var endRec = document.getElementsByClassName('endRec')[0];
endRec.style.display = "none";
var token = null; var token = null;
let times = null; let times = null;
@ -240,6 +246,7 @@
// 文本输入框 // 文本输入框
const statusTxt = document.querySelector('#status-txt');
const voiceTxt = document.querySelector('#voice-txt'); const voiceTxt = document.querySelector('#voice-txt');
// 防止多次请求 // 防止多次请求
@ -274,9 +281,9 @@
onTextChange: function (text) { onTextChange: function (text) {
// 监听识别结果的变化 // 监听识别结果的变化
console.log(text, '监听')
voiceTxt.value = text; voiceTxt.value = text;
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭 // 3秒钟内没有说话就自动关闭
if (text) { if (text) {
clearTimeout(times); clearTimeout(times);
@ -284,6 +291,7 @@
times = setTimeout(() => { times = setTimeout(() => {
this.stop(); this.stop();
// voice.stop(); // voice.stop();
statusTxt.value = '正在说话';
const params = { msg: text }; const params = { msg: text };
@ -291,10 +299,13 @@
const result = parseHealthQuery(params.msg); const result = parseHealthQuery(params.msg);
if (result) { if (result) {
DetailDay(result.dataKey, result.date).then(res => { DetailDay(result.dataKey, result.date).then(res => {
// if (res?.data?.data) {
// speed(params.msg)
// return
// };
let TargetData = res.data.data; let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg); var QSindex = containsKeywordRegex(params.msg);
Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)},data_msg为值hour_minute为检测时间 #限制回复用户的内容中不要出现Null。#限制:回复不要带英文,要都转化成汉语。#限制监测结果为Null的数据不做分析回复。` Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)},data_msg为值hour_minute为检测时间 #限制回复用户的内容中不要出现Null。#限制:回复不要带英文,要都转化成汉语。#限制监测结果为Null的数据不做分析回复。`
/* /*
@ -344,6 +355,9 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
@ -354,7 +368,7 @@
replayVideoSegment(60, 120); replayVideoSegment(60, 120);
// 计算所需时间 // 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text); const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
// 开始倒计时 // 开始倒计时
var totalTime = speakingTime; var totalTime = speakingTime;
@ -363,6 +377,9 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -372,10 +389,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
} }
}; };
xhr.send(data); xhr.send(data);
@ -424,9 +437,16 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
statusTxt.value = '正在说话';
startRec.style.display = "none";
endRec.style.display = "block";
// 字幕文字
voiceTxt.value = filterString(str.output.text, ['*', ' ']);
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
// 播放音频 // 播放音频
audioElement.play(); audioElement.play();
@ -434,8 +454,8 @@
replayVideoSegment(60, 120); replayVideoSegment(60, 120);
// 计算所需时间 // 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text); const speakingTime = calculateSpeakingTime(voiceTxt.value);
// 开始倒计时 // 开始倒计时
var totalTime = speakingTime; var totalTime = speakingTime;
var countdown = setInterval(function() { var countdown = setInterval(function() {
@ -443,6 +463,9 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -452,10 +475,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
} }
}; };
xhr.send(data); xhr.send(data);
@ -468,6 +487,22 @@
} }
}); });
// 暂停
// runRec.addEventListener("click", function() {
// voiceTxt.value = '';
// voice.start();
// isCallbackExecuted = false;
// // 先静音即可处理解决(提前做交互)
// audioElement.muted = false;
// audioElement.pause();
// startRec.style.display = 'none';
// runRec.style.display = 'block';
// endRec.style.display = 'none';
// showModal()
// });
// 开始识别 // 开始识别
startRec.addEventListener("click", function() { startRec.addEventListener("click", function() {
@ -482,8 +517,8 @@
audioElement.currentTime = 0; audioElement.currentTime = 0;
startRec.style.display = 'none'; startRec.style.display = 'none';
runRec.style.display = 'block'; endRec.style.display = 'none';
// endRec.style.opacity = 0; console.log(endRec.style)
showModal() showModal()
}); });
@ -492,7 +527,10 @@
endRec.addEventListener("click", function() { endRec.addEventListener("click", function() {
/**关闭识别**/ /**关闭识别**/
voiceTxt.value = ''; voiceTxt.value = '';
statusTxt.value = '';
voice.stop(); voice.stop();
// 音频 // 音频
audioElement.pause(); audioElement.pause();
audioElement.currentTime = 0; audioElement.currentTime = 0;
@ -502,8 +540,7 @@
isCallbackExecuted = false; isCallbackExecuted = false;
startRec.style.display = 'block'; startRec.style.display = 'block';
runRec.style.display = 'none'; endRec.style.display = 'none';
// endRec.style.opacity = 0;
hideModal() hideModal()
}); });
@ -519,7 +556,7 @@
function hideModal() { function hideModal() {
// overlay.style.display = 'none'; // overlay.style.display = 'none';
modal.style.display = 'none'; modal.style.display = 'none';
dialog.style.display = 'none'; dialog.style.display = 'none';
} }
// 查询详情数据 // 查询详情数据
@ -577,6 +614,9 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' }); const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.value = str;
// 设置音频源 // 设置音频源
audioElement.src = blobUrl; audioElement.src = blobUrl;
@ -596,6 +636,7 @@
totalTime --; totalTime --;
if (totalTime <= 0) { if (totalTime <= 0) {
// 停止倒计时 // 停止倒计时
console.log('计算结束')
clearInterval(countdown); clearInterval(countdown);
replayVideoSegment(0, 60); replayVideoSegment(0, 60);
} }
@ -605,9 +646,6 @@
}).catch(e => { }).catch(e => {
hideModal(); hideModal();
}); });
startRec.style.display = 'block';
runRec.style.display = 'none';
} }
// 防抖 // 防抖
@ -649,7 +687,9 @@
// 个人信息 // 个人信息
function userInfo(user) { function userInfo(user) {
return `年龄${user.birthday}, 身高${user.height}, 体重${user.weight}` if (user) {
return `年龄${user.birthday}, 身高${user.height}, 体重${user.weight}`
}
} }
// 解析文字 // 解析文字
@ -696,8 +736,8 @@
dataKey: key, dataKey: key,
date: formattedDate date: formattedDate
}; };
} }
} }
// 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null // 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null
return null; return null;
@ -714,7 +754,7 @@
width: 100%; width: 100%;
height: 100vh; height: 100vh;
overflow: hidden; overflow: hidden;
background-image: url('https://img.agrimedia.cn/bmsc/index/ai-persion-bg-tuya.jpeg'); background-image: url('https://img.agrimedia.cn/bmsc/bg-cideo-tuya.png');
background-size: 100% 100%; background-size: 100% 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -727,7 +767,7 @@
width: 80%; width: 80%;
top: 10%; top: 10%;
height: auto; height: auto;
background-image: url('https://img.agrimedia.cn/bmsc/index/video-bg.png'); background-image: url('https://img.agrimedia.cn/bmsc/bg-cideo-tuya.png');
background-size: 100% 100%; background-size: 100% 100%;
margin: 0 auto; margin: 0 auto;
padding: 20px; padding: 20px;
@ -754,13 +794,27 @@
align-items: center; align-items: center;
justify-content: space-around; justify-content: space-around;
text-align: center; text-align: center;
margin-top: 30px; margin-bottom: 30px;
} }
#AiButton > img { #AiButton > img {
width: 120px; width: 120px;
height: 30px; height: 30px;
} }
.status > .btn {
text-align: center;
font-size: 30px;
color: #fff;
}
.buttons {
border: 2px solid #fff;
color: #fff;
font-size: 28px;
padding: 4px 20px;
border-radius: 5px;
}
/* 遮罩样式 */ /* 遮罩样式 */
.overlay { .overlay {
position: fixed; position: fixed;
@ -903,6 +957,27 @@
font-weight: 800; font-weight: 800;
} }
.voice {
position: fixed;
bottom: 0px;
width: 100%;
/* background-color: #000; */
}
.voice-box {
width: 100%;
animation: textRoll linear 10s infinite; // 文字滚动动画
white-space: nowrap; // 文字不换行
}
@keyframes textRoll {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(-100%);
}
}
</style> </style>
</body> </body>

Binary file not shown.