figure.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="flgure-box">
  3. <view class="pages-box">
  4. <view class="fs32 fc99">请输入您的身高体重</view>
  5. <view class="inp-box">
  6. <input @input="heightFun" class="inp" placeholder="身高/cm" placeholderStyle="font-size:30rpx" type="digit" />
  7. <view class="inpimg">
  8. <image class="pagesimg" src="@/static/images/height.png"></image>
  9. </view>
  10. </view>
  11. <view class="inp-box">
  12. <input @input="weightFun" class="inp" placeholder="体重/kg" placeholderStyle="font-size:30rpx" type="digit" />
  13. <view class="inpimg">
  14. <image class="pagesimg" src="@/static/images/weight.png"></image>
  15. </view>
  16. </view>
  17. <view class="btn-box">
  18. <button @tap="getdata" class="btn fs32">计 算</button>
  19. </view>
  20. </view>
  21. <view :class="'det-box ' + (show ? '' : 'dp-n')">
  22. <view class="pg-t fs36 fc99">计算结果</view>
  23. <view class="pglist fc99 figure">
  24. <image class="figureimg" :src="res.img"></image>
  25. </view>
  26. <view class="pglist fc99">
  27. <view class="pg-l fs32">测试结果:</view>
  28. <view class="pg-r fs32">{{ res.msg }}</view>
  29. </view>
  30. <view class="pglist fc99">
  31. <view class="pg-l fs32">理想体重:</view>
  32. <view class="pg-r fs32">{{ res.ideal }}</view>
  33. </view>
  34. <view class="pglist fc99 bd-n">
  35. <view class="pg-l fs32">BMI:</view>
  36. <view class="pg-r fs32">{{ res.bmi }}</view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. height: '',
  46. weight: '',
  47. show: false,
  48. res: {
  49. img: '',
  50. msg: '',
  51. ideal: '',
  52. bmi: ''
  53. }
  54. };
  55. },
  56. onShareAppMessage: function () {},
  57. methods: {
  58. heightFun: function (i) {
  59. this.height=i.detail.value;
  60. },
  61. weightFun: function (i) {
  62. this.weight=i.detail.value;
  63. },
  64. getdata: function (i) {
  65. uni.showLoading({
  66. title: '计算中'
  67. });
  68. var e = this.height;
  69. var t = this.weight;
  70. if ('' == e || '' == t) {
  71. uni.showToast({
  72. title: '请输入身高体重',
  73. icon: 'none',
  74. duration: 2000
  75. });
  76. return false;
  77. }
  78. if (isNaN(e) || isNaN(t)) {
  79. uni.showToast({
  80. title: '请正确输入!',
  81. icon: 'none',
  82. duration: 2000
  83. });
  84. } else {
  85. var a = 0.9 * (e - 100);
  86. var s = t / ((e / 100) * (e / 100));
  87. if (s < 18.5) {
  88. this.show=true;
  89. this.res={
  90. img: '/static/images/bq4.png',
  91. msg: '你的体重太轻,要多吃点哟!',
  92. ideal: a,
  93. bmi: s
  94. };
  95. } else {
  96. if (s >= 18.5 && s < 25) {
  97. this.show=true;
  98. this.res={
  99. img: '/static/images/bq1.png',
  100. msg: '亲,你的体重正常,要继续保持哟',
  101. ideal: a,
  102. bmi: s
  103. };
  104. } else {
  105. if(s >= 25 && s < 30){
  106. this.show=true;
  107. this.res={
  108. img: '/static/images/bq3.png',
  109. msg: '亲,您的体重过重,要减肥了!',
  110. ideal: a,
  111. bmi: s
  112. };
  113. }else{
  114. this.show=true;
  115. this.res={
  116. img: '/static/images/bq2.png',
  117. msg: '亲,你确实要减肥了!',
  118. ideal: a,
  119. bmi: s
  120. }
  121. }
  122. }
  123. }
  124. uni.hideLoading();
  125. }
  126. }
  127. }
  128. };
  129. </script>
  130. <style>
  131. @import './figure.css';
  132. </style>