bloodPressure.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <view class="hb column hidden container">
  3. <image class="bg" src="https://user.test.ylrztop.com/images/blood_pressure_top_bg.png" mode="widthFix"></image>
  4. <view :style="{height: statusBarHeight,background: bgColor }"></view>
  5. <u-navbar title="血压检测" titleStyle="font-weight: bold;" @rightClick="rightClick" :autoBack="true"
  6. :bg-color="bgColor">
  7. </u-navbar>
  8. <view class="top-fixed">
  9. <!-- tab切换 -->
  10. <dateTimePicker @onChange="onChangeTime" :tab-color="'orange'"/>
  11. </view>
  12. <scroll-view class="content" :scroll-y="true">
  13. <view class="content-box">
  14. <view class="tltle">血压趋势</view>
  15. <view class="subtitle">单位:mmhg</view>
  16. <view class="charts-box">
  17. <qiun-data-charts type="area" :opts="opts" :chartData="chartData" />
  18. </view>
  19. <view class="legend">
  20. <view class="legend-item">
  21. <view class="legend-dot" style="background-color: #FF5030;"></view><text>收缩压90-140mmHg</text>
  22. </view>
  23. <view class="legend-item">
  24. <view class="legend-dot" style="background-color: #008FD3;"></view><text>舒张压60-90mmHg</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="content-box">
  29. <view class="align-center justify-between">
  30. <view class="tltle">血压异常记录</view>
  31. <view class="more" @click="goPage()">
  32. <text>查看更多</text>
  33. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  34. </view>
  35. </view>
  36. <view class="type-box">
  37. <view class="box bg1">
  38. <view class="fs32 mb12">正常</view>
  39. <view class="align-center justify-between">
  40. <text class="subtitle">{{count.count0}}次</text>
  41. <image class="w24 h24" src="/static/images/health/zc_arrow_icon.png"></image>
  42. </view>
  43. </view>
  44. <view class="box bg2">
  45. <view class="fs32 mb12">轻微</view>
  46. <view class="align-center justify-between">
  47. <text class="subtitle">{{count.count1}}次</text>
  48. <image class="w24 h24" src="/static/images/health/qw_arrow_icon.png"></image>
  49. </view>
  50. </view>
  51. <view class="box bg3">
  52. <view class="fs32 mb12">严重</view>
  53. <view class="align-center justify-between">
  54. <text class="subtitle">{{count.count2}}次</text>
  55. <image class="w24 h24" src="/static/images/health/yz_arrow_icon.png"></image>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="h20"></view>
  61. <view class="btn-box">
  62. <view class="sub-btn" @click="navgetTo()">记录</view>
  63. </view>
  64. </scroll-view>
  65. </view>
  66. </template>
  67. <script>
  68. import {getUserInfo} from '@/api/user.js'
  69. import {getDataList,getLatest,getLatestList} from '@/api/healthUser.js'
  70. import dateTimePicker from "@/pages_echarts/components/dateTimePicker/dateTimePicker.vue"
  71. export default {
  72. components: {
  73. dateTimePicker
  74. },
  75. data() {
  76. return {
  77. loading: false,
  78. isEmpty: false,
  79. statusBarHeight: '',
  80. top: 0,
  81. aIndex:0,
  82. times:[ {name:"每日",val:0},
  83. {name:"每周",val:1},
  84. {name:"每月",val:2}],
  85. indexInfo: [],
  86. chartData: {},
  87. opts: {
  88. padding: [25, 10, 0, 0],
  89. enableScroll: false,
  90. dataLabel: false,
  91. dataPointShapeType: "hollow",
  92. legend: {
  93. show: false
  94. },
  95. xAxis: {
  96. disableGrid: true,
  97. fontSize: 12,
  98. axisLine: false,
  99. fontColor: '#ccc',
  100. labelCount: 7,
  101. format: "formatterTime",
  102. },
  103. yAxis: {
  104. gridType: "dash",
  105. dashLength: 2,
  106. data: [{
  107. fontColor: '#ccc',
  108. min: 0,
  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. area: {
  121. type: "straight",
  122. opacity: 0.2,
  123. addLine: true,
  124. width: 2,
  125. gradient: true,
  126. activeType: "solid"
  127. }
  128. }
  129. },
  130. count:{},
  131. user:null
  132. }
  133. },
  134. computed: {
  135. // 计算属性的 getter
  136. bgColor: function() {
  137. var top = this.top / 30;
  138. return 'rgba(11,179,242, ' + top + ')';
  139. },
  140. },
  141. onLoad(options) {
  142. // 获取系统信息
  143. const sys = uni.getSystemInfoSync()
  144. this.statusBarHeight = sys.statusBarHeight + 'px'
  145. this.userId=options.userId
  146. // this.getUserInfo()
  147. // this.getServerData(0);
  148. uni.$on('refreshBloodPressure', () => {
  149. this.aIndex=0
  150. this.getServerData(0);
  151. })
  152. },
  153. onUnload() { //普通页面在 onUnload 生命周期中执行
  154. uni.$emit('stop')
  155. },
  156. onHide() { //tabBar页面在onHide生命周期中执行
  157. uni.$emit('stop')
  158. },
  159. onPageScroll(e) {
  160. //console.log(e)
  161. this.top = e.scrollTop;
  162. },
  163. methods: {
  164. // tab切换
  165. orderStatusChange(item) {
  166. this.aIndex = item.val
  167. },
  168. onChangeTime(time,tab) {
  169. if (this.userId) {
  170. this.examDate=time
  171. this.getServerData(tab);
  172. }
  173. },
  174. getUserInfo(){
  175. getUserInfo().then(
  176. res => {
  177. if(res.code==200){
  178. if(res.user!=null){
  179. this.user=res.user;
  180. // this.getServerData(0)
  181. }
  182. else{
  183. this.utils.loginOut();
  184. }
  185. }else{
  186. uni.showToast({
  187. icon:'none',
  188. title: "请求失败",
  189. });
  190. }
  191. },
  192. rej => {}
  193. );
  194. },
  195. getServerData(index) {
  196. var that=this
  197. var data={
  198. userId:this.userId,
  199. measurementType: 3,
  200. pageNum:1,
  201. pageSize:100,
  202. timeSearch:this.examDate,
  203. // "value1": 85,
  204. // "measurementTime": this.utils.timeFormat(new Date(),'hh:MM:ss')
  205. }
  206. const weekMap= {
  207. 1: '一',
  208. 2: '二',
  209. 3: '三',
  210. 4: '四',
  211. 5: '五',
  212. 6: '六',
  213. 0: '日' // 注意:JavaScript中getDay()返回0表示周日
  214. };
  215. getLatestList(data).then(
  216. res => {
  217. if (res.code == 200) {
  218. // console.log(res.count0,'res')
  219. this.count=res.count
  220. var list=res.data.list
  221. var time=list.map(item => item.measurementTime).reverse()
  222. var week=list.map(item => '周'+weekMap[item.week]).reverse()
  223. var month=list.map(item => item.measurementDate).reverse()
  224. //模拟从服务器获取数据时的延时
  225. setTimeout(() => {
  226. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  227. let res = {
  228. categories:index==0?time:index==1?week:month,
  229. series: [{
  230. name: "收缩压",
  231. color: "#FF5030",
  232. data: list.map(item => item.value1)
  233. },
  234. {
  235. name: "舒张压",
  236. color: "#008FD3",
  237. data: list.map(item => item.value2)
  238. }
  239. ],
  240. };
  241. this.chartData = JSON.parse(JSON.stringify(res));
  242. }, 500);
  243. } else {
  244. uni.showToast({
  245. icon: 'none',
  246. title: res.msg,
  247. });
  248. }
  249. },
  250. rej => {}
  251. )
  252. },
  253. goPage(index) {
  254. uni.navigateTo({
  255. url: '/pages_echarts/bloodPressureList?userId='+this.userId
  256. })
  257. },
  258. navgetTo() {
  259. uni.navigateTo({
  260. url: '/pages_echarts/bloodPressureDetail?type=add&userId='+this.userId
  261. })
  262. }
  263. }
  264. }
  265. </script>
  266. <style lang="scss" scoped>
  267. .container {
  268. position: relative;
  269. .bg {
  270. width: 100%;
  271. height: 380rpx;
  272. position: absolute;
  273. top: 0;
  274. left: 0;
  275. z-index: -1;
  276. }
  277. }
  278. .top-fixed{
  279. width: 100%;
  280. position: fixed;
  281. top: calc(var(--status-bar-height) + 140rpx);
  282. left: 0;
  283. z-index: 10;
  284. }
  285. .pub-tab-box{
  286. box-sizing: border-box;
  287. width: 400rpx;
  288. // padding: 0 60rpx;
  289. margin: 0 auto;
  290. // background-color: #FFFFFF;
  291. .tab-inner{
  292. height: 88upx;
  293. line-height: 88upx;
  294. display: flex;
  295. align-items: center;
  296. justify-content:space-between;
  297. overflow-x: auto;
  298. }
  299. .item{
  300. font-family: PingFang SC;
  301. font-weight: 400;
  302. font-size: 30rpx;
  303. color: #626468;
  304. line-height: 64rpx;
  305. text-align: center;
  306. &:last-child{
  307. margin-right: 0;
  308. }
  309. &.active{
  310. font-weight: 500;
  311. width: 124rpx;
  312. height: 64rpx;
  313. background: #FF5039;
  314. border-radius: 32rpx 32rpx 32rpx 32rpx;
  315. color: #fff;
  316. }
  317. .text{
  318. position: relative;
  319. z-index: 1;
  320. }
  321. .tab-bg{
  322. width: 72upx;
  323. height: 28upx;
  324. position: absolute;
  325. top: 17upx;
  326. left: 50%;
  327. transform: translateX(-36upx);
  328. z-index: -1;
  329. }
  330. }
  331. }
  332. .content {
  333. padding-top: calc(var(--status-bar-height) + 300rpx) !important;
  334. height: 100vh;
  335. box-sizing: border-box;
  336. width: 100%;
  337. padding: 20rpx;
  338. overflow: hidden;
  339. .btn-box {
  340. height: 120upx;
  341. padding: 0 30upx;
  342. display: flex;
  343. align-items: center;
  344. justify-content: center;
  345. .sub-btn {
  346. width: 388rpx;
  347. height: 72rpx;
  348. line-height: 72upx;
  349. text-align: center;
  350. font-size: 32upx;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. color: #FFFFFF;
  354. background: #FF5039;
  355. border-radius: 44upx;
  356. margin-bottom: 40upx;
  357. }
  358. }
  359. .content-box {
  360. // width: 100%;
  361. background: #FFFFFF;
  362. border-radius: 16rpx 16rpx 16rpx 16rpx;
  363. padding: 24rpx;
  364. margin-bottom: 20rpx;
  365. .tltle {
  366. font-family: PingFang SC;
  367. font-weight: 500;
  368. font-size: 36rpx;
  369. color: #222426;
  370. text-align: left;
  371. margin-bottom: 16rpx;
  372. }
  373. .subtitle {
  374. font-weight: 400;
  375. font-size: 24rpx;
  376. color: #898E91;
  377. text-align: left;
  378. }
  379. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  380. .charts-box {
  381. // width: 100%;
  382. height: 500rpx;
  383. margin-top: 30rpx;
  384. }
  385. .legend {
  386. // height: 34rpx;
  387. margin-top: 44rpx;
  388. // @include u-flex(row, center, space-between);
  389. display: flex;
  390. align-items: center;
  391. justify-content: space-between;
  392. font-family: PingFang SC, PingFang SC;
  393. font-weight: 400;
  394. font-size: 24rpx;
  395. color: #626468;
  396. &-item {
  397. flex: 1;
  398. text-align: center;
  399. // @include u-flex(row, center, center);
  400. display: flex;
  401. align-items: center;
  402. justify-content: center;
  403. }
  404. &-dot {
  405. width: 16rpx;
  406. height: 16rpx;
  407. border-radius: 50%;
  408. margin: 16rpx;
  409. }
  410. }
  411. .more {
  412. display: flex;
  413. align-items: center;
  414. font-family: PingFang SC;
  415. font-weight: 400;
  416. font-size: 24rpx;
  417. color: #898E91;
  418. }
  419. .type-box {
  420. display: flex;
  421. align-items: center;
  422. justify-content: space-between;
  423. margin-top: 20rpx;
  424. .box {
  425. padding: 24rpx;
  426. width: 158rpx;
  427. // height: 144rpx;
  428. border-radius: 16rpx 16rpx 16rpx 16rpx;
  429. &.bg1 {
  430. background: #FAFFFC;
  431. border: 2rpx solid #EBFFF3;
  432. }
  433. &.bg2 {
  434. background: #FEFAF8;
  435. border: 2rpx solid #FDF7F3;
  436. }
  437. &.bg3 {
  438. background: #FFFCFC;
  439. border: 2rpx solid #FCF4F4;
  440. }
  441. }
  442. }
  443. .content-bottom {
  444. padding: 24rpx;
  445. background: #F5F7FA;
  446. border-radius: 16rpx 16rpx 16rpx 16rpx;
  447. margin-top: 32rpx;
  448. .title {
  449. font-family: PingFang SC;
  450. font-weight: 500;
  451. font-size: 28rpx;
  452. color: #222426;
  453. text-align: left;
  454. margin-left: 14rpx;
  455. text {
  456. color: #FF5030;
  457. }
  458. }
  459. .bottom-box {
  460. postion:relative;
  461. font-weight: 400;
  462. font-size: 24rpx;
  463. color: #626468;
  464. text-align: left;
  465. line-height: 40rpx;
  466. padding-top: 24rpx;
  467. padding-left: 24rpx;
  468. view{
  469. position: relative;
  470. }
  471. view::before {
  472. content: "";
  473. width: 8rpx;
  474. height: 8rpx;
  475. background: rgba(255,80,48,0.2);
  476. position: absolute;
  477. left:-22rpx;
  478. top: 20rpx;
  479. border-radius: 50%;
  480. }
  481. }
  482. }
  483. }
  484. }
  485. </style>