bloodSugarDetail.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="container">
  3. <view class="datebox">
  4. <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
  5. <view class="datebox-item border-line flex-bt">
  6. <view>日期</view>
  7. <view class="datebox-item-right">
  8. <text :class="date ? '':'default'">{{date ? date : "请选择日期"}}</text>
  9. <image src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png"></image>
  10. </view>
  11. </view>
  12. </picker>
  13. <picker mode="time" :value="time" @change="bindTimeChange">
  14. <view class="datebox-item flex-bt">
  15. <view>测量时间</view>
  16. <view class="datebox-item-right">
  17. <text :class="time ? '':'default'">{{time ? time : "请选择测量时间"}}</text>
  18. <image src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png"></image>
  19. </view>
  20. </view>
  21. </picker>
  22. </view>
  23. <view class="datebox-detail">
  24. <view class="datebox-detail-header flex-bt">
  25. <view>血糖</view>
  26. <view class="datebox-detail-header-right">
  27. <text class="num">{{active}}</text>
  28. <text>mmol/L</text>
  29. </view>
  30. </view>
  31. <view class="scale">
  32. <simpleScale ref="simpleScale" :minVal="0" :maxVal="33" :int="false" :single="10" :h="h" :active="active" :scroll="false" :style="style"
  33. @value="getScroll" />
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import simpleScale from "@/pages_watch/components/simpleScale/simpleScale.vue"
  40. import { bgInfo } from "@/api/pages_watch/healthMonitoring.js"
  41. export default {
  42. components: {
  43. simpleScale
  44. },
  45. data() {
  46. return {
  47. // 表示有效日期范围的开始,字符串格式为"YYYY-MM-DD"
  48. startDate: "2020-01-01",
  49. // 表示有效日期范围的结束,字符串格式为"YYYY-MM-DD"
  50. endDate: this.$timeFormat(new Date()),
  51. date: "2024-01-01",
  52. time: "17:12",
  53. active: "0",
  54. loading: false,
  55. style: {
  56. line: '#ccc',
  57. bginner: '#fbfbfb',
  58. bgoutside: '#ffffff',
  59. fontColor: '#333',
  60. fontSize: 16
  61. },
  62. h: uni.upx2px(88)
  63. }
  64. },
  65. onLoad(option) {
  66. const param = JSON.parse(option.param)
  67. this.date = param.createTime && param.createTime.split(' ')[0]
  68. this.time = param.createTime && param.createTime.substring(11, 16)
  69. this.active = String(param.num || 0)
  70. this.$nextTick(()=>{
  71. this.$refs.simpleScale.init()
  72. })
  73. },
  74. methods: {
  75. bindDateChange(e) {
  76. this.date = e.detail.value
  77. this.getList()
  78. },
  79. bindTimeChange(e) {
  80. this.time = e.detail.value
  81. this.getList()
  82. },
  83. getScroll(e) {
  84. this.active = e
  85. },
  86. // 查询数据
  87. getList() {
  88. this.loading = true
  89. const param = {
  90. startTime: this.date.replace(/-/g, '/') +" " +this.time + ":00",
  91. endTime: this.date.replace(/-/g, '/') +" " + this.time + ":59",
  92. deviceId: uni.getStorageSync("deviceId"),
  93. }
  94. bgInfo(param).then(res => {
  95. this.loading = false
  96. if (res.code == 200) {
  97. if(res.data && res.data.length > 0) {
  98. this.date = res.data[0].createTime && res.data[0].createTime.split(' ')[0]
  99. this.time = res.data[0].createTime && res.data[0].createTime.substring(11, 16)
  100. this.active = String(res.data[0].bloodGlucose || 0)
  101. } else {
  102. this.active = "0"
  103. }
  104. } else {
  105. this.active = "0"
  106. }
  107. this.$nextTick(()=>{
  108. this.$refs.simpleScale.init()
  109. })
  110. }).catch(() => {
  111. this.loading = false
  112. })
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. @mixin u-flex($flexD, $alignI, $justifyC) {
  119. display: flex;
  120. flex-direction: $flexD;
  121. align-items: $alignI;
  122. justify-content: $justifyC;
  123. }
  124. .flex-bt {
  125. @include u-flex(row, center, space-between);
  126. }
  127. .default {
  128. font-weight: 400;
  129. font-size: 28rpx;
  130. color: #999999;
  131. }
  132. .container {
  133. padding: 20rpx 24rpx;
  134. font-family: PingFang SC, PingFang SC;
  135. font-weight: 500;
  136. font-size: 32rpx;
  137. color: #333333;
  138. }
  139. .datebox {
  140. padding: 0 32rpx;
  141. margin-bottom: 20rpx;
  142. background: #FFFFFF;
  143. border-radius: 16rpx 16rpx 16rpx 16rpx;
  144. &-item {
  145. height: 120rpx;
  146. &-right {
  147. font-weight: 400;
  148. font-size: 32rpx;
  149. @include u-flex(row, center, flex-start);
  150. image {
  151. width: 48rpx;
  152. height: 48rpx;
  153. }
  154. }
  155. }
  156. }
  157. .datebox-detail {
  158. background: #FFFFFF;
  159. border-radius: 16rpx 16rpx 16rpx 16rpx;
  160. padding: 40rpx 32rpx;
  161. &-header-right {
  162. flex-shrink: 0;
  163. font-weight: 400;
  164. font-size: 28rpx;
  165. color: #999999;
  166. .num {
  167. font-size: 48rpx;
  168. color: #333333;
  169. margin-right: 14rpx;
  170. }
  171. }
  172. }
  173. .scale {
  174. height: 176rpx;
  175. margin-top: 36rpx;
  176. overflow: hidden;
  177. background: #FFFFFF;
  178. box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(170,170,170,0.1);
  179. border-radius: 0rpx 0rpx 0rpx 0rpx;
  180. border: 2rpx solid #ECECEC;
  181. // width: 200rpx;
  182. // height: 600rpx;
  183. }
  184. </style>