heartRhythms.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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. <!-- <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 = "";
  61. this.age = "";
  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. border-radius: 50%;
  183. width: 75rpx;
  184. height: 75rpx;
  185. border-radius: 50%;
  186. overflow: hidden;
  187. image{
  188. width: 100%;
  189. height: 75rpx;
  190. }
  191. }
  192. .content{
  193. display: flex;
  194. flex-direction: column;
  195. align-items: center;
  196. justify-content: center;
  197. width:100%;
  198. height:100%;
  199. }
  200. .result-area{
  201. display: flex;
  202. align-items: center;
  203. justify-content: center;
  204. width:95%;
  205. height:30%;
  206. margin: 1%;
  207. border-radius: 25rpx;
  208. background-color: #F2CDB7;
  209. text-align: center;
  210. font-size: 44rpx;
  211. font-weight: 700;
  212. color: #BE7F59;
  213. image{
  214. margin-top: 10%;
  215. }
  216. .border{
  217. border: 4rpx solid #F4F4F4;
  218. height: 90%;
  219. width: 90%;
  220. border-radius: 25rpx;
  221. view{
  222. margin-top: 5%;
  223. }
  224. }
  225. }
  226. .help{
  227. color: azure;
  228. background-color: rgb(0,0,0);
  229. }
  230. .input-area{
  231. height:60%;
  232. margin: 1%;
  233. .static-heart-rate{
  234. display: flex;
  235. flex-direction: row;
  236. align-items: center;
  237. justify-content: center;
  238. width:100%;
  239. height:300rpx;
  240. margin-top: 3%;
  241. border-radius: 25rpx;
  242. color: #7B784E;
  243. font-weight: bold;
  244. font-size: 30rpx;
  245. flex-wrap: wrap;
  246. background: #FDEFEE;
  247. .input-block
  248. {
  249. display: flex;
  250. flex-direction: row;
  251. align-items: center;
  252. justify-content: center;
  253. width:100%;
  254. }
  255. .heart-rate-help
  256. {
  257. // position: absolute;
  258. // right: 40%;
  259. //testing
  260. // border: 1px solid rgb(255,0,0);
  261. }
  262. input{
  263. width: 75%;
  264. background: #D8D7C5;
  265. border-radius: 20rpx;
  266. }
  267. }
  268. .age{
  269. display: flex;
  270. flex-direction: row;
  271. align-items: center;
  272. justify-content: center;
  273. width:100%;
  274. height:220rpx;
  275. border-radius: 25rpx;
  276. background-color: #EFEEE7;
  277. font-size: 30rpx;
  278. color: #7B784E;
  279. font-weight: bold;
  280. input{
  281. height: 120rpx;
  282. }
  283. }
  284. .input-title{
  285. margin-right: 1%;
  286. //testing
  287. // border: 1px solid rgb(255,0,0);
  288. }
  289. .input{
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. background: #F4F4F4;
  294. border-radius: 4upx;
  295. font-size: 28upx;
  296. line-height: 70upx;
  297. font-family: PingFang SC;
  298. font-weight: 500;
  299. color: #848484;
  300. text-align:center;
  301. margin: 1%;
  302. width: 75%;
  303. height: 120rpx;
  304. background: #D8D7C5;
  305. border-radius: 20rpx;
  306. font-size: 46rpx;
  307. }
  308. }
  309. .confirm{
  310. display: flex;
  311. flex-direction: column;
  312. align-items: center;
  313. justify-content: center;
  314. width:95%;
  315. height:7%;
  316. margin: 1%;
  317. background: #F2CDB7;
  318. border-radius: 24rpx;
  319. font-size: 49rpx;
  320. font-weight: bold;
  321. color: #BE7F59;
  322. }
  323. .Company{
  324. position: absolute;
  325. right: 13%;
  326. }
  327. </style>