heartRate.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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/heart_rate_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-if="!isEmpty" type="area" :opts="opts" :chartData="chartData" tooltipFormat="heartTooltip" />
  16. <myEmpty v-show="isEmpty" style="padding: 40rpx 0 0 0;"></myEmpty>
  17. </view>
  18. <view class="heart-rate-statistics">
  19. <view class="heart-rate-statistics-item">
  20. <view>平均值</view>
  21. <view class="heart-rate-statistics-num">{{avg||'--'}}</view>
  22. </view>
  23. <view class="heart-rate-statistics-item">
  24. <view>最低值</view>
  25. <view class="heart-rate-statistics-num">{{min||'--'}}</view>
  26. </view>
  27. <view class="heart-rate-statistics-item">
  28. <view>最高值</view>
  29. <view class="heart-rate-statistics-num">{{max||'--'}}</view>
  30. </view>
  31. </view>
  32. <view class="heart-rate-range">
  33. <text>心率范围</text>
  34. <view class="heart-rate-rangeright">
  35. <text>{{min||''}}-{{max||''}}</text>
  36. <text class="heart-rate-unit">次/分钟</text>
  37. </view>
  38. </view>
  39. <view class="abnormal">
  40. <view class="abnormal-item colorbg1">
  41. <view class="abnormal-item-title">心率过高提醒</view>
  42. <view class="abnormal-item-num">
  43. <text>{{status2}}次</text>
  44. </view>
  45. </view>
  46. <view class="abnormal-item colorbg2">
  47. <view class="abnormal-item-title">心率过低提醒</view>
  48. <view class="abnormal-item-num">
  49. <text>{{status1}}次</text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 心率标准 -->
  55. <view class="standard standardbox">
  56. <view class="standard-title">
  57. <image src="@/static/images/pages_watch/icons/note_icon.png"></image>
  58. <text>心率</text>
  59. <text>标准</text>
  60. </view>
  61. <view class="standard-con">
  62. <view>心率标准范围为60~100次/分,但可因年龄、性别或其他生理因素产生个体差异。</view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue"
  70. import dateTimePicker from "@/pages_watch/components/dateTimePicker/dateTimePicker.vue"
  71. import {heartRateInfo,heartRateCount} from "@/api/pages_watch/healthMonitoring.js";
  72. export default {
  73. components: {
  74. myEmpty,
  75. dateTimePicker
  76. },
  77. data() {
  78. return {
  79. opacity: 0,
  80. loading: false,
  81. isEmpty: false,
  82. avg: undefined,
  83. max: undefined,
  84. min: undefined,
  85. status1: 0,
  86. status2: 0,
  87. chartData: {},
  88. opts: {
  89. color: ["#FF7700"],
  90. padding: [25, 0, 10, 0],
  91. enableScroll: false,
  92. dataLabel: false,
  93. dataPointShapeType: "hollow",
  94. legend: {
  95. show: false,
  96. },
  97. xAxis: {
  98. disableGrid: true,
  99. fontSize: 12,
  100. axisLine: false,
  101. fontColor: '#ccc',
  102. labelCount: 7,
  103. format: "formatterTime",
  104. },
  105. yAxis: {
  106. gridType: "dash",
  107. dashLength: 2,
  108. data: [{
  109. fontColor: '#ccc',
  110. min: 0,
  111. axisLine: false,
  112. fontSize: 12,
  113. }]
  114. },
  115. extra: {
  116. tooltip: {
  117. gridType: "dash",
  118. showArrow: false,
  119. legendShow: true,
  120. legendShape: "circle"
  121. },
  122. area: {
  123. type: "straight",
  124. opacity: 0.2,
  125. addLine: true,
  126. width: 2,
  127. gradient: true,
  128. activeType: "solid"
  129. }
  130. }
  131. }
  132. }
  133. },
  134. methods: {
  135. back() {
  136. uni.navigateBack({
  137. delta: 1
  138. })
  139. },
  140. onChangeTime(time) {
  141. const param = {
  142. startTime: this.$timeFormat(time[0],'yyyy/mm/dd hh:MM:ss'),
  143. endTime: this.$timeFormat(time[1],'yyyy/mm/dd hh:MM:ss'),
  144. deviceId: uni.getStorageSync("deviceId") || ""
  145. }
  146. this.getServerData(param,time[3])
  147. this.getAbnormalInfo(param)
  148. },
  149. getServerData(param,type) {
  150. this.loading = true
  151. heartRateInfo(param).then((res) => {
  152. this.loading = false
  153. this.isEmpty = !(res.data && res.data.list && res.data.list.length>0)
  154. if(res.code == 200 && res.data) {
  155. this.avg = res.data.avg
  156. this.max = res.data.max
  157. this.min = res.data.min
  158. this.opts.xAxis.format = type==0 ? 'formatterTime':'formatterDate'
  159. let chartData = {
  160. categories: res.data.list.map(item=>item.createTime),
  161. series: [{
  162. name: "心率",
  163. data: res.data.list.map(item=>item.avgBpm)
  164. }]
  165. }
  166. this.chartData = JSON.parse(JSON.stringify(chartData));
  167. } else {
  168. this.avg = undefined
  169. this.max = undefined
  170. this.min = undefined
  171. }
  172. }).catch((err) => {
  173. this.loading = false
  174. });
  175. },
  176. // 获取异常数据
  177. getAbnormalInfo(param) {
  178. this.status1 = 0
  179. this.status2 = 0
  180. heartRateCount(param).then((res) => {
  181. if (res.code == 200 && res.data && res.data.length > 0) {
  182. // 0:正常,1:偏低2:偏高
  183. res.data.forEach(item => {
  184. this.status1 += item.status == 1 ? item.count : 0
  185. this.status2 += item.status == 2 ? item.count : 0
  186. })
  187. }
  188. }).catch((err) => {});
  189. },
  190. },
  191. onPageScroll(e) {
  192. if (e.scrollTop <= 44) {
  193. this.opacity = e.scrollTop / 44 * 1
  194. } else if (e.scrollTop > 44) {
  195. this.opacity = 1
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. @mixin u-flex($flexD, $alignI, $justifyC) {
  202. display: flex;
  203. flex-direction: $flexD;
  204. align-items: $alignI;
  205. justify-content: $justifyC;
  206. }
  207. .container {
  208. padding: 0 24rpx;
  209. position: relative;
  210. }
  211. .page-bg {
  212. width: 100%;
  213. height: auto;
  214. position: absolute;
  215. top: 0;
  216. left: 0;
  217. }
  218. .container-body {
  219. position: relative;
  220. z-index: 1;
  221. padding-bottom: 24rpx;
  222. }
  223. .box-title {
  224. font-family: PingFang SC, PingFang SC;
  225. font-weight: 400;
  226. font-size: 24rpx;
  227. color: #757575;
  228. @include u-flex(row, center, space-between);
  229. &-left {
  230. font-weight: 500;
  231. font-size: 36rpx;
  232. color: #222222;
  233. line-height: 42rpx;
  234. }
  235. &-right {
  236. @include u-flex(row, center, flex-start);
  237. image {
  238. height: 48rpx;
  239. width: 48rpx;
  240. }
  241. }
  242. }
  243. .box {
  244. padding: 24rpx;
  245. margin-bottom: 20rpx;
  246. box-sizing: border-box;
  247. background: #FFFFFF;
  248. border-radius: 16rpx 16rpx 16rpx 16rpx;
  249. }
  250. .ytitle {
  251. margin-top: 10rpx;
  252. line-height: 34rpx;
  253. margin-bottom: 24rpx;
  254. font-family: PingFang SC, PingFang SC;
  255. font-weight: 400;
  256. font-size: 24rpx;
  257. color: #999999;
  258. }
  259. .echartbox {
  260. height: 506rpx;
  261. width: 100%;
  262. }
  263. .heart-rate {
  264. &-statistics {
  265. @include u-flex(row, center, space-between);
  266. font-family: PingFang SC, PingFang SC;
  267. font-weight: 400;
  268. font-size: 26rpx;
  269. color: #999999;
  270. }
  271. &-statistics-item {
  272. flex: 1;
  273. height: 200rpx;
  274. @include u-flex(column, center, center);
  275. }
  276. &-statistics-num {
  277. font-weight: 500;
  278. font-size: 48rpx;
  279. color: #333333;
  280. height: 68rpx;
  281. margin-top: 6rpx;
  282. }
  283. &-range {
  284. height: 96rpx;
  285. padding: 0 24rpx;
  286. background: linear-gradient(135deg, #FF7E9E 0%, #FE3565 100%);
  287. border-radius: 16rpx 16rpx 16rpx 16rpx;
  288. @include u-flex(row, center, space-between);
  289. font-family: PingFang SC, PingFang SC;
  290. font-weight: 500;
  291. font-size: 32rpx;
  292. color: #FFFFFF;
  293. }
  294. &-rangeright {
  295. font-weight: 500;
  296. font-size: 40rpx;
  297. @include u-flex(row, center, flex-start);
  298. }
  299. &-unit {
  300. margin-left: 18rpx;
  301. font-weight: 400;
  302. font-size: 24rpx;
  303. }
  304. }
  305. .abnormal {
  306. font-family: PingFang SC, PingFang SC;
  307. font-weight: 400;
  308. font-size: 28rpx;
  309. color: #757575;
  310. @include u-flex(row, center, flex-start);
  311. flex-wrap: wrap;
  312. // gap: 18rpx;
  313. margin-top: 24rpx;
  314. margin-bottom: -2rpx;
  315. margin-right: -18rpx;
  316. &-item {
  317. width: 318rpx;
  318. height: 144rpx;
  319. margin: 0 18rpx 18rpx 0;
  320. padding: 0 24rpx;
  321. box-sizing: border-box;
  322. border-radius: 16rpx 16rpx 16rpx 16rpx;
  323. border: 2rpx solid #FCF4F4;
  324. @include u-flex(column, flex-start, center);
  325. &-title {
  326. font-weight: 500;
  327. font-size: 28rpx;
  328. color: #333333;
  329. margin-bottom: 16rpx;
  330. }
  331. &-num {
  332. width: 100%;
  333. @include u-flex(row, center, space-between);
  334. }
  335. }
  336. .colorbg1 {
  337. background: #FFFCFC;
  338. border-color: #FCF4F4;
  339. }
  340. .colorbg2 {
  341. background: #FAFBFF;
  342. border-color: #F2F7FE;
  343. }
  344. }
  345. .standardbox {
  346. background: linear-gradient(360deg, #FFFFFF 0%, #FFF5EC 100%);
  347. border-radius: 16rpx 16rpx 16rpx 16rpx;
  348. border: 2rpx solid #FFFFFF;
  349. margin-bottom: 20rpx;
  350. }
  351. .standard {
  352. padding: 24rpx;
  353. margin-top: 32rpx;
  354. border-radius: 16rpx 16rpx 16rpx 16rpx;
  355. &-title {
  356. @include u-flex(row, center, flex-start);
  357. font-family: PingFang SC, PingFang SC;
  358. font-weight: 500;
  359. font-size: 28rpx;
  360. color: #333333;
  361. image {
  362. width: 48rpx;
  363. height: 48rpx;
  364. margin-right: 14rpx;
  365. }
  366. text:last-child {
  367. color: #FF7700;
  368. }
  369. }
  370. &-con {
  371. margin-top: 28rpx;
  372. font-family: PingFang SC, PingFang SC;
  373. font-weight: 400;
  374. font-size: 24rpx;
  375. color: #757575;
  376. view {
  377. margin-bottom: 12rpx;
  378. padding-left: 24rpx;
  379. position: relative;
  380. &::before {
  381. content: "";
  382. width: 8rpx;
  383. height: 8rpx;
  384. background: rgba(255, 119, 0, 0.5);
  385. border-radius: 50%;
  386. position: absolute;
  387. left: 0;
  388. top: 50%;
  389. transform: translateY(-50%);
  390. }
  391. }
  392. }
  393. }
  394. </style>