fix: 进入设备默认选择

This commit is contained in:
white 2024-10-14 11:52:09 +08:00
parent a631f1df48
commit a53ecc126c
9 changed files with 147 additions and 261 deletions

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">{{Activedevice? '设备:' + Activedevice : '选择设备'}}</view>
</liu-data-select>
</view>
<view class="btn" @click="outlogin">
@ -317,6 +317,9 @@
},
dataListsNew: {
default: []
},
Activedevice: {
default: ''
}
},
data() {
@ -343,6 +346,9 @@
},
mounted() {
this.name2 = this.getActiceDevice.device_id
setTimeout((
console.log(this.name2, '子子子子子子子子子子子子子子')
), 3000)
},
onLoad() {
/*
@ -388,6 +394,7 @@
methods: {
getArrMaxValue,
onRefresh(pageNo, pageSize) {
console.log('手选')
this.$store.dispatch('api/getIndexData', {
device_id: this.getActiceDevice.device_id ,
need_arr :[

View File

@ -16,7 +16,7 @@
<view class="content">
<!-- 首页数据 -->
<view class="content-wrap" v-if="Sindex == 1">
<homeData :dataListsNew="dataListsNew" :deviceList="deviceList" @deviceGet="deviceGet" @pageDetail="pageDetail"></homeData>
<homeData :dataListsNew="dataListsNew" :deviceList="deviceList" :Activedevice="Activedevice" @deviceGet="deviceGet" @pageDetail="pageDetail"></homeData>
</view>
<!-- 图表 -->
@ -89,7 +89,7 @@
name1: '',
name2: '',
deviceList: [],
Activedevice: '',
urlLink: '',
activeType: '', //
@ -160,8 +160,34 @@
methods: {
getArrMaxValue,
onRefresh(pageNo, pageSize) {
//
this.$store.dispatch('api/getBindUserDeviceId').then(res => {
this.deviceList = res;
//
if (!this.getActiceDevice.device_id) {
if (this.deviceList.length) {
this.name2 = this.deviceList[0].device_id;
this.$store.commit('api/setActiceDevice', this.deviceList[0]);
//
this.$store.dispatch('api/getUserInfo', { device_id: this.deviceList[0].device_id }).then(res => {
this.$store.commit('api/setUserInfo', res);
this.Activedevice = this.deviceList[0].device_id;
this.IndexData(this.deviceList[0].device_id);
});
};
} else {
this.IndexData(this.getActiceDevice.device_id);
this.Activedevice = this.getActiceDevice.device_id;
};
});
},
//
IndexData(device_id) {
this.$store.dispatch('api/getIndexData', {
device_id: this.getActiceDevice.device_id ,
device_id: device_id,
need_arr :[
'pulseReat',
'bloodOxygen',
@ -181,10 +207,6 @@
this.dataListsNew[res[i].name] = this.getNameByKey(res[i].type)
}
//
// this.dataListsNew.bodyData = JSON.parse(JSON.stringify(this.dataListsNew.bloodLiquid));
// this.dataListsNew.bodyData.type = 'bodyData';
console.log(this.dataListsNew)
if (this.dataListsNew.ECGData.data_msg) {
//
delete this.dataListsNew.ECGData.data_msg.wavefrom;
@ -194,12 +216,7 @@
this.urlLink = `/hybrid/html/ai.html?data=${JSON.stringify(this.dataListsNew)}&user=${JSON.stringify(this.getUserInfo)}&token=${store.getters['api/getApiToken']}&deviceId=${this.getActiceDevice.device_id}`;
this.loading = false;
}
);
this.$store.dispatch('api/getBindUserDeviceId').then(res => {
this.deviceList = res;
});
},
mkHourMin(min){

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -167,24 +167,6 @@
<!-- 讯飞语音识别 -->
<script>
window.onload = function () {
var demoData = {
bloodGlucose: "血糖",
SleepDatas: "睡眠",
bloodOxygen: "血氧",
bloodPressure: '血压',
meiTuo: '梅脱',
pulseReat: '心率',
bodyTemperature: '体温',
ECGData: '心电图',
bloodLiquid: '血液',
bloodLiquid: '血脂',
bloodLiquid: '尿酸',
bodyData: '身体成分',
stepIndex: '运动',
stepIndex: '步数',
stepIndex: '运动步数',
};
var videoElement = document.getElementById('myVideo');
var startTime = 5; // 开始时间(以秒为单位)
var endTime = 10; // 结束时间(以秒为单位)
@ -274,7 +256,8 @@
let exampleData = JSON.parse(getURLParameter('data'));
for (let i = 0; i < exampleData.length; i++) {
exampleData[i].name = demoData[exampleData[i].type]
}
};
// 过滤掉非对象类型的值
const filteredData = Object.entries(exampleData).filter(([key, value]) => typeof value === 'object');
@ -284,7 +267,6 @@
...value
}));
/*
* 实例化迅飞语音听写流式版WebAPI
*/
@ -312,13 +294,10 @@
const params = { msg: text };
// 判断关键字是否存在
console.log('判断')
const result = parseHealthQuery(params.msg);
isCallbackExecuted = true;
console.log(result, '判断关键字是否存在')
if (result) {
console.log(result.dataKey, result.date, '参数++++++++++++++++++++++++++++++++++++++++')
DetailDay(result.dataKey, result.date).then(res => {
let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg);
@ -388,38 +367,10 @@
</voice>
</speak> `,
}).then(async(response) => {
const content_bytes = await response.arrayBuffer();
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 字幕文字
voiceTxt.innerText = filterString(str.output.text, ['*', ' ']);
marquee("marquee", "voice-txt");
// 设置音频源
audioElement.src = blobUrl;
// 播放音频
audioElement.play();
// 循环视频
replayVideoSegment(60, 120);
// 监听播放技术
myAudio.addEventListener('ended', function() {
console.log('音频播放已结束!');
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
voice.stop();
replayVideoSegment(0, 60);
hideModal()
});
NextPlayVideo(response, filterString(str.output.text, ['*', ' ']));
}).catch(e => {
hideModal();
});
@ -469,38 +420,10 @@
</voice>
</speak> `,
}).then(async(response) => {
const content_bytes = await response.arrayBuffer();
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 字幕文字
voiceTxt.innerText = filterString(str.output.text, ['*', ' ']);
marquee("marquee", "voice-txt");
// 设置音频源
audioElement.src = blobUrl;
// 播放音频
audioElement.play();
// 循环视频
replayVideoSegment(60, 120);
// 监听播放技术
myAudio.addEventListener('ended', function() {
console.log('音频播放已结束!');
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
voice.stop();
replayVideoSegment(0, 60);
hideModal()
});
NextPlayVideo(response, filterString(str.output.text, ['*', ' ']));
}).catch(e => {
hideModal();
});
@ -609,6 +532,7 @@
// 语音输出
function speed(str) {
console.log(str)
fetch("https://eastasia.tts.speech.microsoft.com/cognitiveservices/v1", {
method: 'POST',
headers: {
@ -628,39 +552,46 @@
</voice>
</speak> `,
}).then(async(response) => {
const content_bytes = await response.arrayBuffer();
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.innerText = str;
// 设置音频源
audioElement.src = blobUrl;
// 播放音频
audioElement.play();
// 循环视频
replayVideoSegment(60, 120);
// 监听播放技术
myAudio.addEventListener('ended', function() {
console.log('音频播放已结束!');
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
voice.stop();
replayVideoSegment(0, 60);
hideModal()
});
NextPlayVideo(response, str);
}).catch(e => {
hideModal();
});
}
// 字幕播放视频等操作
async function NextPlayVideo(response, str) {
const content_bytes = await response.arrayBuffer();
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.innerText = str;
marquee("marquee", "voice-txt");
// 设置音频源
audioElement.src = blobUrl;
// 播放音频
audioElement.play();
// 循环视频
replayVideoSegment(60, 120);
// 监听播放技术
myAudio.addEventListener('ended', function() {
console.log('音频播放已结束!');
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
voice.stop();
replayVideoSegment(0, 60);
hideModal()
});
}
// 防抖
function throttle(fn, wait) {
let lastTime = 0; // 上一次调用的时间
@ -690,6 +621,7 @@
}
}
// 拿到的数据移除*
function filterString(str, charsToRemove) {
// 这里的正则表达式是通过将charsToRemove数组中的字符转换为字符类character class来构建的
// 例如如果charsToRemove是['*', ' '],则正则表达式将是/[* ]/g
@ -705,7 +637,6 @@
}
}
// 解析文字
function parseHealthQuery(query, demoData) {
if (!demoData) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -167,24 +167,6 @@
<!-- 讯飞语音识别 -->
<script>
window.onload = function () {
var demoData = {
bloodGlucose: "血糖",
SleepDatas: "睡眠",
bloodOxygen: "血氧",
bloodPressure: '血压',
meiTuo: '梅脱',
pulseReat: '心率',
bodyTemperature: '体温',
ECGData: '心电图',
bloodLiquid: '血液',
bloodLiquid: '血脂',
bloodLiquid: '尿酸',
bodyData: '身体成分',
stepIndex: '运动',
stepIndex: '步数',
stepIndex: '运动步数',
};
var videoElement = document.getElementById('myVideo');
var startTime = 5; // 开始时间(以秒为单位)
var endTime = 10; // 结束时间(以秒为单位)
@ -274,7 +256,8 @@
let exampleData = JSON.parse(getURLParameter('data'));
for (let i = 0; i < exampleData.length; i++) {
exampleData[i].name = demoData[exampleData[i].type]
}
};
// 过滤掉非对象类型的值
const filteredData = Object.entries(exampleData).filter(([key, value]) => typeof value === 'object');
@ -284,7 +267,6 @@
...value
}));
/*
* 实例化迅飞语音听写流式版WebAPI
*/
@ -312,13 +294,10 @@
const params = { msg: text };
// 判断关键字是否存在
console.log('判断')
const result = parseHealthQuery(params.msg);
isCallbackExecuted = true;
console.log(result, '判断关键字是否存在')
if (result) {
console.log(result.dataKey, result.date, '参数++++++++++++++++++++++++++++++++++++++++')
DetailDay(result.dataKey, result.date).then(res => {
let TargetData = res.data.data;
var QSindex = containsKeywordRegex(params.msg);
@ -388,38 +367,10 @@
</voice>
</speak> `,
}).then(async(response) => {
const content_bytes = await response.arrayBuffer();
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 字幕文字
voiceTxt.innerText = filterString(str.output.text, ['*', ' ']);
marquee("marquee", "voice-txt");
// 设置音频源
audioElement.src = blobUrl;
// 播放音频
audioElement.play();
// 循环视频
replayVideoSegment(60, 120);
// 监听播放技术
myAudio.addEventListener('ended', function() {
console.log('音频播放已结束!');
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
voice.stop();
replayVideoSegment(0, 60);
hideModal()
});
NextPlayVideo(response, filterString(str.output.text, ['*', ' ']));
}).catch(e => {
hideModal();
});
@ -469,38 +420,10 @@
</voice>
</speak> `,
}).then(async(response) => {
const content_bytes = await response.arrayBuffer();
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
startRec.style.display = "none";
endRec.style.display = "block";
// 字幕文字
voiceTxt.innerText = filterString(str.output.text, ['*', ' ']);
marquee("marquee", "voice-txt");
// 设置音频源
audioElement.src = blobUrl;
// 播放音频
audioElement.play();
// 循环视频
replayVideoSegment(60, 120);
// 监听播放技术
myAudio.addEventListener('ended', function() {
console.log('音频播放已结束!');
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
voice.stop();
replayVideoSegment(0, 60);
hideModal()
});
NextPlayVideo(response, filterString(str.output.text, ['*', ' ']));
}).catch(e => {
hideModal();
});
@ -609,6 +532,7 @@
// 语音输出
function speed(str) {
console.log(str)
fetch("https://eastasia.tts.speech.microsoft.com/cognitiveservices/v1", {
method: 'POST',
headers: {
@ -628,39 +552,46 @@
</voice>
</speak> `,
}).then(async(response) => {
const content_bytes = await response.arrayBuffer();
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.innerText = str;
// 设置音频源
audioElement.src = blobUrl;
// 播放音频
audioElement.play();
// 循环视频
replayVideoSegment(60, 120);
// 监听播放技术
myAudio.addEventListener('ended', function() {
console.log('音频播放已结束!');
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
voice.stop();
replayVideoSegment(0, 60);
hideModal()
});
NextPlayVideo(response, str);
}).catch(e => {
hideModal();
});
}
// 字幕播放视频等操作
async function NextPlayVideo(response, str) {
const content_bytes = await response.arrayBuffer();
const blob = new Blob([content_bytes], { type: 'audio/mp3' });
const blobUrl = URL.createObjectURL(blob);
// 字幕文字
voiceTxt.innerText = str;
marquee("marquee", "voice-txt");
// 设置音频源
audioElement.src = blobUrl;
// 播放音频
audioElement.play();
// 循环视频
replayVideoSegment(60, 120);
// 监听播放技术
myAudio.addEventListener('ended', function() {
console.log('音频播放已结束!');
// 停止倒计时
startRec.style.display = 'block';
endRec.style.display = 'none';
statusTxt.value = '';
voiceTxt.innerText = '';
voice.stop();
replayVideoSegment(0, 60);
hideModal()
});
}
// 防抖
function throttle(fn, wait) {
let lastTime = 0; // 上一次调用的时间
@ -690,6 +621,7 @@
}
}
// 拿到的数据移除*
function filterString(str, charsToRemove) {
// 这里的正则表达式是通过将charsToRemove数组中的字符转换为字符类character class来构建的
// 例如如果charsToRemove是['*', ' '],则正则表达式将是/[* ]/g
@ -705,7 +637,6 @@
}
}
// 解析文字
function parseHealthQuery(query, demoData) {
if (!demoData) {