home.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. <view class="row">
  9. <view class="block" style="background-color: #EBF3F2;">
  10. <view class="item-bg" style="background-color: #B6D4CF ;">
  11. <view class="item" style="background-color: #B6D4CF ;" @click="onClick(0, $event)">
  12. <image class="item-logo" src="/static/home/basalMetabolismLogo.png" mode="aspectFit"></image>
  13. <view class="item-title" style="color: #4D857C;">基础代谢率</view>
  14. <image class="item-unlock-logo" src="/static/home/basalMetabolismUnlock.png" mode="aspectFit"></image>
  15. </view>
  16. </view>
  17. <view class="label" style="background-color: #D8E8E5 ; color: #4D857C;">基础代谢: {{bmr}}</view>
  18. </view>
  19. <view class="block" style="background-color: #FEECEC;">
  20. <view class="item-bg" style="background-color: #FABAB9;">
  21. <view class="item" style="background-color: #FABAB9;" @click="onClick(1, $event)">
  22. <image class="item-logo" src="/static/home/dayCalorieLogo.png" mode="aspectFit"></image>
  23. <view class="item-title" style="color: #C65E5C;">每天消耗总热量</view>
  24. <image class="item-unlock-logo" src="/static/home/dayCalorieUnlock.png" mode="aspectFit"></image>
  25. </view>
  26. </view>
  27. <view class="label" style="background-color: #FCD9D9 ; color: #C65E5C;">每日消耗总热量: {{calorie}}</view>
  28. </view>
  29. </view>
  30. <view class="row">
  31. <view class="block" style="background-color: #FCF1EB;">
  32. <view class="item-bg" style="background-color: #F2CDB7;">
  33. <view class="item" style="background-color: #F2CDB7;" @click="onClick(2, $event)">
  34. <image class="item-logo" src="/static/home/heartRhythmsLogo.png" mode="aspectFit"></image>
  35. <view class="item-title" style="color: #BE7F59;">有氧运动心律</view>
  36. <image class="item-unlock-logo" src="/static/home/heartRhythmsUnlock.png" mode="aspectFit"></image>
  37. </view>
  38. </view>
  39. <view class="label" style="background-color: #F8E3D8; color: #BE7F59;">最低有氧心率:{{lowestHeartRate}}</view>
  40. <view class="label" style="background-color: #F8E3D8; color: #BE7F59;">最高有氧心率:{{highestHeartRate}}</view>
  41. </view>
  42. <view class="block" style="background-color: #F0F0E9;">
  43. <view class="item-bg" style="background-color: #C9C7AF;">
  44. <view class="item" style="background-color: #C9C7AF;" @click="onClick(3, $event)">
  45. <image class="item-logo" src="/static/home/bodyFatRatioLogo.png" mode="aspectFit"></image>
  46. <view class="item-title" style="color: #7B784E;">体脂率</view>
  47. <image class="item-unlock-logo" src="/static/home/bodyFatRatioUnlock.png" mode="aspectFit"></image>
  48. </view>
  49. </view>
  50. <view class="label" style="background-color: #E2E1D3; color: #7B784E;">脂肪总重量:{{fatWeight}}</view>
  51. <view class="label" style="background-color: #E2E1D3; color: #7B784E;">体脂率:{{fatRate}}</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. return {
  61. gender:0,
  62. weight:0,
  63. high:0,
  64. age:0,
  65. waist:0,
  66. bmr:0,
  67. calorie:0,
  68. heartRate:0,
  69. lowestHeartRate:0,
  70. highestHeartRate:0,
  71. fatWeight:0,
  72. fatRate:0,
  73. }
  74. },
  75. onShow() {
  76. if(getApp().globalData.bmr != undefined)
  77. {
  78. this.bmr = Math.round(getApp().globalData.bmr);
  79. }
  80. if(getApp().globalData.calorie != undefined)
  81. {
  82. this.calorie = Math.round(getApp().globalData.calorie);
  83. }
  84. if(getApp().globalData.lowestHeartRate != undefined)
  85. {
  86. this.lowestHeartRate = Math.round(getApp().globalData.lowestHeartRate);
  87. }
  88. if(getApp().globalData.highestHeartRate != undefined)
  89. {
  90. this.highestHeartRate = Math.round(getApp().globalData.highestHeartRate);
  91. }
  92. if(getApp().globalData.fatWeight != undefined)
  93. {
  94. this.fatWeight = Math.round(getApp().globalData.fatWeight);
  95. }
  96. if(getApp().globalData.fatRate != undefined)
  97. {
  98. this.fatRate = Math.round(getApp().globalData.fatRate);
  99. }
  100. },
  101. methods: {
  102. onBack: function(id,e) {
  103. //uni.navigateBack()//默认delta:1
  104. uni.navigateBack({
  105. delta:1,//返回层数,2则上上页
  106. })
  107. },
  108. onClick: function(id,e) {
  109. // console.log(id); // 1
  110. // console.log(e); // 事件对象
  111. const that = this
  112. switch (id){
  113. case 0:
  114. {
  115. uni.navigateTo({
  116. url: "/pages/basalMetabolism/basalMetabolism",
  117. });
  118. }
  119. break;
  120. case 1:
  121. {
  122. if(that.bmr != "0"){
  123. uni.navigateTo({
  124. url: "/pages/dayCalorie/dayCalorie",
  125. });
  126. }else{
  127. alert("请先测试基础代谢率")
  128. }
  129. }
  130. break;
  131. case 2:
  132. {
  133. uni.navigateTo({
  134. url: "/pages/heartRhythms/heartRhythms",
  135. });
  136. }
  137. break;
  138. case 3:
  139. {
  140. uni.navigateTo({
  141. url: "/pages/bodyFatRatio/bodyFatRatio",
  142. });
  143. }
  144. break;
  145. default:
  146. break;
  147. }
  148. },
  149. }
  150. }
  151. </script>
  152. <style lang="scss">
  153. .container {
  154. display: flex;
  155. flex-direction: column;
  156. align-items: center;
  157. justify-content: center;
  158. width:100%;
  159. height: 100vh;
  160. // 测试
  161. // border: 1px solid rgb(255,0,0);
  162. // box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 1);
  163. // border-bottom: 1px solid #DDDDDD;
  164. }
  165. .navigation-bar
  166. {
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. width:100%;
  171. height: 6%;
  172. font-weight: 700;
  173. color: black;
  174. font-size: 54rpx;
  175. background-color: white;
  176. // testing
  177. // border: 1px solid rgb(255,0,0);
  178. // background-color: rgb(253,222,157);
  179. }
  180. .back{
  181. position: absolute;
  182. display: flex;
  183. align-items: center;
  184. justify-content: center;
  185. width: 2%;
  186. height: 2%;
  187. top: 2.5%;
  188. left: 3%;
  189. //testing
  190. // border: 1px solid rgb(255,0,0);
  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. // border: 3px solid rgb(144,238,144);
  200. }
  201. .row{
  202. display: flex;
  203. flex-direction: row;
  204. align-items: center;
  205. justify-content: center;
  206. width:100%;
  207. height: 50%;
  208. // 测试
  209. // margin: 10rpx;
  210. // border: 3px solid rgb(144,238,144);
  211. }
  212. .block{
  213. display: flex;
  214. flex-direction: column;
  215. align-items: center;
  216. justify-content: center;
  217. width:100%;
  218. height:100%;
  219. }
  220. .item-bg{
  221. display: flex;
  222. align-items: center;
  223. justify-content: center;
  224. width:90%;
  225. height:70%;
  226. margin: 5%;
  227. }
  228. .item{
  229. display: flex;
  230. flex-direction: column;
  231. align-items: center;
  232. justify-content: center;
  233. height: 80%;
  234. width: 80%;
  235. border: 3px solid #FFFFFF;
  236. // 测试
  237. // margin: 10rpx;
  238. // border: 1px solid rgb(0,0,255);
  239. }
  240. .item-logo
  241. {
  242. z-index: 4;
  243. height: 30%;
  244. width: 30%;
  245. // margin: 1%;
  246. }
  247. .item-title
  248. {
  249. font-size: 46rpx;
  250. font-weight: 700;
  251. margin: 2%;
  252. }
  253. .item-unlock-logo
  254. {
  255. height: 40%;
  256. width: 40%;
  257. }
  258. .label
  259. {
  260. display: flex;
  261. align-items: center;
  262. justify-content: center;
  263. font-size: 40rpx;
  264. font-weight: 700;
  265. width:90%;
  266. height:10%;
  267. margin: 5%;
  268. // 测试
  269. // margin: 10rpx;
  270. // border: 1px solid rgb(0,0,255);
  271. }
  272. /* 解决⼩程序和app滚动条的问题 */
  273. /* #ifdef MP-WEIXIN || APP-PLUS */
  274. ::-webkit-scrollbar {
  275. display: none;
  276. width: 0 !important;
  277. height: 0 !important;
  278. -webkit-appearance: none;
  279. background: transparent;
  280. color: transparent;
  281. }
  282. /* #endif */
  283. /* 解决H5 的问题 */
  284. /* #ifdef H5 */
  285. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  286. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  287. display: none;
  288. width: 0 !important;
  289. height: 0 !important;
  290. -webkit-appearance: none;
  291. background: transparent;
  292. color: transparent;
  293. }
  294. /* #endif */
  295. </style>