bloodSugar.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <view class="container">
  3. <uni-nav-bar fixed :border="false" :backgroundColor="`rgba(255,255,255,${opacity})`" title="血糖监测" :statusBar="true"
  4. left-icon="left" @clickLeft="back"></uni-nav-bar>
  5. <image class="page-bg" src="@/static/images/pages_watch/images/blood_sugar_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">单位:mmol/L</view>
  14. <view class="echartbox">
  15. <qiun-data-charts v-show="!isEmpty" type="area" :opts="opts" :chartData="chartData" tooltipFormat="bsTooltip" />
  16. <myEmpty v-show="isEmpty" style="padding: 40rpx 0 0 0;"></myEmpty>
  17. </view>
  18. </view>
  19. <!-- 血糖异常记录 -->
  20. <view class="box">
  21. <view class="box-title" style="height: 80rpx;">
  22. <view class="box-title-left">血糖异常记录</view>
  23. <view class="box-title-right" @tap="handleMore">
  24. 查看更多<image src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png"></image>
  25. </view>
  26. </view>
  27. <view class="abnormal">
  28. <view class="abnormal-item colorbg1">
  29. <view class="abnormal-item-title">高风险</view>
  30. <view class="abnormal-item-num">
  31. <text>{{status1}}次</text>
  32. <image src="@/static/images/pages_watch/icons/zyss_arrow_icon1.png"></image>
  33. </view>
  34. </view>
  35. <view class="abnormal-item colorbg2">
  36. <view class="abnormal-item-title">不良</view>
  37. <view class="abnormal-item-num">
  38. <text>{{status2}}次</text>
  39. <image src="@/static/images/pages_watch/icons/zyss_arrow_icon2.png"></image>
  40. </view>
  41. </view>
  42. <view class="abnormal-item colorbg3">
  43. <view class="abnormal-item-title">一般</view>
  44. <view class="abnormal-item-num">
  45. <text>{{status3}}次</text>
  46. <image src="@/static/images/pages_watch/icons/zyss_arrow_icon3.png"></image>
  47. </view>
  48. </view>
  49. <view class="abnormal-item colorbg4">
  50. <view class="abnormal-item-title">良好</view>
  51. <view class="abnormal-item-num">
  52. <text>{{status4}}次</text>
  53. <image src="@/static/images/pages_watch/icons/zyss_arrow_icon4.png"></image>
  54. </view>
  55. </view>
  56. <view class="abnormal-item colorbg5">
  57. <view class="abnormal-item-title">正常</view>
  58. <view class="abnormal-item-num">
  59. <text>{{status5}}次</text>
  60. <image src="@/static/images/pages_watch/icons/zyss_arrow_icon5.png"></image>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="standard">
  65. <view class="standard-title">
  66. <image src="@/static/images/pages_watch/icons/note_icon.png"></image>
  67. <text>血糖</text>
  68. <text>最新标准</text>
  69. </view>
  70. <view class="standard-con">
  71. <view>空腹血糖正常值为4.1-6.1mmol/L</view>
  72. <view>餐后1小时血糖正常值为6.7-9.4mmol/L</view>
  73. <view>餐后2小时血糖正常值为{{'<=' + 7.8}}mmol /L</view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue"
  82. import dateTimePicker from "@/pages_watch/components/dateTimePicker/dateTimePicker.vue"
  83. import {bgInfo,bgAbnormaInfo} from "@/api/pages_watch/healthMonitoring.js";
  84. export default {
  85. components: {
  86. myEmpty,
  87. dateTimePicker
  88. },
  89. data() {
  90. return {
  91. opacity: 0,
  92. loading: false,
  93. isEmpty: false,
  94. chartData: {},
  95. // 1:高风险2:不良 3:一般 4:良好 5:正常
  96. status1: 0,
  97. status2: 0,
  98. status3: 0,
  99. status4: 0,
  100. status5: 0,
  101. queryParam: {
  102. startTime: "",
  103. endTime: "",
  104. deviceId: uni.getStorageSync("deviceId")
  105. },
  106. opts: {
  107. color: ["#FF7700"],
  108. padding: [20, 0, 15, 0],
  109. enableScroll: false,
  110. dataLabel:false,
  111. dataPointShapeType: "hollow",
  112. legend: {
  113. show: false,
  114. },
  115. xAxis: {
  116. disableGrid: true,
  117. fontSize: 12,
  118. axisLine:false,
  119. fontColor: '#ccc',
  120. // 横坐标最多展示几个
  121. labelCount: 7,
  122. // 自定义横坐标展示(在/u-charts/config-ucharts中有配置)
  123. format: "formatterTime",
  124. },
  125. yAxis: {
  126. gridType: "dash",
  127. dashLength: 2,
  128. // splitNumber: 6,
  129. data: [{
  130. fontColor: '#ccc',
  131. min: 0,
  132. // max: 33,
  133. axisLine:false,
  134. fontSize: 12,
  135. }]
  136. },
  137. extra: {
  138. tooltip: {
  139. gridType: "dash",
  140. showArrow: false,
  141. legendShow: true,
  142. legendShape: "circle"
  143. },
  144. area: {
  145. type: "straight",
  146. opacity: 0.2,
  147. addLine: true,
  148. width: 2,
  149. gradient: true,
  150. activeType: "solid"
  151. }
  152. }
  153. }
  154. }
  155. },
  156. methods: {
  157. back() {
  158. uni.navigateBack({
  159. delta: 1
  160. })
  161. },
  162. onChangeTime(time) {
  163. const param = {
  164. startTime: this.$timeFormat(time[0],'yyyy/mm/dd hh:MM:ss'),
  165. endTime: this.$timeFormat(time[1],'yyyy/mm/dd hh:MM:ss'),
  166. deviceId: uni.getStorageSync("deviceId")
  167. }
  168. this.queryParam = param
  169. this.getServerData(param)
  170. this.getAbnormalInfo(param)
  171. },
  172. getServerData(param) {
  173. //模拟从服务器获取数据时的延时
  174. this.loading = true
  175. bgInfo(param).then((res) => {
  176. this.loading = false
  177. this.isEmpty = !(res.data && res.data.length>0)
  178. if(res.code == 200 && res.data) {
  179. let chartData = {
  180. categories: res.data.map(item=>item.createTime),
  181. series: [{
  182. name: "血糖",
  183. data: res.data.map(item=>item.bloodGlucose)
  184. }]
  185. }
  186. this.chartData = JSON.parse(JSON.stringify(chartData));
  187. }
  188. }).catch((err) => {
  189. this.loading = false
  190. });
  191. },
  192. // 获取异常数据
  193. getAbnormalInfo(param) {
  194. this.status1 = 0
  195. this.status2 = 0
  196. this.status3 = 0
  197. this.status4 = 0
  198. this.status5 = 0
  199. bgAbnormaInfo(param).then((res) => {
  200. if(res.code == 200 && res.data && res.data.length > 0) {
  201. res.data.forEach(item=>{
  202. this.status1 += item.status == 1 ? item.count : 0
  203. this.status2 += item.status == 2 ? item.count : 0
  204. this.status3 += item.status == 3 ? item.count : 0
  205. this.status4 += item.status == 4 ? item.count : 0
  206. this.status5 += item.status == 5 ? item.count : 0
  207. })
  208. } else {
  209. this.status1 = 0
  210. this.status2 = 0
  211. this.status3 = 0
  212. this.status4 = 0
  213. this.status5 = 0
  214. }
  215. }).catch((err) => { });
  216. },
  217. // 查看等多数据
  218. handleMore() {
  219. uni.navigateTo({
  220. url: "/pages_watch/healthMonitoring/bloodSugarAbnormal?startTime="+this.queryParam.startTime+ "&endTime=" + this.queryParam.endTime
  221. })
  222. }
  223. },
  224. onPageScroll(e) {
  225. if (e.scrollTop <= 44) {
  226. this.opacity = e.scrollTop / 44 * 1
  227. } else if (e.scrollTop > 44) {
  228. this.opacity = 1
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. @mixin u-flex($flexD, $alignI, $justifyC) {
  235. display: flex;
  236. flex-direction: $flexD;
  237. align-items: $alignI;
  238. justify-content: $justifyC;
  239. }
  240. .container {
  241. padding: 0 24rpx;
  242. position: relative;
  243. }
  244. .page-bg {
  245. width: 100%;
  246. height: auto;
  247. position: absolute;
  248. top: 0;
  249. left: 0;
  250. }
  251. .container-body {
  252. position: relative;
  253. z-index: 1;
  254. padding-bottom: 24rpx;
  255. }
  256. .box-title {
  257. font-family: PingFang SC, PingFang SC;
  258. font-weight: 400;
  259. font-size: 24rpx;
  260. color: #757575;
  261. @include u-flex(row, center, space-between);
  262. &-left {
  263. font-weight: 500;
  264. font-size: 36rpx;
  265. color: #222222;
  266. line-height: 42rpx;
  267. }
  268. &-right {
  269. @include u-flex(row, center, flex-start);
  270. image {
  271. height: 48rpx;
  272. width: 48rpx;
  273. }
  274. }
  275. }
  276. .box {
  277. padding: 24rpx;
  278. margin-bottom: 20rpx;
  279. box-sizing: border-box;
  280. background: #FFFFFF;
  281. border-radius: 16rpx 16rpx 16rpx 16rpx;
  282. }
  283. .ytitle {
  284. margin-top: 10rpx;
  285. line-height: 34rpx;
  286. margin-bottom: 24rpx;
  287. font-family: PingFang SC, PingFang SC;
  288. font-weight: 400;
  289. font-size: 24rpx;
  290. color: #999999;
  291. }
  292. .echartbox {
  293. height: 466rpx;
  294. width: 100%;
  295. }
  296. .abnormal {
  297. font-family: PingFang SC, PingFang SC;
  298. font-weight: 400;
  299. font-size: 24rpx;
  300. color: #757575;
  301. @include u-flex(row, center, flex-start);
  302. flex-wrap: wrap;
  303. // gap: 18rpx;
  304. margin-top: 20rpx;
  305. margin-bottom: -18rpx;
  306. margin-right: -18rpx;
  307. &-item {
  308. width: 206rpx;
  309. height: 144rpx;
  310. padding: 0 24rpx;
  311. margin: 0 18rpx 18rpx 0;
  312. box-sizing: border-box;
  313. border-radius: 16rpx 16rpx 16rpx 16rpx;
  314. border: 2rpx solid #FCF4F4;
  315. @include u-flex(column, flex-start, center);
  316. &-title {
  317. font-weight: 500;
  318. font-size: 32rpx;
  319. color: #333333;
  320. margin-bottom: 12rpx;
  321. }
  322. image {
  323. width: 24rpx;
  324. height: 24rpx;
  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: #FEFAF8;
  337. border-color: #FDF7F3;
  338. }
  339. .colorbg3 {
  340. background: #FAFBFF;
  341. border-color: #F2F7FE;
  342. }
  343. .colorbg4 {
  344. background: #FAFCFF;
  345. border-color: #F6FAFF;
  346. }
  347. .colorbg5 {
  348. background: #FAFFFC;
  349. border-color: #EBFFF3;
  350. }
  351. }
  352. .standard {
  353. padding: 24rpx;
  354. margin-top: 32rpx;
  355. background: #F5F7FA;
  356. border-radius: 16rpx 16rpx 16rpx 16rpx;
  357. &-title {
  358. @include u-flex(row, center, flex-start);
  359. font-family: PingFang SC, PingFang SC;
  360. font-weight: 500;
  361. font-size: 28rpx;
  362. color: #333333;
  363. image {
  364. width: 48rpx;
  365. height: 48rpx;
  366. margin-right: 14rpx;
  367. }
  368. text:last-child {
  369. color: #FF7700;
  370. }
  371. }
  372. &-con {
  373. margin-top: 28rpx;
  374. font-family: PingFang SC, PingFang SC;
  375. font-weight: 400;
  376. font-size: 24rpx;
  377. color: #757575;
  378. view {
  379. margin-bottom: 12rpx;
  380. padding-left: 24rpx;
  381. position: relative;
  382. &::before {
  383. content: "";
  384. width: 8rpx;
  385. height: 8rpx;
  386. background: rgba(255, 119, 0, 0.5);
  387. border-radius: 50%;
  388. position: absolute;
  389. left: 0;
  390. top: 50%;
  391. transform: translateY(-50%);
  392. }
  393. }
  394. }
  395. }
  396. </style>