| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- <template>
- <view class="container">
- <view class="navigation-bar">基础代谢率</view>
- <view class="back" @click="onBack(0, $event)">
- <image src="/static/backArrow.png" mode="aspectFit" style="width:100%"></image>
- </view>
- <view class="blue" @click="onHelp(0, $event)">
- <image src="../../static/home/blue.png" mode=""></image>
- </view>
-
- <view class="content">
-
- <view class="result-area">
- <view class="border">
- <image class="item-logo" src="../../static/home/basalMetabolismLogo.png" mode=""></image>
- <view class="">
- {{result}}
- </view>
- <!-- <view class="">
- 基础代谢率
- </view> -->
- </view>
- </view>
- <!-- <button class="help" @click="onHelp(0, $event)">宁哥笔记</button> -->
-
- <view class="input-area">
- <view class="age">
- <view class="input-title">年龄 : </view>
- <input class="input" type="number" placeholder="请输入年龄" v-model="age" />
- <text class="Company">岁</text>
- </view>
-
- <view class="high">
- <view class="input-title">身高 : </view>
- <input class="input" type="number" placeholder="请输入身高" v-model="high" />
- <text class="Company">厘米</text>
- </view>
-
- <view class="weight">
- <view class="input-title">体重 : </view>
- <!-- <input class="input" type="number" placeholder="请输入体重" v-model="weight" @input="onInput(0, $event)" :value="weight"/> -->
- <input class="input" type="number" placeholder="请输入体重" v-model="weight" />
- <text class="Company">公斤</text>
- </view>
- </view>
-
- <button class="confirm" @click="onClick(0, $event)">确定</button>
-
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- weight:-1,
- high:-1,
- age:-1,
- //基础代谢率
- bmr:-1,
- result:'0',
- }
- },
- onLoad() {
- this.weight = "";
- this.high = "";
- this.age = "";
- // console.log('gender=',getApp().globalData.gender)
- // console.log('weight=',getApp().globalData.weight)
- // console.log('high=',getApp().globalData.high)
- // console.log('age=',getApp().globalData.age)
- if(getApp().globalData.weight != undefined)
- {
- this.weight = getApp().globalData.weight;
- }
-
- if(getApp().globalData.high != undefined)
- {
- this.high = getApp().globalData.high;
- }
- if(getApp().globalData.age != undefined)
- {
- this.age = getApp().globalData.age;
- }
-
- },
- methods: {
- onBack: function(id,e) {
- //uni.navigateBack()//默认delta:1
- uni.navigateBack({
- delta:1,//返回层数,2则上上页
- })
- },
- onHelp: function(id,e) {
- uni.navigateTo({
- url: '/pages/basalMetabolism/help',
- animationType: 'slide-in-left',
- animationDuration: 2000,
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- onClick: function(id,e) {
-
- if(this.weight != -1 && this.high !=-1 && this.age != -1)
- {
- let gender = getApp().globalData.gender;
-
- getApp().globalData.weight = this.weight;
- getApp().globalData.high = this.high;
- getApp().globalData.age = this.age;
-
-
- if(gender == 0)
- {
- this.bmr = 66+13.7*this.weight+5*this.high-6.8*this.age;
-
- }
- else
- {
- this.bmr = 655+9.6*this.weight+1.8*this.high-4.7*this.age;
- }
- this.result = '你的基础代谢率为: '+ Math.round(this.bmr) + '千卡';
-
- getApp().globalData.bmr = this.bmr;
- }
- else
- {
- switch (id)
- {
- case 0:
- alert('请输入体重');
- break;
-
- case 1:
- alert('请输入身高');
- break;
-
- case 2:
- alert('请输入年龄');
- break;
-
- default:
- break;
- }
-
- }
- },
- }
- }
- </script>
- <style lang="scss">
- .container {
- // display: flex;
- // flex-direction: column;
- // align-items: center;
- // justify-content: center;
- width:100%;
- // height: 100vh;
- }
-
- .navigation-bar
- {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 120rpx;
- font-weight: 700;
- color: white;
- font-size: 37rpx;
- background-color: rgb(115,164,164);
- }
-
- .back{
- position: absolute;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 3%;
- height: 3%;
- top: 2%;
- left: 3%;
- //testing
- // border: 1px solid rgb(255,0,0);
- }
-
- .blue{
- position: absolute;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 7%;
- height: 7%;
- top: 1%;
- right: 3%;
- border-radius: 50%;
- width: 75rpx;
- height: 75rpx;
- border-radius: 50%;
- overflow: hidden;
- image{
- width: 100%;
- height: 75rpx;
- }
- }
- .content{
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width:100%;
- height:100%;
- }
-
- .result-area{
- display: flex;
- align-items: center;
- justify-content: center;
- width:90%;
- height: 500rpx;
- margin: 1%;
- border-radius: 25rpx;
- background-color: rgb(115,164,164);
- text-align: center;
- font-size: 40rpx;
- font-weight: 700;
- color: #4D857C;
- image{
- margin-top: 10%;
- }
- .border{
- border: 2rpx solid #F4F4F4;
- height: 90%;
- width: 90%;
- border-radius: 25rpx;
- view{
- margin-top: 5%;
- }
- }
- }
-
- .item-logo
- {
- z-index: 4;
- height: 20%;
- width: 15%;
- // margin: 1%;
- }
-
- .help{
- color: azure;
- background-color: rgb(0,0,0);
- }
-
-
- .input-area{
- width:90%;
- height:60%;
- margin: 1%;
- font-size: 36rpx;
- view{
- height: 160rpx;
- line-height: 160rpx;
- }
- .weight{
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- width:100%;
- margin: 1%;
- border-radius: 25rpx;
- background: #FEEBEA;
- color: #7B784E;
- font-weight: bold;
- input{
- width: 75%;
- background: #FBCDCC;
- border-radius: 20rpx;
- }
- }
-
- .high{
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- width:100%;
- margin: 1%;
- border-radius: 25rpx;
- background: #FBF0EA;
- color: #7B784E;
- font-weight: bold;
- input{
- width: 75%;
- background: #F5DACB;
- border-radius: 20rpx;
- }
- }
-
- .age{
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- width:100%;
- border-radius: 25rpx;
- background: #EFEEE7;
- color: #7B784E;
- font-weight: bold;
- input{
- width: 75%;
- background: #D8D7C5;
- border-radius: 20rpx;
- }
- }
- .Company{
- position: absolute;
- right: 15%;
- }
-
- .input-title{
- //testing
- // border: 1px solid rgb(255,0,0);
- }
- .input{
- font-family: PingFang SC;
- font-weight: 500;
- color: #848484;
- // text-align:center;
- font-size: 46rpx;
- height: 100rpx;
- padding-left: 20rpx;
- margin-left: 15rpx;
- }
- }
-
- .confirm{
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width:90%;
- height:7%;
- margin: 10%;
- background: #B6D4CF;
- border-radius: 24rpx;
- color: #4D857C;
- font-weight: bold;
- font-size: 49rpx;
- }
- </style>
|