heartRhythms.vue 7.1 KB

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