examTeamApp/components/target/firstweight.vue

109 lines
2.3 KiB
Vue
Raw Normal View History

2024-05-02 15:59:36 +08:00
<template>
2024-05-29 16:35:45 +08:00
<view v-if="isFirst" class="wrapper wrapperbg">
<view class="bg" @click="onTap">
<view class="edit" @click.stop>
<view class="title">{{type==1?'目标体重':'初始体重'}}</view>
<view class="editem" @click="hideKeyboard" v-if="type!=1">
<view class="name">日期</view>
<view class="right">
<uni-datetime-picker type="date" @change="changeLog" :border="false" :end="endDate"
:clear-icon='false' :hide-second='false' />
</view>
</view>
<view class="editem">
<view class="name">体重</view>
<view class="right">
<input v-model="weight" type="digit" placeholder="请输入" />kg
</view>
</view>
<view class="btn close" @click="onTap()">取消</view>
<view class="btn" @click="handleTarget">确定</view>
</view>
</view>
</view>
2024-05-02 15:59:36 +08:00
</template>
<script>
2024-05-29 16:35:45 +08:00
import {
mapState
} from "vuex";
export default {
props: {
type: {}
},
data() {
return {
regTime: "",
weight: "",
2024-05-02 15:59:36 +08:00
}
2024-05-29 16:35:45 +08:00
},
computed: {
...mapState(["user", "isFirst"]),
endDate() {
return this.$tools.getDate("start")
}
},
methods: {
// 初始体重
handleTarget() {
let that = this
if (that.type != 1 && !that.regTime) {
that.$tools.msg("请选择测量日期")
return
2024-05-02 15:59:36 +08:00
}
2024-05-29 16:35:45 +08:00
if (!that.weight) {
that.$tools.msg("请输入测量体重")
return
2024-05-02 15:59:36 +08:00
}
2024-05-29 16:35:45 +08:00
that.$model.getfirstweight({
aud_id: that.user.id,
time: that.type == 1 ? '' : that.regTime ? that.regTime : that.user.firstresulttime,
weight: that.weight,
type: that.type
}).then(res => {
console.log("目标,", res)
that.$tools.msg(res.msg)
if (res.code == 0) {
that.$store.commit("changeFirst", false);
that.$store.commit('changeUser', {
target_current: res.data
})
that.regTime = ""
that.weight = ""
2024-05-02 15:59:36 +08:00
}
2024-05-29 16:35:45 +08:00
})
},
//
changeLog(e) {
this.regTime = e
},
onTap() {
this.weight = ""
this.regTime = ""
this.$store.commit("changeFirst", false);
},
hideKeyboard() {
uni.hideKeyboard()
},
2024-05-02 15:59:36 +08:00
}
}
2024-05-29 16:35:45 +08:00
</script>
2024-05-02 15:59:36 +08:00
2024-05-29 16:35:45 +08:00
<style scoped lang="scss">
.btn {
width: 40%;
float: right;
margin-top: 15px;
background: $maincolor !important;
}
.edit {
top: 20%
}
2024-05-02 15:59:36 +08:00
2024-05-29 16:35:45 +08:00
.close {
background: #fff !important;
float: left;
color: #333;
}
</style>