heartRhythms.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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="content">
  8. <text class="result-area">{{result}}</text>
  9. <button class="help" @click="onHelp(0, $event)">宁哥笔记</button>
  10. <view class="input-area">
  11. <view class="age">
  12. <view class="input-title">年龄 : </view>
  13. <input class="input" type="number" placeholder="请输入年龄" v-model="age" />
  14. </view>
  15. <view class="static-heart-rate">
  16. <view class="input-block">
  17. <view class="input-title">静态心率 : </view>
  18. <input class="input" type="number" placeholder="请输入静态心率" v-model="heartRate" />
  19. <button class="heart-rate-help" @click="onClickHelp(0, $event)">?</button>
  20. </view>
  21. </view>
  22. </view>
  23. <button class="confirm" @click="onClick(0, $event)">确定</button>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. age:-1,
  32. heartRate:-1,
  33. result:'',
  34. }
  35. },
  36. onLoad() {
  37. this.heartRate = 0;
  38. this.age = 0;
  39. // console.log('heartRate=',getApp().globalData.heartRate);
  40. // console.log('age=',getApp().globalData.age);
  41. if(getApp().globalData.heartRate != undefined)
  42. {
  43. this.heartRate = getApp().globalData.heartRate;
  44. }
  45. if(getApp().globalData.age != undefined)
  46. {
  47. this.age = getApp().globalData.age;
  48. }
  49. },
  50. methods: {
  51. onBack: function(id,e) {
  52. //uni.navigateBack()//默认delta:1
  53. uni.navigateBack({
  54. delta:1,//返回层数,2则上上页
  55. })
  56. },
  57. onHelp: function(id,e) {
  58. uni.navigateTo({
  59. url: '/pages/heartRhythms/help',
  60. animationType: 'slide-in-left',
  61. animationDuration: 2000,
  62. success: res => {},
  63. fail: () => {},
  64. complete: () => {}
  65. });
  66. },
  67. onClickHelp: function(id,e) {
  68. uni.navigateTo({
  69. url: '/pages/heartRhythms/staticHeartRateHelp',
  70. animationType: 'slide-in-left',
  71. animationDuration: 2000,
  72. success: res => {},
  73. fail: () => {},
  74. complete: () => {}
  75. });
  76. },
  77. onClick: function(id,e) {
  78. if(this.heartRate != -1 && this.age != -1)
  79. {
  80. getApp().globalData.heartRate = this.heartRate;
  81. getApp().globalData.age = this.age;
  82. let lowestHeartRate = 220 - this.age-(this.heartRate*0.55)+this.heartRate;
  83. let highestHeartRate = 220 - this.age-(this.heartRate*0.75)+this.heartRate;
  84. this.result = '你的最低有氧心率: '+ Math.round(lowestHeartRate) + '\n' + '最高有氧心率: '+ Math.round(highestHeartRate);
  85. getApp().globalData.lowestHeartRate = this.lowestHeartRate;
  86. getApp().globalData.highestHeartRate = this.highestHeartRate;
  87. }
  88. else
  89. {
  90. switch (id)
  91. {
  92. case 0:
  93. alert('请输入体重');
  94. break;
  95. case 1:
  96. alert('请输入身高');
  97. break;
  98. case 2:
  99. alert('请输入年龄');
  100. break;
  101. default:
  102. break;
  103. }
  104. }
  105. },
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. .container {
  111. display: flex;
  112. flex-direction: column;
  113. align-items: center;
  114. justify-content: center;
  115. width:100%;
  116. height: 100vh;
  117. }
  118. .navigation-bar
  119. {
  120. display: flex;
  121. align-items: center;
  122. justify-content: center;
  123. width: 100%;
  124. height: 10%;
  125. font-weight: 700;
  126. color: white;
  127. background-color: rgb(115,164,164);
  128. }
  129. .back{
  130. position: absolute;
  131. display: flex;
  132. align-items: center;
  133. justify-content: center;
  134. width: 2%;
  135. height: 2%;
  136. top: 3%;
  137. left: 1%;
  138. //testing
  139. // border: 1px solid rgb(255,0,0);
  140. }
  141. .content{
  142. display: flex;
  143. flex-direction: column;
  144. align-items: center;
  145. justify-content: center;
  146. width:100%;
  147. height:100%;
  148. }
  149. .result-area{
  150. display: flex;
  151. align-items: center;
  152. justify-content: center;
  153. width:60%;
  154. height:30%;
  155. margin: 1%;
  156. border-radius: 25rpx;
  157. background-color: rgb(115,164,164);
  158. }
  159. .help{
  160. color: azure;
  161. background-color: rgb(0,0,0);
  162. }
  163. .input-area{
  164. display: flex;
  165. flex-direction: column;
  166. align-items: center;
  167. justify-content: center;
  168. width:60%;
  169. height:60%;
  170. margin: 1%;
  171. .static-heart-rate{
  172. display: flex;
  173. flex-direction: row;
  174. align-items: center;
  175. justify-content: center;
  176. width:100%;
  177. height:100%;
  178. margin: 1%;
  179. border-radius: 25rpx;
  180. background-color: rgb(115,164,164);
  181. .input-block
  182. {
  183. display: flex;
  184. flex-direction: row;
  185. align-items: center;
  186. justify-content: center;
  187. width:40%;
  188. }
  189. .heart-rate-help
  190. {
  191. // position: absolute;
  192. // right: 40%;
  193. //testing
  194. // border: 1px solid rgb(255,0,0);
  195. }
  196. }
  197. .age{
  198. display: flex;
  199. flex-direction: row;
  200. align-items: center;
  201. justify-content: center;
  202. width:100%;
  203. height:100%;
  204. margin: 3%;
  205. border-radius: 25rpx;
  206. background-color: rgb(115,164,164);
  207. }
  208. .input-title{
  209. margin-right: 1%;
  210. //testing
  211. // border: 1px solid rgb(255,0,0);
  212. }
  213. .input{
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. background: #F4F4F4;
  218. border-radius: 4upx;
  219. height: 70upx;
  220. font-size: 28upx;
  221. line-height: 70upx;
  222. font-family: PingFang SC;
  223. font-weight: 500;
  224. color: #848484;
  225. text-align:center;
  226. margin: 1%;
  227. }
  228. }
  229. .confirm{
  230. display: flex;
  231. flex-direction: column;
  232. align-items: center;
  233. justify-content: center;
  234. width:10%;
  235. height:10%;
  236. margin: 1%;
  237. }
  238. </style>