heartRate.vue 9.4 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/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-show="!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)
  147. this.getAbnormalInfo(param)
  148. },
  149. getServerData(param) {
  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. let chartData = {
  159. categories: res.data.list.map(item=>item.createTime),
  160. series: [{
  161. name: "心率",
  162. data: res.data.list.map(item=>item.avgBpm)
  163. }]
  164. }
  165. this.chartData = JSON.parse(JSON.stringify(chartData));
  166. } else {
  167. this.avg = undefined
  168. this.max = undefined
  169. this.min = undefined
  170. }
  171. }).catch((err) => {
  172. this.loading = false
  173. });
  174. },
  175. // 获取异常数据
  176. getAbnormalInfo(param) {
  177. this.status1 = 0
  178. this.status2 = 0
  179. heartRateCount(param).then((res) => {
  180. if (res.code == 200 && res.data && res.data.length > 0) {
  181. // 0:正常,1:偏低2:偏高
  182. res.data.forEach(item => {
  183. this.status1 += item.status == 1 ? item.count : 0
  184. this.status2 += item.status == 2 ? item.count : 0
  185. })
  186. }
  187. }).catch((err) => {});
  188. },
  189. },
  190. onPageScroll(e) {
  191. if (e.scrollTop <= 44) {
  192. this.opacity = e.scrollTop / 44 * 1
  193. } else if (e.scrollTop > 44) {
  194. this.opacity = 1
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. @mixin u-flex($flexD, $alignI, $justifyC) {
  201. display: flex;
  202. flex-direction: $flexD;
  203. align-items: $alignI;
  204. justify-content: $justifyC;
  205. }
  206. .container {
  207. padding: 0 24rpx;
  208. position: relative;
  209. }
  210. .page-bg {
  211. width: 100%;
  212. height: auto;
  213. position: absolute;
  214. top: 0;
  215. left: 0;
  216. }
  217. .container-body {
  218. position: relative;
  219. z-index: 1;
  220. padding-bottom: 24rpx;
  221. }
  222. .box-title {
  223. font-family: PingFang SC, PingFang SC;
  224. font-weight: 400;
  225. font-size: 24rpx;
  226. color: #757575;
  227. @include u-flex(row, center, space-between);
  228. &-left {
  229. font-weight: 500;
  230. font-size: 36rpx;
  231. color: #222222;
  232. line-height: 42rpx;
  233. }
  234. &-right {
  235. @include u-flex(row, center, flex-start);
  236. image {
  237. height: 48rpx;
  238. width: 48rpx;
  239. }
  240. }
  241. }
  242. .box {
  243. padding: 24rpx;
  244. margin-bottom: 20rpx;
  245. box-sizing: border-box;
  246. background: #FFFFFF;
  247. border-radius: 16rpx 16rpx 16rpx 16rpx;
  248. }
  249. .ytitle {
  250. margin-top: 10rpx;
  251. line-height: 34rpx;
  252. margin-bottom: 24rpx;
  253. font-family: PingFang SC, PingFang SC;
  254. font-weight: 400;
  255. font-size: 24rpx;
  256. color: #999999;
  257. }
  258. .echartbox {
  259. height: 506rpx;
  260. width: 100%;
  261. }
  262. .heart-rate {
  263. &-statistics {
  264. @include u-flex(row, center, space-between);
  265. font-family: PingFang SC, PingFang SC;
  266. font-weight: 400;
  267. font-size: 26rpx;
  268. color: #999999;
  269. }
  270. &-statistics-item {
  271. flex: 1;
  272. height: 200rpx;
  273. @include u-flex(column, center, center);
  274. }
  275. &-statistics-num {
  276. font-weight: 500;
  277. font-size: 48rpx;
  278. color: #333333;
  279. height: 68rpx;
  280. margin-top: 6rpx;
  281. }
  282. &-range {
  283. height: 96rpx;
  284. padding: 0 24rpx;
  285. background: linear-gradient(135deg, #FF7E9E 0%, #FE3565 100%);
  286. border-radius: 16rpx 16rpx 16rpx 16rpx;
  287. @include u-flex(row, center, space-between);
  288. font-family: PingFang SC, PingFang SC;
  289. font-weight: 500;
  290. font-size: 32rpx;
  291. color: #FFFFFF;
  292. }
  293. &-rangeright {
  294. font-weight: 500;
  295. font-size: 40rpx;
  296. @include u-flex(row, center, flex-start);
  297. }
  298. &-unit {
  299. margin-left: 18rpx;
  300. font-weight: 400;
  301. font-size: 24rpx;
  302. }
  303. }
  304. .abnormal {
  305. font-family: PingFang SC, PingFang SC;
  306. font-weight: 400;
  307. font-size: 28rpx;
  308. color: #757575;
  309. @include u-flex(row, center, flex-start);
  310. flex-wrap: wrap;
  311. // gap: 18rpx;
  312. margin-top: 24rpx;
  313. margin-bottom: -2rpx;
  314. margin-right: -18rpx;
  315. &-item {
  316. width: 318rpx;
  317. height: 144rpx;
  318. margin: 0 18rpx 18rpx 0;
  319. padding: 0 24rpx;
  320. box-sizing: border-box;
  321. border-radius: 16rpx 16rpx 16rpx 16rpx;
  322. border: 2rpx solid #FCF4F4;
  323. @include u-flex(column, flex-start, center);
  324. &-title {
  325. font-weight: 500;
  326. font-size: 28rpx;
  327. color: #333333;
  328. margin-bottom: 16rpx;
  329. }
  330. &-num {
  331. width: 100%;
  332. @include u-flex(row, center, space-between);
  333. }
  334. }
  335. .colorbg1 {
  336. background: #FFFCFC;
  337. border-color: #FCF4F4;
  338. }
  339. .colorbg2 {
  340. background: #FAFBFF;
  341. border-color: #F2F7FE;
  342. }
  343. }
  344. .standardbox {
  345. background: linear-gradient(360deg, #FFFFFF 0%, #FFF5EC 100%);
  346. border-radius: 16rpx 16rpx 16rpx 16rpx;
  347. border: 2rpx solid #FFFFFF;
  348. margin-bottom: 20rpx;
  349. }
  350. .standard {
  351. padding: 24rpx;
  352. margin-top: 32rpx;
  353. border-radius: 16rpx 16rpx 16rpx 16rpx;
  354. &-title {
  355. @include u-flex(row, center, flex-start);
  356. font-family: PingFang SC, PingFang SC;
  357. font-weight: 500;
  358. font-size: 28rpx;
  359. color: #333333;
  360. image {
  361. width: 48rpx;
  362. height: 48rpx;
  363. margin-right: 14rpx;
  364. }
  365. text:last-child {
  366. color: #FF7700;
  367. }
  368. }
  369. &-con {
  370. margin-top: 28rpx;
  371. font-family: PingFang SC, PingFang SC;
  372. font-weight: 400;
  373. font-size: 24rpx;
  374. color: #757575;
  375. view {
  376. margin-bottom: 12rpx;
  377. padding-left: 24rpx;
  378. position: relative;
  379. &::before {
  380. content: "";
  381. width: 8rpx;
  382. height: 8rpx;
  383. background: rgba(255, 119, 0, 0.5);
  384. border-radius: 50%;
  385. position: absolute;
  386. left: 0;
  387. top: 50%;
  388. transform: translateY(-50%);
  389. }
  390. }
  391. }
  392. }
  393. </style>