bloodPressure.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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'" ref="datePickerRef"/>
  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. // this.getServerData(0);
  149. uni.$on('refreshBloodPressure', () => {
  150. this.aIndex=0
  151. this.getServerData(0);
  152. })
  153. },
  154. onShow(){
  155. var item={value:'day'}
  156. if (this.$refs.datePickerRef) {
  157. console.log('chufa')
  158. this.$refs.datePickerRef.handleTab(item,0);
  159. this.getServerData(0);
  160. }
  161. },
  162. onUnload() { //普通页面在 onUnload 生命周期中执行
  163. uni.$emit('stop')
  164. },
  165. onHide() { //tabBar页面在onHide生命周期中执行
  166. uni.$emit('stop')
  167. },
  168. onPageScroll(e) {
  169. //console.log(e)
  170. this.top = e.scrollTop;
  171. },
  172. methods: {
  173. // tab切换
  174. orderStatusChange(item) {
  175. this.aIndex = item.val
  176. },
  177. onChangeTime(time,tab) {
  178. this.examDate=time
  179. if (tab) {
  180. this.getServerData(tab);
  181. }
  182. },
  183. getUserInfo(){
  184. getUserInfo().then(
  185. res => {
  186. if(res.code==200){
  187. if(res.user!=null){
  188. this.user=res.user;
  189. // this.getServerData(0)
  190. }
  191. else{
  192. this.utils.loginOut();
  193. }
  194. }else{
  195. uni.showToast({
  196. icon:'none',
  197. title: "请求失败",
  198. });
  199. }
  200. },
  201. rej => {}
  202. );
  203. },
  204. getServerData(index) {
  205. var that=this
  206. var data={
  207. userId:this.userId,
  208. measurementType: 3,
  209. pageNum:1,
  210. pageSize:100,
  211. timeSearch:this.examDate,
  212. // "value1": 85,
  213. // "measurementTime": this.utils.timeFormat(new Date(),'hh:MM:ss')
  214. }
  215. const weekMap= {
  216. 1: '一',
  217. 2: '二',
  218. 3: '三',
  219. 4: '四',
  220. 5: '五',
  221. 6: '六',
  222. 0: '日' // 注意:JavaScript中getDay()返回0表示周日
  223. };
  224. getLatestList(data).then(
  225. res => {
  226. if (res.code == 200) {
  227. // console.log(res.count0,'res')
  228. this.count=res.count
  229. var list=res.data.list
  230. var time=list.map(item => item.measurementTime).reverse()
  231. var week=list.map(item => '周'+weekMap[item.week]).reverse()
  232. var month=list.map(item => item.measurementDate).reverse()
  233. //模拟从服务器获取数据时的延时
  234. setTimeout(() => {
  235. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  236. let res = {
  237. categories:index==0?time:index==1?week:month,
  238. series: [{
  239. name: "收缩压",
  240. color: "#FF5030",
  241. data: list.map(item => item.value1)
  242. },
  243. {
  244. name: "舒张压",
  245. color: "#008FD3",
  246. data: list.map(item => item.value2)
  247. }
  248. ],
  249. };
  250. this.chartData = JSON.parse(JSON.stringify(res));
  251. }, 500);
  252. } else {
  253. uni.showToast({
  254. icon: 'none',
  255. title: res.msg,
  256. });
  257. }
  258. },
  259. rej => {}
  260. )
  261. },
  262. goPage(index) {
  263. uni.navigateTo({
  264. url: '/pages_echarts/bloodPressureList?userId='+this.userId
  265. })
  266. },
  267. navgetTo() {
  268. uni.navigateTo({
  269. url: '/pages_echarts/bloodPressureDetail?type=add&userId='+this.userId
  270. })
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="scss" scoped>
  276. .container {
  277. position: relative;
  278. .bg {
  279. width: 100%;
  280. height: 380rpx;
  281. position: absolute;
  282. top: 0;
  283. left: 0;
  284. z-index: -1;
  285. }
  286. }
  287. .top-fixed{
  288. width: 100%;
  289. position: fixed;
  290. top: calc(var(--status-bar-height) + 140rpx);
  291. left: 0;
  292. z-index: 10;
  293. }
  294. .pub-tab-box{
  295. box-sizing: border-box;
  296. width: 400rpx;
  297. // padding: 0 60rpx;
  298. margin: 0 auto;
  299. // background-color: #FFFFFF;
  300. .tab-inner{
  301. height: 88upx;
  302. line-height: 88upx;
  303. display: flex;
  304. align-items: center;
  305. justify-content:space-between;
  306. overflow-x: auto;
  307. }
  308. .item{
  309. font-family: PingFang SC;
  310. font-weight: 400;
  311. font-size: 30rpx;
  312. color: #626468;
  313. line-height: 64rpx;
  314. text-align: center;
  315. &:last-child{
  316. margin-right: 0;
  317. }
  318. &.active{
  319. font-weight: 500;
  320. width: 124rpx;
  321. height: 64rpx;
  322. background: #FF5039;
  323. border-radius: 32rpx 32rpx 32rpx 32rpx;
  324. color: #fff;
  325. }
  326. .text{
  327. position: relative;
  328. z-index: 1;
  329. }
  330. .tab-bg{
  331. width: 72upx;
  332. height: 28upx;
  333. position: absolute;
  334. top: 17upx;
  335. left: 50%;
  336. transform: translateX(-36upx);
  337. z-index: -1;
  338. }
  339. }
  340. }
  341. .content {
  342. padding-top: calc(var(--status-bar-height) + 300rpx) !important;
  343. height: 100vh;
  344. box-sizing: border-box;
  345. width: 100%;
  346. padding: 20rpx;
  347. overflow: hidden;
  348. .btn-box {
  349. height: 120upx;
  350. padding: 0 30upx;
  351. display: flex;
  352. align-items: center;
  353. justify-content: center;
  354. .sub-btn {
  355. width: 388rpx;
  356. height: 72rpx;
  357. line-height: 72upx;
  358. text-align: center;
  359. font-size: 32upx;
  360. font-family: PingFang SC;
  361. font-weight: bold;
  362. color: #FFFFFF;
  363. background: #FF5039;
  364. border-radius: 44upx;
  365. margin-bottom: 40upx;
  366. }
  367. }
  368. .content-box {
  369. // width: 100%;
  370. background: #FFFFFF;
  371. border-radius: 16rpx 16rpx 16rpx 16rpx;
  372. padding: 24rpx;
  373. margin-bottom: 20rpx;
  374. .tltle {
  375. font-family: PingFang SC;
  376. font-weight: 500;
  377. font-size: 36rpx;
  378. color: #222426;
  379. text-align: left;
  380. margin-bottom: 16rpx;
  381. }
  382. .subtitle {
  383. font-weight: 400;
  384. font-size: 24rpx;
  385. color: #898E91;
  386. text-align: left;
  387. }
  388. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  389. .charts-box {
  390. // width: 100%;
  391. height: 500rpx;
  392. margin-top: 30rpx;
  393. }
  394. .legend {
  395. // height: 34rpx;
  396. margin-top: 44rpx;
  397. // @include u-flex(row, center, space-between);
  398. display: flex;
  399. align-items: center;
  400. justify-content: space-between;
  401. font-family: PingFang SC, PingFang SC;
  402. font-weight: 400;
  403. font-size: 24rpx;
  404. color: #626468;
  405. &-item {
  406. flex: 1;
  407. text-align: center;
  408. // @include u-flex(row, center, center);
  409. display: flex;
  410. align-items: center;
  411. justify-content: center;
  412. }
  413. &-dot {
  414. width: 16rpx;
  415. height: 16rpx;
  416. border-radius: 50%;
  417. margin: 16rpx;
  418. }
  419. }
  420. .more {
  421. display: flex;
  422. align-items: center;
  423. font-family: PingFang SC;
  424. font-weight: 400;
  425. font-size: 24rpx;
  426. color: #898E91;
  427. }
  428. .type-box {
  429. display: flex;
  430. align-items: center;
  431. justify-content: space-between;
  432. margin-top: 20rpx;
  433. .box {
  434. padding: 24rpx;
  435. width: 158rpx;
  436. // height: 144rpx;
  437. border-radius: 16rpx 16rpx 16rpx 16rpx;
  438. &.bg1 {
  439. background: #FAFFFC;
  440. border: 2rpx solid #EBFFF3;
  441. }
  442. &.bg2 {
  443. background: #FEFAF8;
  444. border: 2rpx solid #FDF7F3;
  445. }
  446. &.bg3 {
  447. background: #FFFCFC;
  448. border: 2rpx solid #FCF4F4;
  449. }
  450. }
  451. }
  452. .content-bottom {
  453. padding: 24rpx;
  454. background: #F5F7FA;
  455. border-radius: 16rpx 16rpx 16rpx 16rpx;
  456. margin-top: 32rpx;
  457. .title {
  458. font-family: PingFang SC;
  459. font-weight: 500;
  460. font-size: 28rpx;
  461. color: #222426;
  462. text-align: left;
  463. margin-left: 14rpx;
  464. text {
  465. color: #FF5030;
  466. }
  467. }
  468. .bottom-box {
  469. postion:relative;
  470. font-weight: 400;
  471. font-size: 24rpx;
  472. color: #626468;
  473. text-align: left;
  474. line-height: 40rpx;
  475. padding-top: 24rpx;
  476. padding-left: 24rpx;
  477. view{
  478. position: relative;
  479. }
  480. view::before {
  481. content: "";
  482. width: 8rpx;
  483. height: 8rpx;
  484. background: rgba(255,80,48,0.2);
  485. position: absolute;
  486. left:-22rpx;
  487. top: 20rpx;
  488. border-radius: 50%;
  489. }
  490. }
  491. }
  492. }
  493. }
  494. </style>