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>
<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="over" style="margin-top: 30rpx" @click="flag = !flag">
<text>日期筛选</text>
@ -56,7 +56,7 @@
<view>总胆固醇{{(item.data_msg.cholesterol/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.lowDensity/100).toFixed(2)}} </view>
<view>密度脂蛋白{{(item.data_msg.lowDensity/100).toFixed(2)}} </view>
</view>
<view v-if="activeType == 'ECGData'" style="font-size: 24rpx;">
<view>心率:{{item.data_msg.meanHeartRate || item.data_msg.heartRate}} /</view>
@ -77,7 +77,7 @@
<detail_components :key_name="activeType" :item="item"></detail_components>
</view>
</view>
<view class="" style="height: 30rpx;"></view>
<view class="end">到底了</view>
</view>
<ecg-info ref="popShow" :ecgData="ecgData"></ecg-info>
@ -251,6 +251,7 @@
}
}
.content {
margin: 0rpx 100rpx;
.over {
margin: 0rpx 30rpx;
background-color: #fff;
@ -264,6 +265,7 @@
}
.time {
width: 100%;
margin-bottom: 100rpx;
}
.list {
background-color: #fff;

View File

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

View File

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

View File

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

View File

@ -10,13 +10,13 @@
</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="tb_val" style="font-size: 24rpx;">
<view class="tb_val" style="font-size: 30rpx;">
{{v.name}}
</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}}
</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}}
</view>
</view>
@ -43,9 +43,15 @@
background-color: #fff;
border-radius: 40rpx;
padding: 30rpx;
margin: 20rpx;
margin: 20rpx 100rpx 100rpx 100rpx;
}
.top_title {
font-size: 36rpx;
font-weight: 800;
}
.over{
.tb_head{
margin-top: 20rpx;

View File

@ -44,10 +44,10 @@
<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>
@ -222,9 +222,9 @@
// 点击事件
var startRec = document.getElementsByClassName('startRec')[0];
var runRec = document.getElementsByClassName('runRec')[0];
var endRec = document.getElementsByClassName('endRec')[0];
endRec.style.display = "none";
var token = null;
let times = null;
@ -283,7 +283,7 @@
// 监听识别结果的变化
voiceTxt.value = text;
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭
if (text) {
clearTimeout(times);
@ -291,6 +291,7 @@
times = setTimeout(() => {
this.stop();
// voice.stop();
statusTxt.value = '正在说话';
const params = { msg: text };
@ -298,10 +299,13 @@
const result = parseHealthQuery(params.msg);
if (result) {
DetailDay(result.dataKey, result.date).then(res => {
// if (res?.data?.data) {
// speed(params.msg)
// return
// };
let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg);
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 blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 设置音频源
audioElement.src = blobUrl;
@ -361,7 +368,7 @@
replayVideoSegment(60, 120);
// 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
// 开始倒计时
var totalTime = speakingTime;
@ -370,6 +377,9 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -379,10 +389,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
endRec.style.opacity = 'none';
}
};
xhr.send(data);
@ -431,12 +437,16 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
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.play();
@ -444,8 +454,8 @@
replayVideoSegment(60, 120);
// 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
const speakingTime = calculateSpeakingTime(voiceTxt.value);
// 开始倒计时
var totalTime = speakingTime;
var countdown = setInterval(function() {
@ -453,6 +463,9 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -462,18 +475,12 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
endRec.style.opacity = 'none';
}
};
xhr.send(data);
isCallbackExecuted = true;
return
}
statusTxt.value = '';
}, 3000);
}
}
@ -481,20 +488,20 @@
});
// 暂停
runRec.addEventListener("click", function() {
voiceTxt.value = '';
voice.start();
isCallbackExecuted = false;
// runRec.addEventListener("click", function() {
// voiceTxt.value = '';
// voice.start();
// isCallbackExecuted = false;
// 先静音即可处理解决(提前做交互)
audioElement.muted = false;
audioElement.pause();
// // 先静音即可处理解决(提前做交互)
// audioElement.muted = false;
// audioElement.pause();
startRec.style.display = 'none';
runRec.style.display = 'block';
endRec.style.display = 'none';
showModal()
});
// startRec.style.display = 'none';
// runRec.style.display = 'block';
// endRec.style.display = 'none';
// showModal()
// });
// 开始识别
@ -510,8 +517,8 @@
audioElement.currentTime = 0;
startRec.style.display = 'none';
runRec.style.display = 'block';
endRec.style.display = 'none';
console.log(endRec.style)
showModal()
});
@ -520,7 +527,10 @@
endRec.addEventListener("click", function() {
/**关闭识别**/
voiceTxt.value = '';
statusTxt.value = '';
voice.stop();
// 音频
audioElement.pause();
audioElement.currentTime = 0;
@ -530,8 +540,7 @@
isCallbackExecuted = false;
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
endRec.style.display = 'none';
hideModal()
});
@ -547,7 +556,7 @@
function hideModal() {
// overlay.style.display = 'none';
modal.style.display = 'none';
dialog.style.display = 'none';
dialog.style.display = 'none';
}
// 查询详情数据
@ -627,6 +636,7 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
console.log('计算结束')
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -636,9 +646,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
}
// 防抖
@ -787,7 +794,7 @@
align-items: center;
justify-content: space-around;
text-align: center;
margin-top: 30px;
margin-bottom: 30px;
}
#AiButton > img {
width: 120px;
@ -954,7 +961,7 @@
position: fixed;
bottom: 0px;
width: 100%;
background-color: #000;
/* background-color: #000; */
}
.voice-box {
width: 100%;

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
<template>
<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="flx flx_jc flx_ac" style="width:100%; height: 100vh;">
<view class="content" style="height: 50vh">

View File

@ -74,3 +74,11 @@ $uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色
$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="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="">
<!-- 左侧图标按钮 -->
@ -22,11 +22,10 @@
<slot />
</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" />
<text class="tm-navbar-btn-text" v-if="rightText.length"
:style="{ color: rightColor, fontSize: fontSize + 'px' }">{{ rightText }}</text>
<text class="tm-navbar-btn-text" v-if="rightText.length" :style="{ color: rightColor, fontSize: fontSize + 'px' }">{{ rightText }}</text>
<slot name="right" />
</view>
</view>
@ -56,6 +55,12 @@
return 54
// #endif
}
},
width: {
type: String,
default () {
return '60%'
}
},
title: {
type: String,
@ -90,8 +95,14 @@
leftColor: {
type: String,
default () {
return '#333'
return '#fff'
}
},
rbgs: {
type: Boolean,
default () {
return true
}
},
rightText: {
type: String,
@ -136,7 +147,7 @@
},
fixed: {
type: [Boolean, String],
default: false
default: true
},
statusBar: {
type: [Boolean, String],
@ -158,7 +169,10 @@
}
</script>
<style lang="scss">
<style lang="scss">
.uni-navbar {
}
.tm-navbar__content {
width: 100%;
display: flex;
@ -185,7 +199,7 @@
.tm-navbar__header-title {
text-align: center;
letter-spacing: 2upx;
font-size: 36rpx;
font-size: 46rpx;
font-weight: 800;
}
@ -195,14 +209,20 @@
min-width: 60upx;
flex-shrink: 0;
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 {
justify-content: flex-start;
justify-content: flex-start;
color: #fff !important;
}
.tm-navbar-btn-text {
margin: 0 5rpx;
margin: 0 5rpx;
color: #fff !important;
font-size: 30rpx !important;
}
}
}
@ -210,6 +230,7 @@
.tm-navbar--fixed {
position: fixed;
z-index: 998;
width: 60%;
}
.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">
</audio>
<div class="status">
<input class="voice-input" type="search" name="voice" id="status-txt" style="pointer-events: none"/>
</div>
<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 style="opacity: 1">
<div class="voice-box">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none"/>
<div class="voice">
<div class="voice-box scroll-text">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none" value="我是您的健康助手, 请问您有什么帮助吗?"/>
</div>
</div>
</div>
@ -216,9 +222,9 @@
// 点击事件
var startRec = document.getElementsByClassName('startRec')[0];
var runRec = document.getElementsByClassName('runRec')[0];
var endRec = document.getElementsByClassName('endRec')[0];
endRec.style.display = "none";
var token = null;
let times = null;
@ -240,6 +246,7 @@
// 文本输入框
const statusTxt = document.querySelector('#status-txt');
const voiceTxt = document.querySelector('#voice-txt');
// 防止多次请求
@ -274,9 +281,9 @@
onTextChange: function (text) {
// 监听识别结果的变化
console.log(text, '监听')
voiceTxt.value = text;
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭
if (text) {
clearTimeout(times);
@ -284,6 +291,7 @@
times = setTimeout(() => {
this.stop();
// voice.stop();
statusTxt.value = '正在说话';
const params = { msg: text };
@ -291,10 +299,13 @@
const result = parseHealthQuery(params.msg);
if (result) {
DetailDay(result.dataKey, result.date).then(res => {
// if (res?.data?.data) {
// speed(params.msg)
// return
// };
let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg);
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 blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 设置音频源
audioElement.src = blobUrl;
@ -354,7 +368,7 @@
replayVideoSegment(60, 120);
// 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
// 开始倒计时
var totalTime = speakingTime;
@ -363,6 +377,9 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -372,10 +389,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
}
};
xhr.send(data);
@ -424,9 +437,16 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
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.play();
@ -434,8 +454,8 @@
replayVideoSegment(60, 120);
// 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
const speakingTime = calculateSpeakingTime(voiceTxt.value);
// 开始倒计时
var totalTime = speakingTime;
var countdown = setInterval(function() {
@ -443,6 +463,9 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -452,10 +475,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
}
};
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() {
@ -482,8 +517,8 @@
audioElement.currentTime = 0;
startRec.style.display = 'none';
runRec.style.display = 'block';
// endRec.style.opacity = 0;
endRec.style.display = 'none';
console.log(endRec.style)
showModal()
});
@ -492,7 +527,10 @@
endRec.addEventListener("click", function() {
/**关闭识别**/
voiceTxt.value = '';
statusTxt.value = '';
voice.stop();
// 音频
audioElement.pause();
audioElement.currentTime = 0;
@ -502,8 +540,7 @@
isCallbackExecuted = false;
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
endRec.style.display = 'none';
hideModal()
});
@ -519,7 +556,7 @@
function hideModal() {
// overlay.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 blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.value = str;
// 设置音频源
audioElement.src = blobUrl;
@ -596,6 +636,7 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
console.log('计算结束')
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -605,9 +646,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
}
// 防抖
@ -649,7 +687,9 @@
// 个人信息
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,
date: formattedDate
};
}
}
}
}
// 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null
return null;
@ -714,7 +754,7 @@
width: 100%;
height: 100vh;
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%;
display: flex;
flex-direction: column;
@ -727,7 +767,7 @@
width: 80%;
top: 10%;
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%;
margin: 0 auto;
padding: 20px;
@ -754,13 +794,27 @@
align-items: center;
justify-content: space-around;
text-align: center;
margin-top: 30px;
margin-bottom: 30px;
}
#AiButton > img {
width: 120px;
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 {
position: fixed;
@ -903,6 +957,27 @@
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>
</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">
</audio>
<div class="status">
<input class="voice-input" type="search" name="voice" id="status-txt" style="pointer-events: none"/>
</div>
<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 style="opacity: 1">
<div class="voice-box">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none"/>
<div class="voice">
<div class="voice-box scroll-text">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none" value="我是您的健康助手, 请问您有什么帮助吗?"/>
</div>
</div>
</div>
@ -216,9 +222,9 @@
// 点击事件
var startRec = document.getElementsByClassName('startRec')[0];
var runRec = document.getElementsByClassName('runRec')[0];
var endRec = document.getElementsByClassName('endRec')[0];
endRec.style.display = "none";
var token = null;
let times = null;
@ -240,6 +246,7 @@
// 文本输入框
const statusTxt = document.querySelector('#status-txt');
const voiceTxt = document.querySelector('#voice-txt');
// 防止多次请求
@ -274,9 +281,9 @@
onTextChange: function (text) {
// 监听识别结果的变化
console.log(text, '监听')
voiceTxt.value = text;
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭
if (text) {
clearTimeout(times);
@ -284,6 +291,7 @@
times = setTimeout(() => {
this.stop();
// voice.stop();
statusTxt.value = '正在说话';
const params = { msg: text };
@ -291,10 +299,13 @@
const result = parseHealthQuery(params.msg);
if (result) {
DetailDay(result.dataKey, result.date).then(res => {
// if (res?.data?.data) {
// speed(params.msg)
// return
// };
let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg);
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 blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 设置音频源
audioElement.src = blobUrl;
@ -354,7 +368,7 @@
replayVideoSegment(60, 120);
// 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
// 开始倒计时
var totalTime = speakingTime;
@ -363,6 +377,9 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -372,10 +389,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
}
};
xhr.send(data);
@ -424,9 +437,16 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
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.play();
@ -434,8 +454,8 @@
replayVideoSegment(60, 120);
// 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
const speakingTime = calculateSpeakingTime(voiceTxt.value);
// 开始倒计时
var totalTime = speakingTime;
var countdown = setInterval(function() {
@ -443,6 +463,9 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -452,10 +475,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
}
};
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() {
@ -482,8 +517,8 @@
audioElement.currentTime = 0;
startRec.style.display = 'none';
runRec.style.display = 'block';
// endRec.style.opacity = 0;
endRec.style.display = 'none';
console.log(endRec.style)
showModal()
});
@ -492,7 +527,10 @@
endRec.addEventListener("click", function() {
/**关闭识别**/
voiceTxt.value = '';
statusTxt.value = '';
voice.stop();
// 音频
audioElement.pause();
audioElement.currentTime = 0;
@ -502,8 +540,7 @@
isCallbackExecuted = false;
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
endRec.style.display = 'none';
hideModal()
});
@ -519,7 +556,7 @@
function hideModal() {
// overlay.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 blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.value = str;
// 设置音频源
audioElement.src = blobUrl;
@ -596,6 +636,7 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
console.log('计算结束')
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -605,9 +646,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
}
// 防抖
@ -649,7 +687,9 @@
// 个人信息
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,
date: formattedDate
};
}
}
}
}
// 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null
return null;
@ -714,7 +754,7 @@
width: 100%;
height: 100vh;
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%;
display: flex;
flex-direction: column;
@ -727,7 +767,7 @@
width: 80%;
top: 10%;
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%;
margin: 0 auto;
padding: 20px;
@ -754,13 +794,27 @@
align-items: center;
justify-content: space-around;
text-align: center;
margin-top: 30px;
margin-bottom: 30px;
}
#AiButton > img {
width: 120px;
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 {
position: fixed;
@ -903,6 +957,27 @@
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>
</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">
</audio>
<div class="status">
<input class="voice-input" type="search" name="voice" id="status-txt" style="pointer-events: none"/>
</div>
<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 style="opacity: 1">
<div class="voice-box">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none"/>
<div class="voice">
<div class="voice-box scroll-text">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none" value="我是您的健康助手, 请问您有什么帮助吗?"/>
</div>
</div>
</div>
@ -216,9 +222,9 @@
// 点击事件
var startRec = document.getElementsByClassName('startRec')[0];
var runRec = document.getElementsByClassName('runRec')[0];
var endRec = document.getElementsByClassName('endRec')[0];
endRec.style.display = "none";
var token = null;
let times = null;
@ -240,6 +246,7 @@
// 文本输入框
const statusTxt = document.querySelector('#status-txt');
const voiceTxt = document.querySelector('#voice-txt');
// 防止多次请求
@ -274,9 +281,9 @@
onTextChange: function (text) {
// 监听识别结果的变化
console.log(text, '监听')
voiceTxt.value = text;
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭
if (text) {
clearTimeout(times);
@ -284,6 +291,7 @@
times = setTimeout(() => {
this.stop();
// voice.stop();
statusTxt.value = '正在说话';
const params = { msg: text };
@ -291,10 +299,13 @@
const result = parseHealthQuery(params.msg);
if (result) {
DetailDay(result.dataKey, result.date).then(res => {
// if (res?.data?.data) {
// speed(params.msg)
// return
// };
let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg);
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 blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 设置音频源
audioElement.src = blobUrl;
@ -354,7 +368,7 @@
replayVideoSegment(60, 120);
// 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
const speakingTime = calculateSpeakingTime(filterString(str.output.text, ['*', ' ']));
// 开始倒计时
var totalTime = speakingTime;
@ -363,6 +377,9 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -372,10 +389,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
}
};
xhr.send(data);
@ -424,9 +437,16 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
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.play();
@ -434,8 +454,8 @@
replayVideoSegment(60, 120);
// 计算所需时间
const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
const speakingTime = calculateSpeakingTime(voiceTxt.value);
// 开始倒计时
var totalTime = speakingTime;
var countdown = setInterval(function() {
@ -443,6 +463,9 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -452,10 +475,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
}
};
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() {
@ -482,8 +517,8 @@
audioElement.currentTime = 0;
startRec.style.display = 'none';
runRec.style.display = 'block';
// endRec.style.opacity = 0;
endRec.style.display = 'none';
console.log(endRec.style)
showModal()
});
@ -492,7 +527,10 @@
endRec.addEventListener("click", function() {
/**关闭识别**/
voiceTxt.value = '';
statusTxt.value = '';
voice.stop();
// 音频
audioElement.pause();
audioElement.currentTime = 0;
@ -502,8 +540,7 @@
isCallbackExecuted = false;
startRec.style.display = 'block';
runRec.style.display = 'none';
// endRec.style.opacity = 0;
endRec.style.display = 'none';
hideModal()
});
@ -519,7 +556,7 @@
function hideModal() {
// overlay.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 blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.value = str;
// 设置音频源
audioElement.src = blobUrl;
@ -596,6 +636,7 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
console.log('计算结束')
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -605,9 +646,6 @@
}).catch(e => {
hideModal();
});
startRec.style.display = 'block';
runRec.style.display = 'none';
}
// 防抖
@ -649,7 +687,9 @@
// 个人信息
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,
date: formattedDate
};
}
}
}
}
// 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null
return null;
@ -714,7 +754,7 @@
width: 100%;
height: 100vh;
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%;
display: flex;
flex-direction: column;
@ -727,7 +767,7 @@
width: 80%;
top: 10%;
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%;
margin: 0 auto;
padding: 20px;
@ -754,13 +794,27 @@
align-items: center;
justify-content: space-around;
text-align: center;
margin-top: 30px;
margin-bottom: 30px;
}
#AiButton > img {
width: 120px;
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 {
position: fixed;
@ -903,6 +957,27 @@
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>
</body>

Binary file not shown.