dayCalorie.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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/red.png" mode="aspectFit" style="width:100%"></image>
  9. </view>
  10. <view class="content">
  11. <view class="result-area">
  12. <view class="border">
  13. <image class="item-logo" src="../../static/home/dayCalorieLogo.png" mode=""></image>
  14. <view class="">
  15. {{resultStr}}千卡
  16. </view>
  17. <!-- <view class="">
  18. 基础代谢率
  19. </view> -->
  20. </view>
  21. </view>
  22. <!-- <button class="help" @click="onHelp(0, $event)">宁哥笔记</button> -->
  23. <view class="select-area">
  24. <view :class="(selected != index)?'block':'block-selected'":style="{background:backList[index%6]}" v-for="(option,index) in optionArr" @click="onClick(index, $event)">{{option}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. resultStr:'0',
  34. optionArr:[
  35. '办公室久坐没有什么运动',
  36. '每周轻松1-3次运动',
  37. '每周中等强度3-5次',
  38. '每周大强度运动5-7次以上',
  39. '大强度训练每周8次以上',
  40. ],
  41. backList:['#F2CDB7', '#F1F1EC','#E9F2F1','#FDEFEE','#FBF0EA'],
  42. selected:0,
  43. }
  44. },
  45. onLoad() {
  46. if(getApp().globalData.bmr !=undefined)
  47. {
  48. let calorie = getApp().globalData.bmr * 1.2;
  49. this.resultStr = '每天消耗的总热量: ' + Math.round(calorie);
  50. }
  51. else
  52. {
  53. uni.navigateBack({
  54. delta:1,
  55. animationType: 'slide-in-left',
  56. animationDuration: 2000,
  57. success: res => {
  58. alert('清先测量基础代谢');
  59. },
  60. fail: () => {},
  61. complete: () => {}
  62. });
  63. }
  64. },
  65. methods: {
  66. onBack: function(id,e) {
  67. //uni.navigateBack()//默认delta:1
  68. uni.navigateBack({
  69. delta:1,//返回层数,2则上上页
  70. })
  71. },
  72. onHelp: function(id,e) {
  73. uni.navigateTo({
  74. url: '/pages/dayCalorie/help',
  75. animationType: 'slide-in-left',
  76. animationDuration: 2000,
  77. success: res => {},
  78. fail: () => {},
  79. complete: () => {}
  80. });
  81. },
  82. onClick: function(id,e) {
  83. // console.log(id);
  84. this.selected = id;
  85. let calorie = -1;
  86. switch (id){
  87. case 0:
  88. calorie = getApp().globalData.bmr * 1.2;
  89. break;
  90. case 1:
  91. calorie = getApp().globalData.bmr * 1.375;
  92. break;
  93. case 2:
  94. calorie = getApp().globalData.bmr * 1.5;
  95. break;
  96. case 3:
  97. calorie = getApp().globalData.bmr * 1.725;
  98. break;
  99. case 4:
  100. calorie = getApp().globalData.bmr * 1.9;
  101. break;
  102. default:
  103. break;
  104. }
  105. getApp().globalData.calorie = calorie;
  106. this.resultStr = '每天消耗的总热量: ' + Math.round(calorie) + '千卡';
  107. },
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. .container {
  113. display: flex;
  114. flex-direction: column;
  115. align-items: center;
  116. justify-content: center;
  117. width:100%;
  118. height: 100vh;
  119. }
  120. .navigation-bar
  121. {
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. width: 100%;
  126. height: 8%;
  127. font-weight: 700;
  128. color: white;
  129. font-size: 37rpx;
  130. background-color: #FABAB9;
  131. }
  132. .item-logo
  133. {
  134. z-index: 4;
  135. height: 20%;
  136. width: 11%;
  137. }
  138. .back{
  139. position: absolute;
  140. display: flex;
  141. align-items: center;
  142. justify-content: center;
  143. width: 3%;
  144. height: 3%;
  145. top: 2%;
  146. left: 3%;
  147. //testing
  148. // border: 1px solid rgb(255,0,0);
  149. }
  150. .blue{
  151. position: absolute;
  152. display: flex;
  153. align-items: center;
  154. justify-content: center;
  155. width: 7%;
  156. height: 7%;
  157. top: -1%;
  158. right: 3%;
  159. //testing
  160. // border: 1px solid rgb(255,0,0);
  161. }
  162. .content{
  163. display: flex;
  164. flex-direction: column;
  165. align-items: center;
  166. justify-content: center;
  167. width:100%;
  168. height:100%;
  169. }
  170. .result-area{
  171. display: flex;
  172. align-items: center;
  173. justify-content: center;
  174. width:90%;
  175. height:30%;
  176. margin: 1%;
  177. border-radius: 25rpx;
  178. background-color: #FABAB9;
  179. text-align: center;
  180. font-size: 44rpx;
  181. font-weight: 700;
  182. color: #4D857C;
  183. image{
  184. margin-top: 10%;
  185. }
  186. .border{
  187. border: 2rpx solid #F4F4F4;
  188. height: 90%;
  189. width: 90%;
  190. border-radius: 25rpx;
  191. view{
  192. margin-top: 5%;
  193. }
  194. }
  195. }
  196. .help{
  197. color: azure;
  198. background-color: rgb(0,0,0);
  199. }
  200. .select-area{
  201. display: flex;
  202. flex-direction: column;
  203. align-items: center;
  204. justify-content: center;
  205. width:90%;
  206. height:60%;
  207. margin: 1%;
  208. view{
  209. height: 142rpx;
  210. }
  211. }
  212. .block{
  213. width:100%;
  214. margin: 1%;
  215. font-size: 30rpx;
  216. font-weight: bold;
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. background-color: rgb(115,164,164);
  221. }
  222. .block-selected{
  223. width:100%;
  224. margin: 1%;
  225. font-weight: bold;
  226. display: flex;
  227. align-items: center;
  228. justify-content: center;
  229. background-color: rgb(115,164,164);
  230. box-shadow: 0rpx 12rpx 16rpx 0rpx rgba(0, 0, 0, 0.22);
  231. }
  232. .confirm{
  233. display: flex;
  234. flex-direction: column;
  235. align-items: center;
  236. justify-content: center;
  237. width:90%;
  238. height:7%;
  239. margin: 1%;
  240. background: #FABAB9;
  241. border-radius: 24rpx;
  242. color: #C65E5C;
  243. font-weight: bold;
  244. font-size: 49rpx;
  245. }
  246. </style>