bloodOxygen.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="container">
  3. <uni-nav-bar fixed :border="false" :backgroundColor="`rgba(255,255,255,${opacity})`" title="血氧监测"
  4. :statusBar="true" left-icon="left" @clickLeft="back"></uni-nav-bar>
  5. <image class="page-bg" src="@/static/images/pages_watch/images/blood_oxygen_top_bg.png" mode="widthFix"></image>
  6. <view class="container-body">
  7. <dateTimePicker @onChange="onChangeTime" />
  8. <!-- 血氧趋势 -->
  9. <view class="box">
  10. <view class="box-title">
  11. <view class="box-title-left">血氧趋势</view>
  12. </view>
  13. <view class="ytitle" v-show="!loading && !isEmpty">百分比</view>
  14. <view class="echartbox">
  15. <qiun-data-charts v-show="!isEmpty" type="column" :opts="opts" :chartData="chartData"
  16. tooltipFormat="spTooltip" />
  17. <myEmpty v-show="isEmpty" style="padding: 40rpx 0 0 0;"></myEmpty>
  18. </view>
  19. <view class="legend" v-show="!loading && !isEmpty">
  20. <view class="legend-item">
  21. <!-- 小于70% ,&lt;微信开发者工具报错-->
  22. <view class="legend-dot" style="background-color: #FF5558;"></view><text>{{'<'}}70%</text>
  23. </view>
  24. <view class="legend-item">
  25. <view class="legend-dot" style="background-color: #FDBD27;"></view><text>70 - 89%</text>
  26. </view>
  27. <view class="legend-item">
  28. <view class="legend-dot" style="background-color: #52D087;"></view><text>90 - 100%</text>
  29. </view>
  30. </view>
  31. <view class="statistics">
  32. <view class="statistics-item">
  33. <view>平均值</view>
  34. <view class="statistics-num">{{avg}}%</view>
  35. </view>
  36. <view class="statistics-item">
  37. <view>最低值</view>
  38. <view class="statistics-num">{{min}}%</view>
  39. </view>
  40. <view class="statistics-item">
  41. <view>最高值</view>
  42. <view class="statistics-num">{{max}}%</view>
  43. </view>
  44. </view>
  45. <view class="abnormal">
  46. <view class="abnormal-item colorbg1">
  47. <view class="abnormal-item-title">血氧过高提醒</view>
  48. <view class="abnormal-item-num">
  49. <text>{{status2}}次</text>
  50. </view>
  51. </view>
  52. <view class="abnormal-item colorbg2">
  53. <view class="abnormal-item-title">血氧过低提醒</view>
  54. <view class="abnormal-item-num">
  55. <text>{{status1}}次</text>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue"
  65. import dateTimePicker from "@/pages_watch/components/dateTimePicker/dateTimePicker.vue"
  66. import {
  67. spInfo,
  68. spCount
  69. } from "@/api/pages_watch/healthMonitoring.js";
  70. export default {
  71. components: {
  72. myEmpty,
  73. dateTimePicker
  74. },
  75. data() {
  76. return {
  77. opacity: 0,
  78. loading: true,
  79. isEmpty: false,
  80. // 0:正常,1:偏低2:偏高
  81. status1: 0,
  82. status2: 0,
  83. avg: 0,
  84. min: 0,
  85. max: 0,
  86. chartData: {},
  87. opts: {
  88. padding: [15, 0, 15, 0],
  89. enableScroll: false,
  90. dataLabel: false,
  91. legend: {
  92. show: false
  93. },
  94. xAxis: {
  95. disableGrid: true,
  96. fontSize: 12,
  97. axisLine: false,
  98. fontColor: '#ccc',
  99. labelCount: 7,
  100. format: "formatterTime",
  101. },
  102. yAxis: {
  103. gridType: "dash",
  104. dashLength: 2,
  105. data: [{
  106. fontColor: '#ccc',
  107. min: 0,
  108. // max: 100,
  109. axisLine: false,
  110. fontSize: 12,
  111. }]
  112. },
  113. extra: {
  114. tooltip: {
  115. gridType: "dash",
  116. showArrow: false,
  117. legendShow: true,
  118. legendShape: "circle"
  119. },
  120. column: {
  121. type: "group",
  122. width: 12,
  123. barBorderRadius: [4, 4, 0, 0],
  124. }
  125. }
  126. }
  127. }
  128. },
  129. methods: {
  130. back() {
  131. uni.navigateBack({
  132. delta: 1
  133. })
  134. },
  135. onChangeTime(time) {
  136. const param = {
  137. startTime: this.$timeFormat(time[0], 'yyyy/mm/dd hh:MM:ss'),
  138. endTime: this.$timeFormat(time[1], 'yyyy/mm/dd hh:MM:ss'),
  139. deviceId: uni.getStorageSync("deviceId") || ""
  140. }
  141. this.getServerData(param)
  142. this.getCount(param)
  143. },
  144. getServerData(param) {
  145. this.loading = true
  146. spInfo(param).then((res) => {
  147. this.loading = false
  148. this.isEmpty = !(res.data && res.data.list && res.data.list.length > 0)
  149. if (res.code == 200 && res.data) {
  150. this.avg = res.data.avg
  151. this.min = res.data.min
  152. this.max = res.data.max
  153. let chartData = {
  154. categories: res.data.list.map(item => item.createTime),
  155. series: [{
  156. name: "血氧",
  157. data: res.data.list.map(item => ({
  158. value: item.minBoxy,
  159. color: item.status === 1 ? "#FDBD27" : item.status ===
  160. 2 ? "#FF5558" : "#52D087"
  161. }))
  162. }]
  163. }
  164. this.chartData = JSON.parse(JSON.stringify(chartData));
  165. } else {
  166. this.avg = undefined
  167. this.max = undefined
  168. this.min = undefined
  169. }
  170. }).catch((err) => {
  171. this.loading = false
  172. });
  173. },
  174. getCount(param) {
  175. this.status1 = 0
  176. this.status2 = 0
  177. spCount(param).then((res) => {
  178. if (res.code == 200 && res.data && res.data.length > 0) {
  179. // 0:正常,1:偏低2:偏高
  180. res.data.forEach(item => {
  181. this.status1 += item.status == 1 ? item.count : 0
  182. this.status2 += item.status == 2 ? item.count : 0
  183. })
  184. }
  185. }).catch((err) => {});
  186. }
  187. },
  188. onPageScroll(e) {
  189. if (e.scrollTop <= 44) {
  190. this.opacity = e.scrollTop / 44 * 1
  191. } else if (e.scrollTop > 44) {
  192. this.opacity = 1
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss" scoped>
  198. @mixin u-flex($flexD, $alignI, $justifyC) {
  199. display: flex;
  200. flex-direction: $flexD;
  201. align-items: $alignI;
  202. justify-content: $justifyC;
  203. }
  204. .container {
  205. padding: 0 24rpx;
  206. position: relative;
  207. }
  208. .page-bg {
  209. width: 100%;
  210. height: auto;
  211. position: absolute;
  212. top: 0;
  213. left: 0;
  214. }
  215. .container-body {
  216. position: relative;
  217. z-index: 1;
  218. padding-bottom: 24rpx;
  219. }
  220. .box-title {
  221. font-family: PingFang SC, PingFang SC;
  222. font-weight: 400;
  223. font-size: 24rpx;
  224. color: #757575;
  225. @include u-flex(row, center, space-between);
  226. &-left {
  227. font-weight: 500;
  228. font-size: 36rpx;
  229. color: #222222;
  230. line-height: 42rpx;
  231. }
  232. &-right {
  233. @include u-flex(row, center, flex-start);
  234. image {
  235. height: 48rpx;
  236. width: 48rpx;
  237. }
  238. }
  239. }
  240. .ytitle {
  241. margin-top: 10rpx;
  242. line-height: 34rpx;
  243. margin-bottom: 24rpx;
  244. font-family: PingFang SC, PingFang SC;
  245. font-weight: 400;
  246. font-size: 24rpx;
  247. color: #999999;
  248. }
  249. .legend {
  250. height: 48rpx;
  251. margin-top: 44rpx;
  252. margin-bottom: 24rpx;
  253. @include u-flex(row, center, space-between);
  254. font-family: PingFang SC, PingFang SC;
  255. font-weight: 400;
  256. font-size: 24rpx;
  257. color: #757575;
  258. &-item {
  259. flex: 1;
  260. text-align: center;
  261. @include u-flex(row, center, center);
  262. }
  263. &-dot {
  264. width: 12rpx;
  265. height: 12rpx;
  266. border-radius: 50%;
  267. margin: 12rpx;
  268. }
  269. }
  270. .box {
  271. padding: 24rpx;
  272. margin-bottom: 20rpx;
  273. box-sizing: border-box;
  274. background: #FFFFFF;
  275. border-radius: 16rpx 16rpx 16rpx 16rpx;
  276. }
  277. .echartbox {
  278. height: 520rpx;
  279. width: 100%;
  280. }
  281. .statistics {
  282. @include u-flex(row, center, space-between);
  283. font-family: PingFang SC, PingFang SC;
  284. font-weight: 400;
  285. font-size: 26rpx;
  286. color: #999999;
  287. &-item {
  288. flex: 1;
  289. height: 160rpx;
  290. @include u-flex(column, center, center);
  291. }
  292. &-num {
  293. font-weight: 500;
  294. font-size: 48rpx;
  295. color: #333333;
  296. height: 68rpx;
  297. margin-top: 4rpx;
  298. }
  299. }
  300. .abnormal {
  301. font-family: PingFang SC, PingFang SC;
  302. font-weight: 400;
  303. font-size: 28rpx;
  304. color: #757575;
  305. @include u-flex(row, center, flex-start);
  306. flex-wrap: wrap;
  307. // gap: 18rpx;
  308. margin-top: 16rpx;
  309. margin-bottom: -2rpx;
  310. margin-right: -18rpx;
  311. &-item {
  312. width: 318rpx;
  313. height: 144rpx;
  314. padding: 0 24rpx;
  315. margin: 0 18rpx 18rpx 0;
  316. box-sizing: border-box;
  317. border-radius: 16rpx 16rpx 16rpx 16rpx;
  318. border: 2rpx solid #FCF4F4;
  319. @include u-flex(column, flex-start, center);
  320. &-title {
  321. font-weight: 500;
  322. font-size: 28rpx;
  323. color: #333333;
  324. margin-bottom: 16rpx;
  325. }
  326. &-num {
  327. width: 100%;
  328. @include u-flex(row, center, space-between);
  329. }
  330. }
  331. .colorbg1 {
  332. background: #FFFCFC;
  333. border-color: #FCF4F4;
  334. }
  335. .colorbg2 {
  336. background: #FAFBFF;
  337. border-color: #F2F7FE;
  338. }
  339. }
  340. </style>