kitchendDevice/pageTwo/count/KcalEdit.vue

111 lines
1.9 KiB
Vue

<template>
<view class="content">
<view class="title">
自定义卡路里量
<text class="desc">{{suggestion_kcal_range_val}}</text>
</view>
<view class="input">
<input type="digit" placeholder="请输入" v-model="kcal" />
<text>千卡</text>
</view>
<view class="btn" @click="handlesub">确认修改</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
kcal: "",
suggestion_kcal_range_val: ""
}
},
computed: {
...mapState(["user"]),
},
onLoad(options) {
this.suggestion_kcal_range_val = options.suggestion_kcal_range_val
},
methods: {
handlesub() {
let that = this
if (that.kcal == '' || Number(that.kcal) <= 0) {
that.$tools.msg("请输入卡路里")
return
}
that.$model.getCountSetUserKcal({
aud_id: that.user.aud_id,
set_kcal: that.kcal
}).then(res => {
if (res.code == 0) {
that.$tools.msg("设置成功")
setTimeout(function() {
uni.switchTab({
url: '/pages/count/count'
})
}, 1000)
}
})
}
}
}
</script>
<style scoped lang="scss">
.content {
padding: 0 15px;
flex-wrap: wrap;
background-color: #fff;
}
.title {
width: 100%;
font-size: 16px;
margin: 15px 0;
font-weight: bold;
text {
font-size: 14px;
color: #999;
font-weight: 500;
width: 100%;
display: inline-block;
margin-top: 10px;
}
}
.input {
display: flex;
margin: 20px;
height: 35px;
line-height: 35px;
border-bottom: 1px solid #dfdfdf;
width: calc(100% - 40px);
position: relative;
/deep/input {
width: 100%;
height: 35px;
font-size: 18px;
line-height: 35px;
text-align: center;
font-weight: bold;
position: absolute;
}
text {
position: absolute;
right: 0;
}
}
.btn {
margin-top: 40px;
width: calc(100% - 30px);
color: #fff;
}
</style>