|
|
@@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|