basalMetabolism.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <view class="container">
  3. <view class="navigation-bar">基础代谢率</view>
  4. <view class="back" @click="onBack(0, $event)">
  5. <image src="/static/backArrow.png" mode="aspectFit" style="width:100%"></image>
  6. </view>
  7. <view class="blue" @click="onHelp(0, $event)">
  8. <image src="../../static/home/blue.png" mode=""></image>
  9. </view>
  10. <view class="content">
  11. <view class="result-area">
  12. <view class="border">
  13. <image class="item-logo" src="../../static/home/basalMetabolismLogo.png" mode=""></image>
  14. <view class="">
  15. {{result}}
  16. </view>
  17. <!-- <view class="">
  18. 基础代谢率
  19. </view> -->
  20. </view>
  21. </view>
  22. <!-- <button class="help" @click="onHelp(0, $event)">宁哥笔记</button> -->
  23. <view class="input-area">
  24. <view class="age">
  25. <view class="input-title">年龄 : </view>
  26. <input class="input" type="number" placeholder="请输入年龄" v-model="age" />
  27. <text class="Company">岁</text>
  28. </view>
  29. <view class="high">
  30. <view class="input-title">身高 : </view>
  31. <input class="input" type="number" placeholder="请输入身高" v-model="high" />
  32. <text class="Company">厘米</text>
  33. </view>
  34. <view class="weight">
  35. <view class="input-title">体重 : </view>
  36. <!-- <input class="input" type="number" placeholder="请输入体重" v-model="weight" @input="onInput(0, $event)" :value="weight"/> -->
  37. <input class="input" type="number" placeholder="请输入体重" v-model="weight" />
  38. <text class="Company">公斤</text>
  39. </view>
  40. </view>
  41. <button class="confirm" @click="onClick(0, $event)">确定</button>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. weight:-1,
  50. high:-1,
  51. age:-1,
  52. //基础代谢率
  53. bmr:-1,
  54. result:'0',
  55. }
  56. },
  57. onLoad() {
  58. this.weight = "";
  59. this.high = "";
  60. this.age = "";
  61. // console.log('gender=',getApp().globalData.gender)
  62. // console.log('weight=',getApp().globalData.weight)
  63. // console.log('high=',getApp().globalData.high)
  64. // console.log('age=',getApp().globalData.age)
  65. if(getApp().globalData.weight != undefined)
  66. {
  67. this.weight = getApp().globalData.weight;
  68. }
  69. if(getApp().globalData.high != undefined)
  70. {
  71. this.high = getApp().globalData.high;
  72. }
  73. if(getApp().globalData.age != undefined)
  74. {
  75. this.age = getApp().globalData.age;
  76. }
  77. },
  78. methods: {
  79. onBack: function(id,e) {
  80. //uni.navigateBack()//默认delta:1
  81. uni.navigateBack({
  82. delta:1,//返回层数,2则上上页
  83. })
  84. },
  85. onHelp: function(id,e) {
  86. uni.navigateTo({
  87. url: '/pages/basalMetabolism/help',
  88. animationType: 'slide-in-left',
  89. animationDuration: 2000,
  90. success: res => {},
  91. fail: () => {},
  92. complete: () => {}
  93. });
  94. },
  95. onClick: function(id,e) {
  96. if(this.weight != -1 && this.high !=-1 && this.age != -1)
  97. {
  98. let gender = getApp().globalData.gender;
  99. getApp().globalData.weight = this.weight;
  100. getApp().globalData.high = this.high;
  101. getApp().globalData.age = this.age;
  102. if(gender == 0)
  103. {
  104. this.bmr = 66+13.7*this.weight+5*this.high-6.8*this.age;
  105. }
  106. else
  107. {
  108. this.bmr = 655+9.6*this.weight+1.8*this.high-4.7*this.age;
  109. }
  110. this.result = '你的基础代谢率为: '+ Math.round(this.bmr) + '千卡';
  111. getApp().globalData.bmr = this.bmr;
  112. }
  113. else
  114. {
  115. switch (id)
  116. {
  117. case 0:
  118. alert('请输入体重');
  119. break;
  120. case 1:
  121. alert('请输入身高');
  122. break;
  123. case 2:
  124. alert('请输入年龄');
  125. break;
  126. default:
  127. break;
  128. }
  129. }
  130. },
  131. }
  132. }
  133. </script>
  134. <style lang="scss">
  135. .container {
  136. // display: flex;
  137. // flex-direction: column;
  138. // align-items: center;
  139. // justify-content: center;
  140. width:100%;
  141. // height: 100vh;
  142. }
  143. .navigation-bar
  144. {
  145. display: flex;
  146. align-items: center;
  147. justify-content: center;
  148. width: 100%;
  149. height: 120rpx;
  150. font-weight: 700;
  151. color: white;
  152. font-size: 37rpx;
  153. background-color: rgb(115,164,164);
  154. }
  155. .back{
  156. position: absolute;
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. width: 3%;
  161. height: 3%;
  162. top: 2%;
  163. left: 3%;
  164. //testing
  165. // border: 1px solid rgb(255,0,0);
  166. }
  167. .blue{
  168. position: absolute;
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. width: 7%;
  173. height: 7%;
  174. top: 1%;
  175. right: 3%;
  176. border-radius: 50%;
  177. width: 75rpx;
  178. height: 75rpx;
  179. border-radius: 50%;
  180. overflow: hidden;
  181. image{
  182. width: 100%;
  183. height: 75rpx;
  184. }
  185. }
  186. .content{
  187. display: flex;
  188. flex-direction: column;
  189. align-items: center;
  190. justify-content: center;
  191. width:100%;
  192. height:100%;
  193. }
  194. .result-area{
  195. display: flex;
  196. align-items: center;
  197. justify-content: center;
  198. width:90%;
  199. height: 500rpx;
  200. margin: 1%;
  201. border-radius: 25rpx;
  202. background-color: rgb(115,164,164);
  203. text-align: center;
  204. font-size: 40rpx;
  205. font-weight: 700;
  206. color: #4D857C;
  207. image{
  208. margin-top: 10%;
  209. }
  210. .border{
  211. border: 2rpx solid #F4F4F4;
  212. height: 90%;
  213. width: 90%;
  214. border-radius: 25rpx;
  215. view{
  216. margin-top: 5%;
  217. }
  218. }
  219. }
  220. .item-logo
  221. {
  222. z-index: 4;
  223. height: 20%;
  224. width: 15%;
  225. // margin: 1%;
  226. }
  227. .help{
  228. color: azure;
  229. background-color: rgb(0,0,0);
  230. }
  231. .input-area{
  232. width:90%;
  233. height:60%;
  234. margin: 1%;
  235. font-size: 36rpx;
  236. view{
  237. height: 160rpx;
  238. line-height: 160rpx;
  239. }
  240. .weight{
  241. display: flex;
  242. flex-direction: row;
  243. align-items: center;
  244. justify-content: center;
  245. width:100%;
  246. margin: 1%;
  247. border-radius: 25rpx;
  248. background: #FEEBEA;
  249. color: #7B784E;
  250. font-weight: bold;
  251. input{
  252. width: 75%;
  253. background: #FBCDCC;
  254. border-radius: 20rpx;
  255. }
  256. }
  257. .high{
  258. display: flex;
  259. flex-direction: row;
  260. align-items: center;
  261. justify-content: center;
  262. width:100%;
  263. margin: 1%;
  264. border-radius: 25rpx;
  265. background: #FBF0EA;
  266. color: #7B784E;
  267. font-weight: bold;
  268. input{
  269. width: 75%;
  270. background: #F5DACB;
  271. border-radius: 20rpx;
  272. }
  273. }
  274. .age{
  275. display: flex;
  276. flex-direction: row;
  277. align-items: center;
  278. justify-content: center;
  279. width:100%;
  280. border-radius: 25rpx;
  281. background: #EFEEE7;
  282. color: #7B784E;
  283. font-weight: bold;
  284. input{
  285. width: 75%;
  286. background: #D8D7C5;
  287. border-radius: 20rpx;
  288. }
  289. }
  290. .Company{
  291. position: absolute;
  292. right: 15%;
  293. }
  294. .input-title{
  295. //testing
  296. // border: 1px solid rgb(255,0,0);
  297. }
  298. .input{
  299. font-family: PingFang SC;
  300. font-weight: 500;
  301. color: #848484;
  302. // text-align:center;
  303. font-size: 46rpx;
  304. height: 100rpx;
  305. padding-left: 20rpx;
  306. margin-left: 15rpx;
  307. }
  308. }
  309. .confirm{
  310. display: flex;
  311. flex-direction: column;
  312. align-items: center;
  313. justify-content: center;
  314. width:90%;
  315. height:7%;
  316. margin: 10%;
  317. background: #B6D4CF;
  318. border-radius: 24rpx;
  319. color: #4D857C;
  320. font-weight: bold;
  321. font-size: 49rpx;
  322. }
  323. </style>