瀏覽代碼

增加 身高体重录入

feat
chenJinxu 7 月之前
父節點
當前提交
54c081ee2c
共有 3 個文件被更改,包括 106 次插入54 次删除
  1. +6
    -2
      src/filters/filter.js
  2. +91
    -43
      src/views/insight/index.vue
  3. +9
    -9
      src/views/insight/signsReport.vue

+ 6
- 2
src/filters/filter.js 查看文件

@@ -46,15 +46,19 @@ export function calcBMI(height, weight) {
const bmiObj = {};
// 计算 BMI 指数
const bmi = weight / (realHeight * realHeight);
bmiObj.bmi = bmi;
bmiObj.bmi = bmi.toFixed(1);
if (bmi < 18.5) {
bmiObj.result = '体重过轻';
bmiObj.color = '#2ea7e0';
} else if (bmi >= 18.5 && bmi < 24.9) {
bmiObj.result = '正常体重';
bmiObj.color = '#189b3b';
} else if (bmi >= 25 && bmi < 29.9) {
bmiObj.result = '超重';
bmiObj.color = '#ff5f8b';
} else {
bmiObj.result = '肥胖';
bmiObj.color = '#189b3b';
bmiObj.result = '暂无数据';
}
return bmiObj;
}


+ 91
- 43
src/views/insight/index.vue 查看文件

@@ -64,8 +64,8 @@
<p>{{ bmi.result }}</p>
<van-button size="mini" @click="onUpdateBmi">更新</van-button>
</div>
<van-dialog v-model="bmi.isBmiShow" title="请输入身高和体重" confirm-button-color="#179b3b" cancel-button-text="关闭"
show-cancel-button @confirm="onConfirmBmi">
<van-dialog v-model="bmi.isBmiShow" :title="dialogTitle" confirm-button-color="#179b3b" cancel-button-text="关闭"
show-cancel-button @confirm="onConfirmBmi" @cancel="onCancelBmi">
<div class="bmiDialog">
<van-cell-group>
<van-field v-model="bmi.height" label="身高:" type="number" maxlength="3" placeholder="请输入身高" border
@@ -158,11 +158,13 @@
import DateSwitch from '@/components/DateSwitch.vue';
import { format, startOfMonth, endOfMonth } from 'date-fns';
import ToastService from '@/services/toast-service';
import DialogService from '@/services/dialog-service';
import { /* EmotionModel, */ PsyBaseUrl } from '@/config/models';
import axios from 'axios';
import EchartBox from '@/components/EchartBox';
import APIHealthUser from '@/api/health-user';
import APIAlarm from '@/api/core';
import { isNull } from '@/services/utils-service';
export default {
components: {
DateSwitch,
@@ -260,11 +262,13 @@ export default {
}
],
bmi: {
height: '170',
weight: '57',
value: '24.5',
result: '肥胖',
height: '',
weight: '',
value: '',
result: '',
isBmiShow: false,
curHeight: '', //当前的身高
curWeight: '',//当前的体重
},
upImg: require('@/assets/today/icons/up.png'),
downImg: require('@/assets/today/icons/down.png'),
@@ -297,6 +301,7 @@ export default {
signDaysList: [],
stepsData: {},
calorieData: {},
personData: null

};
},
@@ -311,6 +316,7 @@ export default {
if (isExistToken) {
this.initData();
this.getPsychologiclData();
this.getPersonInfo();
}
},
watch: {
@@ -479,41 +485,7 @@ export default {
}
}
},
series: [
{
name: `无${this.emoName}倾向`,
type: 'line',
padding: 5,
smooth: true,
data: this.emotionData,
symbol: 'circle',
symbolSize: 10,
itemStyle: {
color: '#fff',
borderWidth: 2
},
lineStyle: {
width: 6,
type: 'solid',
color: '#189b3b'
}
},
{
name: `轻度${this.emoName}倾向`,
type: 'line',
data: ''
},
{
name: `中度${this.emoName}倾向`,
type: 'line',
data: ''
},
{
name: `重度${this.emoName}倾向`,
type: 'line',
data: ''
}
]
series: []
};
},
emoLegend() {
@@ -1255,7 +1227,7 @@ export default {
data.forEach(item => {
xdata.push(item.key);
ydata.push({
value: item.value,
value: item.value == null ? 0 : item.value,
label: {
show: true
},
@@ -1548,13 +1520,89 @@ export default {
});
});
},
// 获取用户信息
getPersonInfo() {
let reqParams = {
personId: this.$store.getters.personId
};
APIHealthUser.personInfo(reqParams)
.then(res => {
const data = res.data.data;
if (data) {
this.bmi.height = data.height;
this.bmi.weight = data.weight;
this.bmi.curHeight = data.height;
this.bmi.curWeight = data.weight;
const bmiResult = this.$calcBMI(data.height, data.weight);
this.bmi.value = bmiResult.bmi;
this.bmi.result = bmiResult.result;
this.personData = { ...data }
console.log("bmi信息", bmiResult);
}
})
.catch(error => {
console.log('error', error);
this.showOverlay = false;
this.isPageShow = true;
})
.finally(() => {

})
},
// 更新用户信息
updatePerson() {
let reqBody = {
...this.personData

};
reqBody.height = Number(this.bmi.height);
reqBody.weight = Number(this.bmi.weight);
console.log('reqBody', reqBody);
ToastService.loading({
message: '更新中'
});
APIHealthUser.updatePerson(reqBody)
.then(res => {
ToastService.clear();
console.log(res.data);
if (res.data.stateCode == 1) {
ToastService.success({
message: '更新成功'
});
setTimeout(() => {
this.getPersonInfo();
}, 1000);
} else {
DialogService.confirm({
title: res.data.message
});
}
})
.catch(e => {
ToastService.clear();
DialogService.confirm({
title: e.message || '服务器异常'
});
});
},
// 更新bmi
onUpdateBmi() {
// 打开输入弹窗
this.bmi.isBmiShow = true;
},
onConfirmBmi() {

if (isNull(this.bmi.height) || isNull(this.bmi.weight)) {
this.bmi.height = this.bmi.curHeight;
this.bmi.weight = this.bmi.curWeight;
return DialogService.confirm({
title: '身高和体重不能为空'
})
}
this.updatePerson();
},
onCancelBmi() {
this.bmi.height = this.bmi.curHeight;
this.bmi.weight = this.bmi.curWeight;
}
}
};


+ 9
- 9
src/views/insight/signsReport.vue 查看文件

@@ -158,12 +158,12 @@
</div>
</div>
</div>
<div class="advice" v-show="signActive == 2">
<!-- <div class="advice" v-show="signActive == 2">
<div class="content">
<p class="title">健康建议</p>
<p>{{ adviceOfCalor || '--' }}</p>
</div>
</div>
</div> -->
</div>
<!-- 建议 -->
<!-- <div class="advice" v-show="signActive !== 2">
@@ -298,14 +298,14 @@ export default {
},
calorieData: {
calorieTotal: {
compare: '',
lastTotal: '',
total: ''
compare: null,
lastTotal: null,
total: null
},
calorieAvg: {
compare: '',
lastAvg: '',
avg: ''
compare: null,
lastAvg: null,
avg: null
}
},

@@ -1866,7 +1866,7 @@ export default {
text-align: left;

p {
font-size: 24px;
font-size: 28px;
color: #707070;
line-height: 46px;
padding: 10px 0;


Loading…
取消
儲存