|
|
@@ -0,0 +1,140 @@ |
|
|
|
<template> |
|
|
|
<div class="psychological-main-container"> |
|
|
|
<van-nav-bar title="今日情绪" :border="true" :left-arrow="true" @click-left="onNavBack"></van-nav-bar> |
|
|
|
<div class="main"> |
|
|
|
<div class="list"> |
|
|
|
<div v-for="(item,index) in healhtList" :key="index" :class="['item', item.class]" @click="onClick(item)"> |
|
|
|
<p class="health-value" :style="{ color: calcColor(item.value) }"> |
|
|
|
{{ item.value || '--' }} |
|
|
|
</p> |
|
|
|
<p class="health-name"> |
|
|
|
{{ item.name || '--'}} |
|
|
|
</p> |
|
|
|
<div class="health-result"> |
|
|
|
<div :class="['left', item.class]"> |
|
|
|
<p class="result"> |
|
|
|
{{ item.result || '暂无数据'}} |
|
|
|
</p> |
|
|
|
</div> |
|
|
|
<div class="right"> |
|
|
|
<!-- img --> |
|
|
|
<img :src="item.img" alt=""> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="health-time"> |
|
|
|
<p class="time">{{ item.time || '--' }}</p> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import axios from "axios"; |
|
|
|
export default { |
|
|
|
name: 'psychologicalMain', |
|
|
|
data(){ |
|
|
|
return { |
|
|
|
healhtList: [ |
|
|
|
/* { value: 40, name: '抑郁倾向', class: 'depression',result: '无抑郁倾向', time: '17:52', img: require('@/assets/img/regardless.png') }, |
|
|
|
{ value: 55, name: '压力', class: 'stress', result: '轻度压力', time: '17:52', img: require('@/assets/img/regardless.png') }, |
|
|
|
{ value: 75, name: '疲劳', class: 'tiredness', result: '中度疲劳', time: '17:52', img: require('@/assets/img/moderate.png') }, */ |
|
|
|
], |
|
|
|
uid: '', |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
created() { |
|
|
|
this.loadParams(); |
|
|
|
this.getHomeData(); |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
|
|
|
|
}, |
|
|
|
methods: { |
|
|
|
loadParams() { |
|
|
|
let params = this.$route.query; |
|
|
|
if (params) { |
|
|
|
this.uid = params.uid; |
|
|
|
} |
|
|
|
}, |
|
|
|
getHomeData() { |
|
|
|
this.$toast.loading('数据加载中'); |
|
|
|
let reqUrl = `https://dbmq.rzliot.com/heart/api/Data/GetHomeData`; |
|
|
|
let reqParams = { |
|
|
|
uid: this.uid, |
|
|
|
date: this.$dayjs(new Date()).format('YYYY-MM-DD') |
|
|
|
}; |
|
|
|
axios.get(reqUrl, { |
|
|
|
params: { ...reqParams } |
|
|
|
}).then(res => { |
|
|
|
console.log("res", res); |
|
|
|
const data = res.data.response; |
|
|
|
this.healhtList = [ |
|
|
|
// 抑郁 |
|
|
|
{ value: data.DepScore, name: '抑郁倾向', class: 'depression', result: data.DepDesc, time: data.DepMeasureTime ? this.$dayjs(data.DepMeasureTime).format('HH:mm'): '', level: data.DepLevel, img: this.calcImg(data.DepLevel) }, |
|
|
|
// 压力 |
|
|
|
{ value: data.StressScore, name: '压力', class: 'stress', result: data.StressDesc, time: data.StressMeasureTime ? this.$dayjs(data.StressMeasureTime).format('HH:mm') : '', level: data.StressLevel, img: this.calcImg(data.StressLevel) }, |
|
|
|
// 疲劳 |
|
|
|
{ value: data.TirScore, name: '疲劳', class: 'tiredness', result: data.TirDesc, time: data.TirMeasureTime ? this.$dayjs(data.TirMeasureTime).format('HH:mm') : '', level: data.TirLevel, img: this.calcImg(data.TirLevel) }, |
|
|
|
]; |
|
|
|
this.$toast.success('数据加载完成'); |
|
|
|
}).catch(() =>{}).finally(() => { this.$toast.clear() }) |
|
|
|
|
|
|
|
}, |
|
|
|
onClick(item) { |
|
|
|
this.$router.push({ |
|
|
|
name: 'psychological', |
|
|
|
query: { |
|
|
|
name: item.class, |
|
|
|
uid: this.uid |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
onNavBack() { |
|
|
|
this.$router.go(-1); |
|
|
|
}, |
|
|
|
// 计算表情 |
|
|
|
calcImg(level) { |
|
|
|
let imgUrl = ''; |
|
|
|
switch(level) { |
|
|
|
case '0': |
|
|
|
imgUrl = require('@/assets/img/regardless.png'); |
|
|
|
break; |
|
|
|
case '1': |
|
|
|
imgUrl = require('@/assets/img/regardless.png'); |
|
|
|
break; |
|
|
|
case '2': |
|
|
|
imgUrl = require('@/assets/img/moderate.png'); |
|
|
|
break; |
|
|
|
case '3': |
|
|
|
imgUrl = require('@/assets/img/moderate.png'); |
|
|
|
break; |
|
|
|
} |
|
|
|
return imgUrl; |
|
|
|
}, |
|
|
|
// 计算颜色 |
|
|
|
calcColor(value) { |
|
|
|
let color = ""; |
|
|
|
if (value <= 40) { |
|
|
|
color = "#62BD48"; |
|
|
|
} else if (value > 40 && value <= 65) { |
|
|
|
color = "#FEC350"; |
|
|
|
} else if (value > 65 && value <= 80) { |
|
|
|
color = "#F86825"; |
|
|
|
} else if (value > 80) { |
|
|
|
color = "#EB1D15"; |
|
|
|
} else { |
|
|
|
color = ""; |
|
|
|
} |
|
|
|
return color; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
|
@import "./index.scss"; |
|
|
|
</style> |