234 lines
4.8 KiB
Vue
234 lines
4.8 KiB
Vue
<template>
|
|
<view class="app">
|
|
<view class="uptext">
|
|
<view class="pressureg">
|
|
身高
|
|
</view>
|
|
<input placeholder="请输入数值" border="bottom" v-model="height" fontSize='50rpx' inputAlign='center'
|
|
type="number"></input>
|
|
<view class="text">
|
|
cm
|
|
</view>
|
|
</view>
|
|
<view class="uptext">
|
|
<view class="pressureg">
|
|
体重
|
|
</view>
|
|
<input placeholder="请输入数值" border="bottom" v-model="weight" fontSize='50rpx' inputAlign='center'
|
|
type="number"></input>
|
|
<view class="text">
|
|
KG
|
|
</view>
|
|
</view>
|
|
<view class="uptext">
|
|
<view class="pressureg">
|
|
BMI
|
|
</view>
|
|
<input placeholder="请输入数值" border="bottom" v-model="bmi" fontSize='50rpx' inputAlign='center'
|
|
disabled></input>
|
|
<view class="text">
|
|
kg/m^2
|
|
</view>
|
|
</view>
|
|
<view class="time">
|
|
<view style="display: flex;align-items: center;">
|
|
<text style="margin-left: 50rpx">记录时间:</text>
|
|
<view style="display: flex;margin: 0 auto; color: #999;">
|
|
<uni-datetime-picker v-model="measureTime" @change="timeconfirm">{{measureTime}}
|
|
<image style="margin-right: 40rpx;" src="../../static/huijiantou.png" mode="widthFix" />
|
|
</uni-datetime-picker>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="submit" @tap="submit">
|
|
保存
|
|
</view>
|
|
<u-toast ref="uToast" />
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
savebmi
|
|
} from '@/api/examinationapi/add.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
weight: '',
|
|
height: '',
|
|
timetext: this.formatDate(Date.now()),
|
|
measureTime: this.formatDate(Date.now()),
|
|
};
|
|
},
|
|
computed: {
|
|
bmi() {
|
|
return (this.weight / ((this.height / 100) * (this.height / 100))).toFixed(2);
|
|
},
|
|
},
|
|
methods: {
|
|
formatDate(timestamp) {
|
|
const now = new Date(parseInt(timestamp))
|
|
const year = now.getFullYear();
|
|
const month = now.getMonth() + 1;
|
|
const date = now.getDate();
|
|
const hour = now.getHours();
|
|
const minute = now.getMinutes();
|
|
const second = now.getSeconds();
|
|
return year + "-" + ((month < 10) ? '0' + month : month) + "-" + ((date < 10) ? '0' + date : date) + " " +
|
|
((hour < 10) ? '0' + hour : hour) + ":" + ((minute < 10) ? '0' + minute : minute) + ":" + ((second <
|
|
10) ? '0' + second : second);
|
|
},
|
|
timeconfirm(time) {
|
|
this.timetext = time
|
|
},
|
|
submit() {
|
|
if (this.height && this.weight) {
|
|
this.bmi
|
|
let data = {
|
|
bmi: (this.weight / ((this.height / 100) * (this.height / 100))).toFixed(2),
|
|
height: this.height,
|
|
weight: this.weight,
|
|
identity: uni.getStorageSync('userinfo').cardNo,
|
|
measureTime: this.timetext,
|
|
}
|
|
savebmi(data).then(res => {
|
|
if (res.code == 200) {
|
|
this.$refs.uToast.show({
|
|
title: '保存成功',
|
|
type: 'success',
|
|
})
|
|
setTimeout(() => {
|
|
uni.navigateBack({
|
|
delta: 1
|
|
})
|
|
}, 1000)
|
|
}
|
|
})
|
|
} else {
|
|
this.$refs.uToast.show({
|
|
title: '各项格式为正整数,请重新输入',
|
|
type: 'error',
|
|
})
|
|
}
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
page {
|
|
background-color: #fff;
|
|
}
|
|
|
|
.app {
|
|
.submit {
|
|
width: 60%;
|
|
height: 98rpx;
|
|
margin: 60rpx auto;
|
|
background-color: #4AC4AB;
|
|
border-radius: 10rpx;
|
|
border: solid 0rpx #0c0c0c;
|
|
color: #ffffff;
|
|
text-align: center;
|
|
line-height: 98rpx;
|
|
}
|
|
|
|
.time {
|
|
margin-top: 100rpx;
|
|
position: relative;
|
|
border-bottom: 1rpx solid #f0f1f6;
|
|
height: 80rpx;
|
|
line-height: 65rpx;
|
|
|
|
image {
|
|
width: 20rpx;
|
|
height: 20rpx;
|
|
position: absolute;
|
|
right: 10rpx;
|
|
top: 20%;
|
|
}
|
|
|
|
// text:nth-child(1) {
|
|
// margin-left: 50rpx;
|
|
// }
|
|
|
|
text:nth-child(2) {
|
|
float: right;
|
|
margin-right: 100rpx;
|
|
color: #999999;
|
|
font-size: 28rpx;
|
|
}
|
|
|
|
}
|
|
|
|
.uptext:nth-child(4) {
|
|
margin-top: 80rpx;
|
|
}
|
|
|
|
.uptext:nth-child(3) {
|
|
margin-top: 80rpx;
|
|
}
|
|
|
|
.uptext:nth-child(2) {
|
|
margin-top: 80rpx;
|
|
}
|
|
|
|
.uptext:nth-child(1) {
|
|
margin-top: 40rpx;
|
|
}
|
|
|
|
.uptext {
|
|
width: 100%;
|
|
height: 300rpx;
|
|
position: relative;
|
|
border-bottom: 1rpx solid #f0f1f6;
|
|
|
|
.pressured {
|
|
margin-left: 20rpx;
|
|
font-size: 32rpx;
|
|
line-height: 34rpx;
|
|
letter-spacing: 2rpx;
|
|
color: #d34141;
|
|
}
|
|
|
|
.pressureg {
|
|
margin-left: 20rpx;
|
|
font-size: 32rpx;
|
|
line-height: 34rpx;
|
|
letter-spacing: 2rpx;
|
|
color: #41d36d;
|
|
}
|
|
|
|
.heart {
|
|
margin-left: 20rpx;
|
|
font-size: 32rpx;
|
|
line-height: 34rpx;
|
|
letter-spacing: 2rpx;
|
|
color: #00aaff;
|
|
}
|
|
|
|
.text {
|
|
position: absolute;
|
|
top: 75%;
|
|
width: 20%;
|
|
text-align: center;
|
|
left: 40%;
|
|
font-size: 30rpx;
|
|
line-height: 34rpx;
|
|
letter-spacing: 1rpx;
|
|
color: #999999;
|
|
}
|
|
|
|
/deep/ input {
|
|
text-align: center;
|
|
font-size: 40rpx;
|
|
border-bottom: 2rpx solid #f0f1f6;
|
|
position: absolute;
|
|
width: 40%;
|
|
height: 10%;
|
|
top: 50%;
|
|
left: 30%;
|
|
}
|
|
}
|
|
}
|
|
</style> |