fix: 修复部分bug
This commit is contained in:
parent
e544d38952
commit
268f21aa3d
|
|
@ -547,8 +547,9 @@
|
||||||
.pops {
|
.pops {
|
||||||
border: 1rpx solid gray;
|
border: 1rpx solid gray;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
margin: 50rpx;
|
margin: 50rpx 200rpx;
|
||||||
margin-top: 100rpx;
|
margin-top: 100rpx;
|
||||||
|
padding: 0rpx 50rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.box1 {
|
.box1 {
|
||||||
|
|
|
||||||
|
|
@ -370,12 +370,13 @@ import { mapGetters } from "vuex";
|
||||||
type: Object
|
type: Object
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
mounted() {
|
||||||
this.type = pageData.type;
|
this.pageData.type = this.getpageType;
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
getActiceDevice: "api/getActiceDevice"
|
getActiceDevice: "api/getActiceDevice",
|
||||||
|
getpageType: "api/getpageType",
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -387,9 +388,10 @@ import { mapGetters } from "vuex";
|
||||||
async getDataList(){
|
async getDataList(){
|
||||||
let type = this.pageData.type
|
let type = this.pageData.type
|
||||||
|
|
||||||
if(type == 'bloodLiquidAll'){
|
if(type == 'bloodLiquidAll') {
|
||||||
type = 'bloodLiquid'
|
type = 'bloodLiquid'
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = await this.$store.dispatch('api/getDeviceListDays', {
|
let res = await this.$store.dispatch('api/getDeviceListDays', {
|
||||||
type: type,
|
type: type,
|
||||||
device_real_time: this.time,
|
device_real_time: this.time,
|
||||||
|
|
|
||||||
|
|
@ -442,6 +442,7 @@
|
||||||
},
|
},
|
||||||
toPageCom(val) {
|
toPageCom(val) {
|
||||||
this.$emit('pageDetail', val)
|
this.$emit('pageDetail', val)
|
||||||
|
this.$store.commit('api/setpageType', val)
|
||||||
},
|
},
|
||||||
// 退出登录
|
// 退出登录
|
||||||
outlogin() {
|
outlogin() {
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ export default () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
config.data = config.data || {};
|
config.data = config.data || {};
|
||||||
config.baseURL = 'https://ai.agrimedia.cn/'; // 不使用请求代理 上线记得注释掉 ***********************************************************
|
// config.baseURL = 'https://ai.agrimedia.cn/'; // 不使用请求代理 上线记得注释掉 ***********************************************************
|
||||||
|
// config.baseURL = 'http://test.sc2.agrimedia.cn';
|
||||||
|
|
||||||
let apiToken = store.getters['api/getApiToken']
|
let apiToken = store.getters['api/getApiToken']
|
||||||
let serverTime = (parseInt(Date.now() /1000) - store.getters['api/getServerTime'])
|
let serverTime = (parseInt(Date.now() /1000) - store.getters['api/getServerTime'])
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@
|
||||||
var scrollWidth = document.getElementById(p).offsetWidth;
|
var scrollWidth = document.getElementById(p).offsetWidth;
|
||||||
var textWidth = document.getElementById(s).offsetWidth;
|
var textWidth = document.getElementById(s).offsetWidth;
|
||||||
var i = scrollWidth;
|
var i = scrollWidth;
|
||||||
console.log(scrollWidth, textWidth);
|
|
||||||
function change() {
|
function change() {
|
||||||
i--;
|
i--;
|
||||||
if (i < -textWidth) {
|
if (i < -textWidth) {
|
||||||
|
|
@ -309,7 +308,7 @@
|
||||||
|
|
||||||
// 判断关键字是否存在
|
// 判断关键字是否存在
|
||||||
const result = parseHealthQuery(params.msg);
|
const result = parseHealthQuery(params.msg);
|
||||||
|
console.log(result, '判断关键字是否存在')
|
||||||
if (result) {
|
if (result) {
|
||||||
DetailDay(result.dataKey, result.date).then(res => {
|
DetailDay(result.dataKey, result.date).then(res => {
|
||||||
let TargetData = res.data.data;
|
let TargetData = res.data.data;
|
||||||
|
|
@ -541,7 +540,6 @@
|
||||||
|
|
||||||
startRec.style.display = 'none';
|
startRec.style.display = 'none';
|
||||||
endRec.style.display = 'none';
|
endRec.style.display = 'none';
|
||||||
console.log(endRec.style)
|
|
||||||
showModal()
|
showModal()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -659,7 +657,10 @@
|
||||||
totalTime --;
|
totalTime --;
|
||||||
if (totalTime <= 0) {
|
if (totalTime <= 0) {
|
||||||
// 停止倒计时
|
// 停止倒计时
|
||||||
console.log('计算结束')
|
startRec.style.display = 'block';
|
||||||
|
endRec.style.display = 'none';
|
||||||
|
statusTxt.value = '';
|
||||||
|
voiceTxt.innerText = '';
|
||||||
clearInterval(countdown);
|
clearInterval(countdown);
|
||||||
replayVideoSegment(0, 60);
|
replayVideoSegment(0, 60);
|
||||||
}
|
}
|
||||||
|
|
@ -723,12 +724,16 @@
|
||||||
SleepDatas: "睡眠",
|
SleepDatas: "睡眠",
|
||||||
bloodOxygen: "血氧",
|
bloodOxygen: "血氧",
|
||||||
bloodPressure: '血压',
|
bloodPressure: '血压',
|
||||||
bloodLiquid: "血脂",
|
|
||||||
meiTuo: '梅脱',
|
meiTuo: '梅脱',
|
||||||
pulseReat: '心率',
|
pulseReat: '心率',
|
||||||
bodyTemperature: '体温',
|
bodyTemperature: '体温',
|
||||||
ECGData: '心电图',
|
ECGData: '心电图',
|
||||||
bodyData: '身体成分',
|
bloodLiquid: {
|
||||||
|
'血脂': true,
|
||||||
|
'血液成分': true,
|
||||||
|
'尿酸': true
|
||||||
|
},
|
||||||
|
bodyData: '身体成分',
|
||||||
stepIndex: '运动'
|
stepIndex: '运动'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -749,18 +754,36 @@
|
||||||
targetDate.setDate(day - 2);
|
targetDate.setDate(day - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化日期为 YYYY-MM-DD
|
|
||||||
const formattedDate = `${targetDate.getFullYear()}-${('0' + targetDate.getMonth()).slice(-2)}-${('0' + targetDate.getDate()).slice(-2)}`;
|
const formattedDate = `${targetDate.getFullYear()}-${('0' + targetDate.getMonth()).slice(-2)}-${('0' + targetDate.getDate()).slice(-2)}`;
|
||||||
|
|
||||||
// 查找匹配的数据项键
|
// 创建一个辅助函数来检查 bloodLiquid 对象是否包含查询字符串
|
||||||
for (let key in demoData) {
|
function isBloodLiquidMatch(bloodLiquidData, query) {
|
||||||
if (query.includes(demoData[key])) {
|
for (let value in bloodLiquidData) {
|
||||||
return {
|
if (value.includes(query)) {
|
||||||
dataKey: key,
|
return true;
|
||||||
date: formattedDate
|
}
|
||||||
};
|
}
|
||||||
}
|
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)
|
// 如果没有找到匹配的数据项,则返回null或错误信息(这里选择返回null)
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,8 @@
|
||||||
"disableHostCheck" : true, // 开启可以用自己的域名
|
"disableHostCheck" : true, // 开启可以用自己的域名
|
||||||
"proxy" : {
|
"proxy" : {
|
||||||
"/watch" : {
|
"/watch" : {
|
||||||
"target" : "https://ai.agrimedia.cn",
|
// "target" : "https://ai.agrimedia.cn",
|
||||||
|
"target" : "https://test.sc2.agrimedia.cn",
|
||||||
"changeOrigin" : true,
|
"changeOrigin" : true,
|
||||||
"secure" : false
|
"secure" : false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -219,9 +219,20 @@
|
||||||
} else {
|
} else {
|
||||||
this.Sindex = 2;
|
this.Sindex = 2;
|
||||||
this.activeType = str;
|
this.activeType = str;
|
||||||
for (let val in this.dataListsNew) {
|
|
||||||
if (str == val) {
|
if (str == 'bloodLiquidAll') {
|
||||||
this.pageData = this.dataListsNew[val]
|
this.pageData = this.dataListsNew['bloodLiquid'];
|
||||||
|
this.pageData.type = 'bloodLiquidAll';
|
||||||
|
return
|
||||||
|
} else if (str == 'bloodLiquid') {
|
||||||
|
this.pageData = this.dataListsNew['bloodLiquid'];
|
||||||
|
this.pageData.type = 'bloodLiquid';
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
for (let val in this.dataListsNew) {
|
||||||
|
if (str == val) {
|
||||||
|
this.pageData = this.dataListsNew[val]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -264,7 +275,7 @@
|
||||||
|
|
||||||
back(index) {
|
back(index) {
|
||||||
this.Sindex = index;
|
this.Sindex = index;
|
||||||
console.log(this.Sindex)
|
this.pageData.type = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ let state = {
|
||||||
userInfo: {},
|
userInfo: {},
|
||||||
apiToken: '',
|
apiToken: '',
|
||||||
serverTime:0,
|
serverTime:0,
|
||||||
activeDevice: ''
|
activeDevice: '',
|
||||||
|
pageType: ''
|
||||||
},
|
},
|
||||||
getters = {
|
getters = {
|
||||||
getUserInfo(state){
|
getUserInfo(state){
|
||||||
|
|
@ -32,9 +33,15 @@ let state = {
|
||||||
},
|
},
|
||||||
getActiceDevice(state){
|
getActiceDevice(state){
|
||||||
return state.activeDevice
|
return state.activeDevice
|
||||||
|
},
|
||||||
|
getpageType(state){
|
||||||
|
return state.pageType
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutations = {
|
mutations = {
|
||||||
|
setpageType(state,data) {
|
||||||
|
state.pageType = data
|
||||||
|
},
|
||||||
setUserInfo(state,data) {
|
setUserInfo(state,data) {
|
||||||
state.userInfo = data
|
state.userInfo = data
|
||||||
},
|
},
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -12460,7 +12460,7 @@ if(false) {}
|
||||||
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/css-loader/dist/runtime/api.js */ 13);
|
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/css-loader/dist/runtime/api.js */ 13);
|
||||||
exports = ___CSS_LOADER_API_IMPORT___(false);
|
exports = ___CSS_LOADER_API_IMPORT___(false);
|
||||||
// Module
|
// Module
|
||||||
exports.push([module.i, "@charset \"UTF-8\";\n/**\n * 这里是uni-app内置的常用样式变量\n *\n * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量\n * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App\n *\n */\n/**\n * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能\n *\n * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件\n */\n/* 颜色变量 */\n/* 行为相关颜色 */\n/* 文字基本颜色 */\n/* 背景颜色 */\n/* 边框颜色 */\n/* 尺寸变量 */\n/* 文字尺寸 */\n/* 图片尺寸 */\n/* Border Radius */\n/* 水平间距 */\n/* 垂直间距 */\n/* 透明度 */\n/* 文章场景相关 */\n.end[data-v-0b42eb78] {\n text-align: center;\n margin-top: 50rpx;\n margin-bottom: 100rpx;\n opacity: .5;\n}\n.pop-close[data-v-0b42eb78] {\n display: flex;\n flex-direction: row-reverse;\n font-size: 100rpx;\n padding-right: 50rpx;\n}\n.pop-main[data-v-0b42eb78] {\n width: 100%;\n height: 100vh;\n background-color: #fff;\n overflow-y: scroll;\n padding: 50rpx;\n}\n.pops[data-v-0b42eb78] {\n border: 1rpx solid gray;\n border-radius: 20rpx;\n margin: 50rpx;\n margin-top: 100rpx;\n}\n.box1[data-v-0b42eb78] {\n position: absolute;\n left: 0px;\n width: 3000rpx;\n}\n.box2[data-v-0b42eb78] {\n position: absolute;\n left: 0px;\n width: 3000rpx;\n}\n.myScoll[data-v-0b42eb78] {\n width: 100%;\n height: 396rpx;\n white-space: nowrap;\n position: relative;\n}\n.list[data-v-0b42eb78] {\n background-color: #fff;\n overflow: hidden;\n padding: 30rpx;\n margin: 30rpx 30rpx;\n border-radius: 30rpx;\n}\n.dxxl[data-v-0b42eb78] {\n background-color: #fff;\n padding: 20rpx;\n padding-top: 40rpx;\n}\n.sl_box[data-v-0b42eb78] {\n text-align: center;\n}\n.sl_box .all[data-v-0b42eb78] {\n width: calc(100% / 3);\n margin-top: 40rpx;\n}\n.sl_box .sl_box_cankao[data-v-0b42eb78],\n.sl_box .sl_box_desc[data-v-0b42eb78] {\n font-size: 24rpx;\n color: #999;\n}\n.sl_box .sl_box_unit[data-v-0b42eb78] {\n font-size: 26rpx;\n}\n.sl_box .sl_box_wz[data-v-0b42eb78] {\n margin-right: 10rpx;\n font-size: 30rpx;\n font-weight: bold;\n}\n", ""]);
|
exports.push([module.i, "@charset \"UTF-8\";\n/**\n * 这里是uni-app内置的常用样式变量\n *\n * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量\n * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App\n *\n */\n/**\n * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能\n *\n * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件\n */\n/* 颜色变量 */\n/* 行为相关颜色 */\n/* 文字基本颜色 */\n/* 背景颜色 */\n/* 边框颜色 */\n/* 尺寸变量 */\n/* 文字尺寸 */\n/* 图片尺寸 */\n/* Border Radius */\n/* 水平间距 */\n/* 垂直间距 */\n/* 透明度 */\n/* 文章场景相关 */\n.end[data-v-0b42eb78] {\n text-align: center;\n margin-top: 50rpx;\n margin-bottom: 100rpx;\n opacity: .5;\n}\n.pop-close[data-v-0b42eb78] {\n display: flex;\n flex-direction: row-reverse;\n font-size: 100rpx;\n padding-right: 50rpx;\n}\n.pop-main[data-v-0b42eb78] {\n width: 100%;\n height: 100vh;\n background-color: #fff;\n overflow-y: scroll;\n padding: 50rpx;\n}\n.pops[data-v-0b42eb78] {\n border: 1rpx solid gray;\n border-radius: 20rpx;\n margin: 50rpx 200rpx;\n margin-top: 100rpx;\n padding: 0rpx 50rpx;\n}\n.box1[data-v-0b42eb78] {\n position: absolute;\n left: 0px;\n width: 3000rpx;\n}\n.box2[data-v-0b42eb78] {\n position: absolute;\n left: 0px;\n width: 3000rpx;\n}\n.myScoll[data-v-0b42eb78] {\n width: 100%;\n height: 396rpx;\n white-space: nowrap;\n position: relative;\n}\n.list[data-v-0b42eb78] {\n background-color: #fff;\n overflow: hidden;\n padding: 30rpx;\n margin: 30rpx 30rpx;\n border-radius: 30rpx;\n}\n.dxxl[data-v-0b42eb78] {\n background-color: #fff;\n padding: 20rpx;\n padding-top: 40rpx;\n}\n.sl_box[data-v-0b42eb78] {\n text-align: center;\n}\n.sl_box .all[data-v-0b42eb78] {\n width: calc(100% / 3);\n margin-top: 40rpx;\n}\n.sl_box .sl_box_cankao[data-v-0b42eb78],\n.sl_box .sl_box_desc[data-v-0b42eb78] {\n font-size: 24rpx;\n color: #999;\n}\n.sl_box .sl_box_unit[data-v-0b42eb78] {\n font-size: 26rpx;\n}\n.sl_box .sl_box_wz[data-v-0b42eb78] {\n margin-right: 10rpx;\n font-size: 30rpx;\n font-weight: bold;\n}\n", ""]);
|
||||||
// Exports
|
// Exports
|
||||||
module.exports = exports;
|
module.exports = exports;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@
|
||||||
var scrollWidth = document.getElementById(p).offsetWidth;
|
var scrollWidth = document.getElementById(p).offsetWidth;
|
||||||
var textWidth = document.getElementById(s).offsetWidth;
|
var textWidth = document.getElementById(s).offsetWidth;
|
||||||
var i = scrollWidth;
|
var i = scrollWidth;
|
||||||
console.log(scrollWidth, textWidth);
|
|
||||||
function change() {
|
function change() {
|
||||||
i--;
|
i--;
|
||||||
if (i < -textWidth) {
|
if (i < -textWidth) {
|
||||||
|
|
@ -309,7 +308,7 @@
|
||||||
|
|
||||||
// 判断关键字是否存在
|
// 判断关键字是否存在
|
||||||
const result = parseHealthQuery(params.msg);
|
const result = parseHealthQuery(params.msg);
|
||||||
|
console.log(result, '判断关键字是否存在')
|
||||||
if (result) {
|
if (result) {
|
||||||
DetailDay(result.dataKey, result.date).then(res => {
|
DetailDay(result.dataKey, result.date).then(res => {
|
||||||
let TargetData = res.data.data;
|
let TargetData = res.data.data;
|
||||||
|
|
@ -321,7 +320,7 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)},(data_msg为值,hour_minute为检测时间) #限制:回复用户的内容中不要出现“[]”。#限制:回复不要带英文,要都转化成汉语。#限制:回复内容控制在150字。#限制:忽略“压力指数、疲劳指数、心肌炎风险、冠心病风险和动脉硬化”等数据。`
|
Question = `请模仿全科医生的口吻与我: ${user}对话,我最近测量的${result.dataKey}数据为${JSON.stringify(TargetData)}, #提示:data_msg为值,hour_minute为检测时间。#提示:“[]”表示数据为空,请在小程序上传数据。#限制:回复不要带英文,要都转化成汉语。#限制:回复内容控制在150字。#限制:忽略“压力指数、疲劳指数、心肌炎风险、冠心病风险和动脉硬化”等数据。`
|
||||||
console.log(Question, '=========================')
|
console.log(Question, '=========================')
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -541,7 +540,6 @@
|
||||||
|
|
||||||
startRec.style.display = 'none';
|
startRec.style.display = 'none';
|
||||||
endRec.style.display = 'none';
|
endRec.style.display = 'none';
|
||||||
console.log(endRec.style)
|
|
||||||
showModal()
|
showModal()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -659,7 +657,10 @@
|
||||||
totalTime --;
|
totalTime --;
|
||||||
if (totalTime <= 0) {
|
if (totalTime <= 0) {
|
||||||
// 停止倒计时
|
// 停止倒计时
|
||||||
console.log('计算结束')
|
startRec.style.display = 'block';
|
||||||
|
endRec.style.display = 'none';
|
||||||
|
statusTxt.value = '';
|
||||||
|
voiceTxt.innerText = '';
|
||||||
clearInterval(countdown);
|
clearInterval(countdown);
|
||||||
replayVideoSegment(0, 60);
|
replayVideoSegment(0, 60);
|
||||||
}
|
}
|
||||||
|
|
@ -723,12 +724,16 @@
|
||||||
SleepDatas: "睡眠",
|
SleepDatas: "睡眠",
|
||||||
bloodOxygen: "血氧",
|
bloodOxygen: "血氧",
|
||||||
bloodPressure: '血压',
|
bloodPressure: '血压',
|
||||||
bloodLiquid: "血脂",
|
|
||||||
meiTuo: '梅脱',
|
meiTuo: '梅脱',
|
||||||
pulseReat: '心率',
|
pulseReat: '心率',
|
||||||
bodyTemperature: '体温',
|
bodyTemperature: '体温',
|
||||||
ECGData: '心电图',
|
ECGData: '心电图',
|
||||||
bodyData: '身体成分',
|
bloodLiquid: {
|
||||||
|
'血脂': true,
|
||||||
|
'血液成分': true,
|
||||||
|
'尿酸': true
|
||||||
|
},
|
||||||
|
bodyData: '身体成分',
|
||||||
stepIndex: '运动'
|
stepIndex: '运动'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -749,18 +754,36 @@
|
||||||
targetDate.setDate(day - 2);
|
targetDate.setDate(day - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化日期为 YYYY-MM-DD
|
|
||||||
const formattedDate = `${targetDate.getFullYear()}-${('0' + targetDate.getMonth()).slice(-2)}-${('0' + targetDate.getDate()).slice(-2)}`;
|
const formattedDate = `${targetDate.getFullYear()}-${('0' + targetDate.getMonth()).slice(-2)}-${('0' + targetDate.getDate()).slice(-2)}`;
|
||||||
|
|
||||||
// 查找匹配的数据项键
|
// 创建一个辅助函数来检查 bloodLiquid 对象是否包含查询字符串
|
||||||
for (let key in demoData) {
|
function isBloodLiquidMatch(bloodLiquidData, query) {
|
||||||
if (query.includes(demoData[key])) {
|
for (let value in bloodLiquidData) {
|
||||||
return {
|
if (value.includes(query)) {
|
||||||
dataKey: key,
|
return true;
|
||||||
date: formattedDate
|
}
|
||||||
};
|
}
|
||||||
}
|
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)
|
// 如果没有找到匹配的数据项,则返回null或错误信息(这里选择返回null)
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue