bloodSugarAbnormal.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view>
  3. <myTabbar :tabList="tabList" :current="activeTab" @change="changeTab" />
  4. <!-- <swiper :current="activeTab" @change="onSwiperChange" :style="'height:' + clientHeight + 'px;'">
  5. <swiper-item v-for="(tab,index) in tabList" :key="index"> -->
  6. <scroll-view scroll-y="true" :style="'height:' + clientHeight + 'px;'" @scrolltolower="scrolltolower">
  7. <template v-if="list &&list.length > 0">
  8. <abnormalList :abnormalList="abnormalList" :unit="'mmol/L'" :type="'bs'" @monthChange="monthChange">
  9. <template v-slot:default="slotProps">
  10. <view :class="'slotview status'+slotProps.data.status" v-if="slotProps.data.status == 1">
  11. <text>高</text><text>风险</text>
  12. </view>
  13. <view :class="'slotview status'+slotProps.data.status" v-else>
  14. {{_typeText(slotProps.data.status)}}
  15. </view>
  16. </template>
  17. </abnormalList>
  18. </template>
  19. <view v-else>
  20. <myEmpty />
  21. </view>
  22. <!-- <view class="loading">
  23. <view class="tips" v-if="loadings === '0'">这是我的底线了~</view>
  24. <view class="tips" v-else-if="loadings === '1'">上拉加载更多...</view>
  25. <view class="imgs" v-else-if="loadings === '2'">
  26. <image src="load.png" mode=""></image>
  27. <text>加载中...</text>
  28. </view>
  29. </view> -->
  30. </scroll-view>
  31. <!-- </swiper-item>
  32. </swiper> -->
  33. </view>
  34. </template>
  35. <script>
  36. import abnormalList from "@/pages_watch/components/abnormalList/abnormalList.vue"
  37. import { bgInfoPage } from "@/api/pages_watch/healthMonitoring.js"
  38. import myTabbar from "@/pages_watch/components/myTabbar/myTabbar.vue"
  39. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue"
  40. export default {
  41. components: {
  42. abnormalList,
  43. myEmpty,
  44. myTabbar
  45. },
  46. data() {
  47. return {
  48. loading: false,
  49. isMore: true,
  50. activeTab: 0,
  51. tabList: [{
  52. id: 0,
  53. name: '全部'
  54. }, {
  55. id: 1,
  56. name: '高风险'
  57. }, {
  58. id: 2,
  59. name: '不良'
  60. }, {
  61. id: 3,
  62. name: '一般'
  63. }, {
  64. id: 4,
  65. name: '良好'
  66. }, {
  67. id: 5,
  68. name: '正常'
  69. }],
  70. clientHeight: 0,
  71. scrollViewId: 'scrollView0',
  72. queryParam: {
  73. startTime: undefined,
  74. endTime: undefined,
  75. deviceId: undefined,
  76. status: '',
  77. pageSize: 10,
  78. pageNum: 1,
  79. },
  80. total: 0,
  81. abnormalList: {},
  82. list: [],
  83. }
  84. },
  85. computed: {
  86. _typeText() {
  87. const txt = {
  88. 1: '高风险',
  89. 2: '不良',
  90. 3: '一般',
  91. 4: '良好',
  92. 5: '正常',
  93. }
  94. return (type) => {
  95. return txt[type] || ''
  96. }
  97. }
  98. },
  99. onLoad(option) {
  100. this.queryParam.startTime = option.startTime
  101. this.queryParam.endTime = option.endTime
  102. this.queryParam.deviceId = uni.getStorageSync("deviceId")
  103. this.refresh()
  104. },
  105. onReady() {
  106. uni.getSystemInfo({
  107. success: (res) => {
  108. this.clientHeight = res.windowHeight - uni.upx2px(100);
  109. }
  110. })
  111. },
  112. methods: {
  113. changeTab(e) {
  114. this.activeTab = e.index;
  115. this.refresh()
  116. },
  117. // swiper划动
  118. onSwiperChange(e) {
  119. this.changeIdx(e.detail.current);
  120. },
  121. // 更新当前页
  122. changeIdx(index) {
  123. if (this.activeTab === index) return;
  124. this.activeTab = index;
  125. this.scrollViewId = 'scrollView' + this.activeTab;
  126. this.refresh()
  127. },
  128. // 获取数据
  129. getList() {
  130. this.loading = true
  131. this.queryParam.status = this.activeTab > 0 ? this.activeTab : ''
  132. bgInfoPage(this.queryParam).then(res => {
  133. this.loading = false
  134. if (res.code == 0) {
  135. let list = res.rows && res.rows.length > 0 ? res.rows : []
  136. this.list = this.list.concat(list)
  137. this.total = res.total
  138. this.queryParam.pageNum++
  139. if (this.list.length >= this.total) {
  140. this.isMore = false
  141. }
  142. this.resetData(this.list)
  143. }
  144. }).catch(() => {
  145. this.loading = false
  146. })
  147. },
  148. resetData(array) {
  149. this.abnormalList = array.reduce((acc, obj) => {
  150. const [year, month] = obj.createTime.split(' ')[0].split('-');
  151. const date = obj.createTime.split(' ')[0];
  152. if (!acc[`${year}-${month}`]) {
  153. acc[`${year}-${month}`] = {};
  154. }
  155. if (!acc[`${year}-${month}`][date]) {
  156. acc[`${year}-${month}`][date] = [];
  157. }
  158. obj.num = obj.bloodGlucose
  159. acc[`${year}-${month}`][date].push(obj);
  160. return acc;
  161. }, {});
  162. },
  163. refresh() {
  164. this.loading = false
  165. this.isMore = true
  166. this.queryParam.pageNum = 1
  167. this.list = []
  168. this.getList()
  169. },
  170. // 滚动到底部
  171. scrolltolower() {
  172. if (this.isMore) {
  173. this.getList()
  174. }
  175. },
  176. // 改变月份(时间范围:查询选中的月份-现在的月份) 2024-07
  177. monthChange(month) {
  178. const date = month + "-01 00:00:00"
  179. this.queryParam.startTime = this.$timeFormat(date, "yyyy/mm/dd hh:MM:ss")
  180. this.queryParam.endTime = this.$timeFormat(new Date(), "yyyy/mm/dd hh:MM:ss")
  181. this.refresh()
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. @mixin u-flex($flexD, $alignI, $justifyC) {
  188. display: flex;
  189. flex-direction: $flexD;
  190. align-items: $alignI;
  191. justify-content: $justifyC;
  192. }
  193. .status1 {
  194. background: #FF5558;
  195. }
  196. .status2 {
  197. background: #FFB992;
  198. }
  199. .status4 {
  200. background: #96CBFA;
  201. }
  202. .status5 {
  203. background: #52D087;
  204. }
  205. .status3 {
  206. background: #91AEFF;
  207. }
  208. .slotview {
  209. display: inline-block;
  210. flex-shrink: 0;
  211. width: 72rpx;
  212. height: 72rpx;
  213. border-radius: 50%;
  214. overflow: hidden;
  215. font-size: 20rpx;
  216. color: #FFFFFF;
  217. text-align: center;
  218. padding: 10rpx;
  219. @include u-flex(column, center, center);
  220. box-sizing: border-box;
  221. margin-right: 18rpx;
  222. }
  223. </style>