fix: 修复部分问题

This commit is contained in:
white 2024-10-10 14:42:54 +08:00
parent 268f21aa3d
commit d06b55535b
15 changed files with 160 additions and 119 deletions

View File

@ -77,7 +77,7 @@
<detail_components :key_name="activeType" :item="item"></detail_components>
</view>
</view>
<view class="end">到底了</view>
<view class="end">到底了~</view>
</view>
<ecg-info ref="popShow" :ecgData="ecgData"></ecg-info>

View File

@ -147,7 +147,7 @@
.zzt{
position: relative;
padding: 20rpx 0;
width: 60%;
width: 70%;
.xnz{
width: 8rpx;
height: 20rpx;

View File

@ -63,7 +63,7 @@
</view>
</view>
<view class="end">
到底了
到底了~
</view>
</view>
</template>

View File

@ -73,7 +73,7 @@
</view>
</view>
</view>
<view class="time" style="width: 100%; text-align: right; padding-bottom: 0rpx">
<view class="time" style="width: 100%; text-align: right; padding-bottom: 0rpx; text-align: left;">
{{dataListsNew.SleepDatas.data_msg? dataListsNew.SleepDatas.device_real_time + '更新' : '--'}}
</view>
<view class="bg">

View File

@ -77,7 +77,7 @@
}
</script>
<script>
var Items = ['血糖', '睡眠', '血氧', '血压', '尿酸', '梅拖', '心率', '体温', '心电图', '身体成份', '运动', '血脂'];
var Items = ['血糖', '睡眠', '血氧', '血压', '尿酸', '梅拖', '心率', '体温', '心电图', '身体成份', '运动', '血脂', '血液成分'];
var Question = '';
function getURLParameter(name) {
@ -294,11 +294,11 @@
voiceTxt.innerText = text;
marquee("marquee", "voice-txt");
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭
if (text) {
statusTxt.value = '正在听…';
clearTimeout(times);
if (!isCallbackExecuted) {
times = setTimeout(() => {
this.stop();
@ -309,10 +309,12 @@
// 判断关键字是否存在
const result = parseHealthQuery(params.msg);
console.log(result, '判断关键字是否存在')
if (result) {
DetailDay(result.dataKey, result.date).then(res => {
let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg);
if (result.dataKey == 'ECGData') {
TargetData.map(item => {
delete item.data_msg.wavefrom;
@ -321,7 +323,8 @@
}
Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)}, #提示data_msg为值hour_minute为检测时间。#提示:“[]”表示数据为空,请在小程序上传数据。#限制:回复不要带英文,要都转化成汉语。#限制回复内容控制在150字。#限制:忽略“压力指数、疲劳指数、心肌炎风险、冠心病风险和动脉硬化”等数据。`
console.log(Question, '=========================')
console.log(Question, '=========================');
/*
* 调用接口 传递关键信息 文字转语音
@ -335,15 +338,17 @@
var data = JSON.stringify({
"messages": [
{"role": "system", "content": Question},
{"role": "user", "content": `请问我${Items[QSindex]}正常吗`}
{"role": "user", "content": `请问我${params.msg}正常吗`}
]
})
});
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
const chunk = xhr.responseText;
const str = extractStopEvent(chunk);
statusTxt.value = '正在说话';
/*
* 微软接口识别
*/
@ -401,10 +406,10 @@
statusTxt.value = '';
voiceTxt.innerText = '';
clearInterval(countdown);
voice.stop();
replayVideoSegment(0, 60);
}
}, 1000);
hideModal()
}).catch(e => {
hideModal();
@ -431,6 +436,8 @@
const chunk = xhr.responseText;
const str = extractStopEvent(chunk);
statusTxt.value = '正在说话';
/*
* 微软接口识别
*/
@ -457,7 +464,6 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
statusTxt.value = '正在说话';
startRec.style.display = "none";
endRec.style.display = "block";
@ -489,6 +495,7 @@
statusTxt.value = '';
voiceTxt.innerText = '';
clearInterval(countdown);
voice.stop();
replayVideoSegment(0, 60);
}
}, 1000);
@ -509,25 +516,19 @@
}
});
// 暂停
// 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() {
startShibie();
});
// 关闭识别
endRec.addEventListener("click", function() {
closeShibie();
});
function startShibie() {
/**开始识别**/
voiceTxt.innerText = '';
voice.start();
@ -541,11 +542,9 @@
startRec.style.display = 'none';
endRec.style.display = 'none';
showModal()
});
}
// 关闭识别
endRec.addEventListener("click", function() {
function closeShibie() {
/**关闭识别**/
voiceTxt.innerText = '';
statusTxt.value = '';
@ -563,19 +562,17 @@
startRec.style.display = 'block';
endRec.style.display = 'none';
hideModal()
});
}
// 显示弹窗和遮罩
function showModal() {
// overlay.style.display = 'block';
modal.style.display = 'block';
dialog.style.display = 'block';
}
// 隐藏弹窗和遮罩
function hideModal() {
// overlay.style.display = 'none';
modal.style.display = 'none';
dialog.style.display = 'none';
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -65,7 +65,6 @@
var scrollWidth = document.getElementById(p).offsetWidth;
var textWidth = document.getElementById(s).offsetWidth;
var i = scrollWidth;
console.log(scrollWidth, textWidth);
function change() {
i--;
if (i < -textWidth) {
@ -309,7 +308,7 @@
// 判断关键字是否存在
const result = parseHealthQuery(params.msg);
console.log(result, '判断关键字是否存在')
if (result) {
DetailDay(result.dataKey, result.date).then(res => {
let TargetData = res.data.data;
@ -541,7 +540,6 @@
startRec.style.display = 'none';
endRec.style.display = 'none';
console.log(endRec.style)
showModal()
});
@ -659,7 +657,10 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
console.log('计算结束')
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -723,12 +724,16 @@
SleepDatas: "睡眠",
bloodOxygen: "血氧",
bloodPressure: '血压',
bloodLiquid: "血脂",
meiTuo: '梅脱',
pulseReat: '心率',
bodyTemperature: '体温',
ECGData: '心电图',
bodyData: '身体成分',
bloodLiquid: {
'血脂': true,
'血液成分': true,
'尿酸': true
},
bodyData: '身体成分',
stepIndex: '运动'
};
}
@ -749,18 +754,36 @@
targetDate.setDate(day - 2);
}
// 格式化日期为 YYYY-MM-DD
const formattedDate = `${targetDate.getFullYear()}-${('0' + targetDate.getMonth()).slice(-2)}-${('0' + targetDate.getDate()).slice(-2)}`;
// 查找匹配的数据项键
for (let key in demoData) {
if (query.includes(demoData[key])) {
return {
dataKey: key,
date: formattedDate
};
}
}
// 创建一个辅助函数来检查 bloodLiquid 对象是否包含查询字符串
function isBloodLiquidMatch(bloodLiquidData, query) {
for (let value in bloodLiquidData) {
if (value.includes(query)) {
return true;
}
}
return false;
}
// 在查询逻辑中使用这个辅助函数
for (let key in demoData) {
if (typeof demoData[key] === 'object' && key === 'bloodLiquid') {
if (isBloodLiquidMatch(demoData[key], query)) {
const formattedDate = new Date().toISOString().split('T')[0];
return {
dataKey: key,
date: formattedDate
};
}
} else if (typeof demoData[key] === 'string' && demoData[key].includes(query)) {
const formattedDate = new Date().toISOString().split('T')[0];
return {
dataKey: key,
date: formattedDate
};
}
}
// 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null
return null;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -65,7 +65,6 @@
var scrollWidth = document.getElementById(p).offsetWidth;
var textWidth = document.getElementById(s).offsetWidth;
var i = scrollWidth;
console.log(scrollWidth, textWidth);
function change() {
i--;
if (i < -textWidth) {
@ -309,7 +308,7 @@
// 判断关键字是否存在
const result = parseHealthQuery(params.msg);
console.log(result, '判断关键字是否存在')
if (result) {
DetailDay(result.dataKey, result.date).then(res => {
let TargetData = res.data.data;
@ -541,7 +540,6 @@
startRec.style.display = 'none';
endRec.style.display = 'none';
console.log(endRec.style)
showModal()
});
@ -659,7 +657,10 @@
totalTime --;
if (totalTime <= 0) {
// 停止倒计时
console.log('计算结束')
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
clearInterval(countdown);
replayVideoSegment(0, 60);
}
@ -723,12 +724,16 @@
SleepDatas: "睡眠",
bloodOxygen: "血氧",
bloodPressure: '血压',
bloodLiquid: "血脂",
meiTuo: '梅脱',
pulseReat: '心率',
bodyTemperature: '体温',
ECGData: '心电图',
bodyData: '身体成分',
bloodLiquid: {
'血脂': true,
'血液成分': true,
'尿酸': true
},
bodyData: '身体成分',
stepIndex: '运动'
};
}
@ -749,18 +754,36 @@
targetDate.setDate(day - 2);
}
// 格式化日期为 YYYY-MM-DD
const formattedDate = `${targetDate.getFullYear()}-${('0' + targetDate.getMonth()).slice(-2)}-${('0' + targetDate.getDate()).slice(-2)}`;
// 查找匹配的数据项键
for (let key in demoData) {
if (query.includes(demoData[key])) {
return {
dataKey: key,
date: formattedDate
};
}
}
// 创建一个辅助函数来检查 bloodLiquid 对象是否包含查询字符串
function isBloodLiquidMatch(bloodLiquidData, query) {
for (let value in bloodLiquidData) {
if (value.includes(query)) {
return true;
}
}
return false;
}
// 在查询逻辑中使用这个辅助函数
for (let key in demoData) {
if (typeof demoData[key] === 'object' && key === 'bloodLiquid') {
if (isBloodLiquidMatch(demoData[key], query)) {
const formattedDate = new Date().toISOString().split('T')[0];
return {
dataKey: key,
date: formattedDate
};
}
} else if (typeof demoData[key] === 'string' && demoData[key].includes(query)) {
const formattedDate = new Date().toISOString().split('T')[0];
return {
dataKey: key,
date: formattedDate
};
}
}
// 如果没有找到匹配的数据项则返回null或错误信息这里选择返回null
return null;

File diff suppressed because one or more lines are too long

View File

@ -3802,7 +3802,7 @@ var render = function () {
staticClass: _vm._$g(43, "sc"),
staticStyle: {
width: "100%",
"text-align": "right",
"text-align": "left",
"padding-bottom": "0rpx",
},
attrs: { _i: 43 },
@ -8181,7 +8181,7 @@ var render = function () {
1
),
_c("uni-view", { staticClass: _vm._$g(28, "sc"), attrs: { _i: 28 } }, [
_vm._v("到底了"),
_vm._v("到底了~"),
]),
],
1
@ -9401,7 +9401,7 @@ var render = function () {
_c(
"uni-view",
{ staticClass: _vm._$g(39, "sc"), attrs: { _i: 39 } },
[_vm._v("到底了")]
[_vm._v("到底了~")]
),
],
2

View File

@ -77,7 +77,7 @@
}
</script>
<script>
var Items = ['血糖', '睡眠', '血氧', '血压', '尿酸', '梅拖', '心率', '体温', '心电图', '身体成份', '运动', '血脂'];
var Items = ['血糖', '睡眠', '血氧', '血压', '尿酸', '梅拖', '心率', '体温', '心电图', '身体成份', '运动', '血脂', '血液成分'];
var Question = '';
function getURLParameter(name) {
@ -294,11 +294,11 @@
voiceTxt.innerText = text;
marquee("marquee", "voice-txt");
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭
if (text) {
statusTxt.value = '正在听…';
clearTimeout(times);
if (!isCallbackExecuted) {
times = setTimeout(() => {
this.stop();
@ -309,10 +309,12 @@
// 判断关键字是否存在
const result = parseHealthQuery(params.msg);
console.log(result, '判断关键字是否存在')
if (result) {
DetailDay(result.dataKey, result.date).then(res => {
let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg);
if (result.dataKey == 'ECGData') {
TargetData.map(item => {
delete item.data_msg.wavefrom;
@ -321,7 +323,8 @@
}
Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)}, #提示data_msg为值hour_minute为检测时间。#提示:“[]”表示数据为空,请在小程序上传数据。#限制:回复不要带英文,要都转化成汉语。#限制回复内容控制在150字。#限制:忽略“压力指数、疲劳指数、心肌炎风险、冠心病风险和动脉硬化”等数据。`
console.log(Question, '=========================')
console.log(Question, '=========================');
/*
* 调用接口 传递关键信息 文字转语音
@ -335,15 +338,18 @@
var data = JSON.stringify({
"messages": [
{"role": "system", "content": Question},
{"role": "user", "content": `请问我${Items[QSindex]}正常吗`}
{"role": "user", "content": `请问我${params.msg}正常吗`}
]
})
console.log(data, '问题问题问题问题问题问题问题问题')
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
const chunk = xhr.responseText;
const str = extractStopEvent(chunk);
statusTxt.value = '正在说话';
/*
* 微软接口识别
*/
@ -401,10 +407,10 @@
statusTxt.value = '';
voiceTxt.innerText = '';
clearInterval(countdown);
voice.stop();
replayVideoSegment(0, 60);
}
}, 1000);
hideModal()
}).catch(e => {
hideModal();
@ -431,6 +437,8 @@
const chunk = xhr.responseText;
const str = extractStopEvent(chunk);
statusTxt.value = '正在说话';
/*
* 微软接口识别
*/
@ -457,7 +465,6 @@
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
statusTxt.value = '正在说话';
startRec.style.display = "none";
endRec.style.display = "block";
@ -489,6 +496,7 @@
statusTxt.value = '';
voiceTxt.innerText = '';
clearInterval(countdown);
voice.stop();
replayVideoSegment(0, 60);
}
}, 1000);
@ -509,25 +517,19 @@
}
});
// 暂停
// 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() {
startShibie();
});
// 关闭识别
endRec.addEventListener("click", function() {
closeShibie();
});
function startShibie() {
/**开始识别**/
voiceTxt.innerText = '';
voice.start();
@ -541,11 +543,9 @@
startRec.style.display = 'none';
endRec.style.display = 'none';
showModal()
});
}
// 关闭识别
endRec.addEventListener("click", function() {
function closeShibie() {
/**关闭识别**/
voiceTxt.innerText = '';
statusTxt.value = '';
@ -563,19 +563,17 @@
startRec.style.display = 'block';
endRec.style.display = 'none';
hideModal()
});
}
// 显示弹窗和遮罩
function showModal() {
// overlay.style.display = 'block';
modal.style.display = 'block';
dialog.style.display = 'block';
}
// 隐藏弹窗和遮罩
function hideModal() {
// overlay.style.display = 'none';
modal.style.display = 'none';
dialog.style.display = 'none';
}