pressure.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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="echartbox">
  11. <qiun-data-charts v-show="!isEmpty" type="column" :opts="opts" :chartData="chartData"
  12. tooltipFormat="pressureTooltip" />
  13. <myEmpty v-show="isEmpty" style="padding: 40rpx 0 0 0;"></myEmpty>
  14. </view>
  15. <view class="legend" v-show="!loading && !isEmpty">
  16. <view class="legend-item">
  17. <view class="legend-dot" style="background-color: #13c3fc;"></view><text>放松</text>
  18. </view>
  19. <view class="legend-item">
  20. <view class="legend-dot" style="background-color: #05b981;"></view><text>正常</text>
  21. </view>
  22. <view class="legend-item">
  23. <view class="legend-dot" style="background-color: #f8a03f;"></view><text>尚可</text>
  24. </view>
  25. <view class="legend-item">
  26. <view class="legend-dot" style="background-color: #f54f51;"></view><text>高</text>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 压力值 -->
  31. <view class="box">
  32. <view class="abnormal">
  33. <view class="abnormal-item colorbg4">
  34. <view class="abnormal-item-title">放松</view>
  35. <view class="abnormal-item-num">
  36. <text>{{status1}}次</text>
  37. <image src="@/static/images/pages_watch/icons/zyss_arrow_icon4.png"></image>
  38. </view>
  39. </view>
  40. <view class="abnormal-item colorbg5">
  41. <view class="abnormal-item-title">正常</view>
  42. <view class="abnormal-item-num">
  43. <text>{{status2}}次</text>
  44. <image src="@/static/images/pages_watch/icons/zyss_arrow_icon5.png"></image>
  45. </view>
  46. </view>
  47. <view class="abnormal-item colorbg2">
  48. <view class="abnormal-item-title">尚可</view>
  49. <view class="abnormal-item-num">
  50. <text>{{status3}}次</text>
  51. <image src="@/static/images/pages_watch/icons/zyss_arrow_icon2.png"></image>
  52. </view>
  53. </view>
  54. <view class="abnormal-item colorbg1">
  55. <view class="abnormal-item-title">高</view>
  56. <view class="abnormal-item-num">
  57. <text>{{status4}}次</text>
  58. <image src="@/static/images/pages_watch/icons/zyss_arrow_icon1.png"></image>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="standard">
  63. <view class="standard-title">
  64. <image src="@/static/images/pages_watch/icons/note_icon.png"></image>
  65. <text>温馨提醒</text>
  66. </view>
  67. <view class="linebox">
  68. <view class="line line1">
  69. <text>放松</text>
  70. <view class="bar"></view>
  71. </view>
  72. <view class="line line2">
  73. <text>正常</text>
  74. <view class="bar"></view>
  75. </view>
  76. <view class="line line3">
  77. <text>尚可</text>
  78. <view class="bar"></view>
  79. </view>
  80. <view class="line line4">
  81. <text>高</text>
  82. <view class="bar"></view>
  83. </view>
  84. </view>
  85. <view class="standard-con">
  86. <view>压力值由心率变异性计算而来,得分越高,压力值越大。</view>
  87. <!-- <view>此功能开启后,会常亮心率灯,可能会影响设备的续航时间。</view> -->
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <script>
  95. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue"
  96. import dateTimePicker from "@/pages_watch/components/dateTimePicker/dateTimePicker.vue"
  97. import {fatigueInfo,fatigueCount} from "@/api/pages_watch/healthMonitoring.js";
  98. export default {
  99. components: {
  100. myEmpty,
  101. dateTimePicker
  102. },
  103. data() {
  104. return {
  105. opacity: 0,
  106. loading: false,
  107. isEmpty: false,
  108. status1: 0,
  109. status2: 0,
  110. status3: 0,
  111. status4: 0,
  112. chartData: {},
  113. opts: {
  114. padding: [15, 0, 15, 0],
  115. enableScroll: false,
  116. dataLabel: false,
  117. legend: {
  118. show: false
  119. },
  120. xAxis: {
  121. disableGrid: true,
  122. fontSize: 12,
  123. axisLine: false,
  124. fontColor: '#ccc',
  125. labelCount: 7,
  126. format: "formatterTime",
  127. },
  128. yAxis: {
  129. gridType: "dash",
  130. dashLength: 2,
  131. data: [{
  132. fontColor: '#ccc',
  133. min: 0,
  134. // max: 100,
  135. axisLine: false,
  136. fontSize: 12,
  137. }]
  138. },
  139. extra: {
  140. tooltip: {
  141. gridType: "dash",
  142. showArrow: false,
  143. legendShow: true,
  144. legendShape: "circle"
  145. },
  146. column: {
  147. type: "group",
  148. width: 12,
  149. barBorderRadius: [4, 4, 0, 0],
  150. }
  151. }
  152. }
  153. }
  154. },
  155. methods: {
  156. back() {
  157. uni.navigateBack({
  158. delta: 1
  159. })
  160. },
  161. onChangeTime(time) {
  162. const param = {
  163. startTime: this.$timeFormat(time[0],'yyyy/mm/dd hh:MM:ss'),
  164. endTime: this.$timeFormat(time[1],'yyyy/mm/dd hh:MM:ss'),
  165. deviceId: uni.getStorageSync("deviceId") || ""
  166. }
  167. this.getServerData(param)
  168. this.getAbnormalInfo(param)
  169. },
  170. getServerData(param) {
  171. this.loading = true
  172. fatigueInfo(param).then((res) => {
  173. this.loading = false
  174. this.isEmpty = !(res.data && res.data && res.data.length>0)
  175. if(res.code == 200 && res.data) {
  176. let chartData = {
  177. categories: res.data.map(item => item.createTime),
  178. series: [{
  179. name: "压力值",
  180. data: res.data.map(item => ({
  181. value: item.pressure,
  182. color: item.status==1?'#13c3fc':item.status==2?'#05b981':item.status==3?'#f8a03f':item.status==4?'#f54f51':'#eee'
  183. }))
  184. }]
  185. }
  186. this.chartData = JSON.parse(JSON.stringify(chartData));
  187. } else {
  188. }
  189. }).catch((err) => {
  190. this.loading = false
  191. });
  192. },
  193. // 获取异常数据
  194. getAbnormalInfo(param) {
  195. this.status1 = 0
  196. this.status2 = 0
  197. fatigueCount(param).then((res) => {
  198. if (res.code == 200 && res.data && res.data.length > 0) {
  199. // 0:正常,1:偏低2:偏高
  200. res.data.forEach(item => {
  201. this.status1 += item.status == 1 ? item.count : 0
  202. this.status2 += item.status == 2 ? item.count : 0
  203. this.status3 += item.status == 3 ? item.count : 0
  204. this.status4 += item.status == 4 ? item.count : 0
  205. })
  206. }
  207. }).catch((err) => {});
  208. },
  209. },
  210. onPageScroll(e) {
  211. if (e.scrollTop <= 44) {
  212. this.opacity = e.scrollTop / 44 * 1
  213. } else if (e.scrollTop > 44) {
  214. this.opacity = 1
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. @mixin u-flex($flexD, $alignI, $justifyC) {
  221. display: flex;
  222. flex-direction: $flexD;
  223. align-items: $alignI;
  224. justify-content: $justifyC;
  225. }
  226. .linebox {
  227. margin-top: 16rpx;
  228. margin-bottom: 40rpx;
  229. @include u-flex(row, center, flex-start);
  230. width: 100%;
  231. font-family: PingFang SC, PingFang SC;
  232. font-weight: 400;
  233. font-size: 24rpx;
  234. .bar {
  235. width: 100%;
  236. height: 40rpx;
  237. position: relative;
  238. &::after {
  239. position: absolute;
  240. bottom: -40rpx;
  241. left: -0.5em;
  242. content: '0';
  243. color: #222222;
  244. }
  245. }
  246. .line {
  247. @include u-flex(column, center, center);
  248. padding: 0 2rpx 10rpx 2rpx;
  249. }
  250. .line1 {
  251. width: 30%;
  252. color: rgb(19,195,252);
  253. .bar {
  254. background-color: rgb(19,195,252);
  255. border-radius: 20rpx 0 0 20rpx;
  256. &::after {
  257. left: 0;
  258. }
  259. }
  260. }
  261. .line2 {
  262. width: 30%;
  263. color: rgb(5,185,129);
  264. .bar {
  265. background-color: rgb(5,185,129);
  266. &::after {
  267. content: '30';
  268. }
  269. }
  270. }
  271. .line3 {
  272. width: 20%;
  273. color: rgb(248,160,63);
  274. .bar {
  275. background-color: rgb(248,160,63);
  276. &::after {
  277. content: '60';
  278. }
  279. }
  280. }
  281. .line4 {
  282. width: 20%;
  283. color: rgb(245,79,81);
  284. .bar {
  285. background-color: rgb(245,79,81);
  286. border-radius: 0 20rpx 20rpx 0;
  287. &::after {
  288. content: '80';
  289. }
  290. &::before {
  291. position: absolute;
  292. bottom: -40rpx;
  293. right: -0.5em;
  294. content: '100';
  295. color: #222222;
  296. }
  297. }
  298. }
  299. }
  300. .container {
  301. padding: 0 24rpx;
  302. position: relative;
  303. }
  304. .page-bg {
  305. width: 100%;
  306. height: auto;
  307. position: absolute;
  308. top: 0;
  309. left: 0;
  310. }
  311. .container-body {
  312. position: relative;
  313. z-index: 1;
  314. padding-bottom: 24rpx;
  315. }
  316. .box-title {
  317. font-family: PingFang SC, PingFang SC;
  318. font-weight: 400;
  319. font-size: 24rpx;
  320. color: #757575;
  321. @include u-flex(row, center, space-between);
  322. &-left {
  323. font-weight: 500;
  324. font-size: 36rpx;
  325. color: #222222;
  326. line-height: 42rpx;
  327. }
  328. &-right {
  329. @include u-flex(row, center, flex-start);
  330. image {
  331. height: 48rpx;
  332. width: 48rpx;
  333. }
  334. }
  335. }
  336. .box {
  337. padding: 24rpx;
  338. margin-bottom: 20rpx;
  339. box-sizing: border-box;
  340. background: #FFFFFF;
  341. border-radius: 16rpx 16rpx 16rpx 16rpx;
  342. }
  343. .ytitle {
  344. margin-top: 10rpx;
  345. line-height: 34rpx;
  346. margin-bottom: 24rpx;
  347. font-family: PingFang SC, PingFang SC;
  348. font-weight: 400;
  349. font-size: 24rpx;
  350. color: #999999;
  351. }
  352. .echartbox {
  353. height: 506rpx;
  354. width: 100%;
  355. }
  356. .legend {
  357. height: 48rpx;
  358. // margin-top: 44rpx;
  359. margin-bottom: 24rpx;
  360. @include u-flex(row, center, space-between);
  361. font-family: PingFang SC, PingFang SC;
  362. font-weight: 400;
  363. font-size: 24rpx;
  364. color: #757575;
  365. &-item {
  366. flex: 1;
  367. text-align: center;
  368. @include u-flex(row, center, center);
  369. }
  370. &-dot {
  371. width: 12rpx;
  372. height: 12rpx;
  373. border-radius: 50%;
  374. margin: 12rpx;
  375. }
  376. }
  377. .abnormal {
  378. font-family: PingFang SC, PingFang SC;
  379. font-weight: 400;
  380. font-size: 24rpx;
  381. color: #757575;
  382. @include u-flex(row, center, flex-start);
  383. flex-wrap: wrap;
  384. // gap: 18rpx;
  385. margin-top: 20rpx;
  386. margin-bottom: -18rpx;
  387. margin-right: -18rpx;
  388. &-item {
  389. width: 206rpx;
  390. height: 144rpx;
  391. padding: 0 24rpx;
  392. margin: 0 18rpx 18rpx 0;
  393. box-sizing: border-box;
  394. border-radius: 16rpx 16rpx 16rpx 16rpx;
  395. border: 2rpx solid #FCF4F4;
  396. @include u-flex(column, flex-start, center);
  397. &-title {
  398. font-weight: 500;
  399. font-size: 32rpx;
  400. color: #333333;
  401. margin-bottom: 12rpx;
  402. }
  403. image {
  404. width: 24rpx;
  405. height: 24rpx;
  406. }
  407. &-num {
  408. width: 100%;
  409. @include u-flex(row, center, space-between);
  410. }
  411. }
  412. .colorbg1 {
  413. background: #FFFCFC;
  414. border-color: #FCF4F4;
  415. }
  416. .colorbg2 {
  417. background: #FEFAF8;
  418. border-color: #FDF7F3;
  419. }
  420. .colorbg3 {
  421. background: #FAFBFF;
  422. border-color: #F2F7FE;
  423. }
  424. .colorbg4 {
  425. background: #FAFCFF;
  426. border-color: #F6FAFF;
  427. }
  428. .colorbg5 {
  429. background: #FAFFFC;
  430. border-color: #EBFFF3;
  431. }
  432. }
  433. .standardbox {
  434. background: linear-gradient(360deg, #FFFFFF 0%, #FFF5EC 100%);
  435. border-radius: 16rpx 16rpx 16rpx 16rpx;
  436. border: 2rpx solid #FFFFFF;
  437. margin-bottom: 20rpx;
  438. }
  439. .standard {
  440. padding: 24rpx;
  441. margin-top: 32rpx;
  442. border-radius: 16rpx 16rpx 16rpx 16rpx;
  443. &-title {
  444. @include u-flex(row, center, flex-start);
  445. font-family: PingFang SC, PingFang SC;
  446. font-weight: 500;
  447. font-size: 28rpx;
  448. color: #333333;
  449. image {
  450. width: 48rpx;
  451. height: 48rpx;
  452. margin-right: 14rpx;
  453. }
  454. }
  455. &-con {
  456. margin-top: 28rpx;
  457. font-family: PingFang SC, PingFang SC;
  458. font-weight: 400;
  459. font-size: 24rpx;
  460. color: #757575;
  461. view {
  462. margin-bottom: 12rpx;
  463. padding-left: 24rpx;
  464. position: relative;
  465. &::before {
  466. content: "";
  467. width: 8rpx;
  468. height: 8rpx;
  469. background: rgba(255, 119, 0, 0.5);
  470. border-radius: 50%;
  471. position: absolute;
  472. left: 0;
  473. top: 50%;
  474. transform: translateY(-50%);
  475. }
  476. }
  477. }
  478. }
  479. </style>