home_monitoring.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <template>
  2. <view class="mb-5" ref="ccc">
  3. <view class="position-relative bghead" style="margin-top: -80rpx;">
  4. <image src="@/static/img/other/tou.png" mode="widthFix" class="w-100"></image>
  5. </view>
  6. <view class="p-3">
  7. <view class="centerY mb-3 w-100 font-bold">
  8. <view class="bule_line" style="height: 26rpx;"></view>
  9. <text class="font-bold text-dark ml-2 fs-16 line-height1">身体健康数据</text>
  10. </view>
  11. <view class="bg-white" style="border-radius: 16rpx;overflow: hidden;">
  12. <view class="px-2 py-1 centerY" style="background: linear-gradient(180deg, #F6FFFF 0%, #EAFEFF 100%);">
  13. <view class="w-15">
  14. <view class="picbox">
  15. <image class="picimg" src="@/static/img/other/xy.png" mode="aspectFit"></image>
  16. </view>
  17. </view>
  18. <view class=" ml-2">
  19. <view class="fs-14 font-bold line-height1" style="color: #35B79C;">血压</view>
  20. <view class="fs-10">
  21. <text class="text-gry">测量时间</text>
  22. </view>
  23. </view>
  24. <view class="ml-auto fs-14">
  25. <view class="font-bold text-right line-height1" style="color: #868687;">
  26. <span v-if="dataArray.gxyList&&dataArray.gxyList[0]">{{dataArray.gxyList&&dataArray.gxyList[0].rbp||'未测量'}}/{{dataArray.gxyList&&dataArray.gxyList[0].sbp||'未测量'}} mmHg</span>
  27. <span v-else>未测量</span>
  28. </view>
  29. <view class="fs-12 centerY" style="color: #868687 ;">
  30. <text class="iconfont Clock"></text>
  31. <view class="ml-1">
  32. <span v-if="dataArray.gxyList&&dataArray.gxyList[0]">{{dataArray.gxyList&&dataArray.gxyList[0].uploadTime}}</span>
  33. <span v-else>暂无</span>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="iconfont Chevron-Right fs-24" style="color: #35B79C;"></view>
  38. </view>
  39. <view class="px-3 py-2" v-if="dataArray.gxyList&&dataArray.gxyList.length">
  40. <view class="fs-14 text-gry mb-1">
  41. 近7次测量记录
  42. </view>
  43. <view class="">
  44. <view id="echarts1" class="echarts"></view>
  45. </view>
  46. <view class="mt-3 p-2 mb-2"
  47. style="box-shadow: 0px 2px 13px 2px rgba(211,212,214,0.45);border-radius: 8px;">
  48. <view class="centerY">
  49. <image class="w-10" src="@/static/img/other/xy2.png" mode="widthFix"></image>
  50. <view class="fs-14 font-bold ml-2 space-nowrap">
  51. 血压标准
  52. </view>
  53. <view class=" ml-2 fs-12" style="color: #868687;">
  54. <view class="">
  55. 收缩压:90~139 mmHg
  56. </view>
  57. <view class="">
  58. 舒张压:60~90 mmHg
  59. </view>
  60. </view>
  61. </view>
  62. <view class="centerY mt-2">
  63. <image class="w-10" src="@/static/img/other/zjjy.png" mode="widthFix"></image>
  64. <view class="fs-14 font-bold ml-2 space-nowrap">
  65. 专家建议
  66. </view>
  67. <view class=" ml-2 fs-12" style="color: #868687;">
  68. 正常
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="bg-white mt-2" style="border-radius: 16rpx;overflow: hidden;">
  75. <view class="px-2 py-1 centerY" style="background: linear-gradient(180deg, #ebf6ff 0%, #D4EBFF 100%);">
  76. <view class="w-15 ">
  77. <view class="picbox">
  78. <image class="picimg" src="@/static/img/other/xuet.png" mode="aspectFit"></image>
  79. </view>
  80. </view>
  81. <view class=" ml-2">
  82. <view class="fs-14 font-bold line-height1" style="color: #369FE5;">血糖</view>
  83. <view class="fs-10">
  84. <text class="text-gry">测量时间</text>
  85. </view>
  86. </view>
  87. <view class="ml-auto fs-14">
  88. <view class="font-bold text-right line-height1" style="color: #868687;">
  89. <span v-if="dataArray.gxyList&&dataArray.tnbList[0]">{{dataArray.tnbList&&dataArray.tnbList[0].glu||'未测量'}} mmol/L</span>
  90. <span v-else>未测量</span>
  91. </view>
  92. <view class=" centerY" style="color: #868687 ;">
  93. <text class="iconfont Clock"></text>
  94. <view class="fs-12 ml-1">
  95. <span v-if="dataArray.tnbList&&dataArray.tnbList[0]">{{dataArray.tnbList&&dataArray.tnbList[0].uploadTime}}</span>
  96. <span v-else>暂无</span>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="iconfont Chevron-Right fs-24" style="color: #369FE5;"></view>
  101. </view>
  102. <view class="px-3 py-2" v-if="dataArray.tnbList&&dataArray.tnbList.length">
  103. <view class="fs-14 text-gry mb-1">
  104. 近7次测量记录
  105. </view>
  106. <view class="">
  107. <view id="echarts2" class="echarts"></view>
  108. </view>
  109. <view class="mt-3 p-2 mb-2"
  110. style="box-shadow: 0px 2px 13px 2px rgba(211,212,214,0.45);border-radius: 8px;">
  111. <view class="centerY">
  112. <image class="w-10" src="@/static/img/other/xtfw.png" mode="widthFix"></image>
  113. <view class="fs-14 font-bold ml-2 space-nowrap">
  114. 血糖标准
  115. </view>
  116. <view class=" ml-2 fs-12" style="color: #868687;">
  117. <view class="">
  118. 3.9~6.9 mmol/L
  119. </view>
  120. </view>
  121. </view>
  122. <view class="centerY mt-2">
  123. <image class="w-10" src="@/static/img/other/zjjy.png" mode="widthFix"></image>
  124. <view class="fs-14 font-bold ml-2 space-nowrap">
  125. 专家建议
  126. </view>
  127. <view class=" ml-2 fs-12" style="color: #868687;">
  128. 正常
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. <view class="bg-white mt-2" style="border-radius: 16rpx;overflow: hidden;">
  135. <view class="px-2 py-1 centerY" style="background: linear-gradient(180deg, #F6FFFF 0%, #EAFEFF 100%);">
  136. <view class="w-15 ">
  137. <view class="picbox">
  138. <image class="picimg" src="@/static/img/other/xinl.png" mode="aspectFit"></image>
  139. </view>
  140. </view>
  141. <view class=" ml-2">
  142. <view class="fs-14 font-bold line-height1" style="color: #35B79C">心率</view>
  143. <view class="fs-10">
  144. <text class="text-gry">测量时间</text>
  145. </view>
  146. </view>
  147. <view class="ml-auto fs-14">
  148. <view class="font-bold text-right line-height1" style="color: #868687;">
  149. <span v-if="dataArray.gxyList&&dataArray.gxyList[0]">{{dataArray.gxyList&&dataArray.gxyList[0].pulse||'未测量'}} 次/分钟</span>
  150. <span v-else>未测量</span>
  151. </view>
  152. <view class="fs-10 centerY" style="color: #868687 ;">
  153. <text class="iconfont Clock"></text>
  154. <view class="ml-1">
  155. <span v-if="dataArray.gxyList&&dataArray.gxyList[0]">{{dataArray.gxyList&&dataArray.gxyList[0].uploadTime}}</span>
  156. <span v-else>暂无</span>
  157. </view>
  158. </view>
  159. </view>
  160. <view class="iconfont Chevron-Right fs-24" style="color: #35B79C "></view>
  161. </view>
  162. <view class="px-3 py-2" v-if="dataArray.gxyList&&dataArray.gxyList.length">
  163. <view class="fs-14 text-gry mb-1">
  164. 近7次测量记录
  165. </view>
  166. <view class="">
  167. <view id="echarts3" class="echarts"></view>
  168. </view>
  169. <view class="mt-3 p-2 mb-2"
  170. style="box-shadow: 0px 2px 13px 2px rgba(211,212,214,0.45);border-radius: 8px;">
  171. <view class="centerY">
  172. <image class="w-10" src="@/static/img/other/xlfw.png" mode="widthFix"></image>
  173. <view class="fs-14 font-bold ml-2 space-nowrap">
  174. 心率标准
  175. </view>
  176. <view class=" ml-2 fs-12" style="color: #868687;">
  177. 60~100 次/分钟
  178. </view>
  179. </view>
  180. <view class="centerY mt-2">
  181. <image class="w-10" src="@/static/img/other/zjjy.png" mode="widthFix"></image>
  182. <view class="fs-14 font-bold ml-2 space-nowrap">
  183. 专家建议
  184. </view>
  185. <view class=" ml-2 fs-12" style="color: #868687;">
  186. 正常
  187. </view>
  188. </view>
  189. </view>
  190. </view>
  191. </view>
  192. </view>
  193. </view>
  194. </template>
  195. <script>
  196. export default {
  197. data() {
  198. return {
  199. dataArray:{}
  200. };
  201. },
  202. onLoad() {
  203. this.find_home_data()
  204. },
  205. methods: {
  206. async find_home_data() {
  207. uni.showLoading({
  208. title: '加载中'
  209. });
  210. let idCard = uni.getStorageSync('idCard')
  211. let {
  212. data,
  213. code
  214. } = await this.$api.find_home_data({
  215. idCard
  216. })
  217. if (code == 0) {
  218. this.dataArray = data;
  219. if(data&&data.gxyList.length){
  220. this.getdom('echarts1',()=>{
  221. this.chartOption1(data.gxyList, 'echarts1')
  222. })
  223. this.getdom('echarts3',()=>{
  224. this.chartOption3(data.gxyList, 'echarts3')
  225. })
  226. }
  227. if(data&&data.tnbList.length){
  228. this.getdom('echarts2',()=>{
  229. this.chartOption2(data.tnbList, 'echarts3')
  230. })
  231. }
  232. uni.hideLoading();
  233. uni.stopPullDownRefresh()
  234. } else {
  235. uni.hideLoading();
  236. uni.stopPullDownRefresh()
  237. }
  238. console.log(this.dataArray)
  239. },
  240. getdom(dom,cb){
  241. let timer = setInterval(()=>{
  242. if(document.getElementById(dom)){
  243. clearInterval(timer)
  244. cb&&cb()
  245. }
  246. },300)
  247. }
  248. },
  249. onPullDownRefresh() {
  250. this.find_home_data()
  251. }
  252. }
  253. </script>
  254. <script module="echarts" lang="renderjs">
  255. import * as echarts from 'echarts';
  256. import { config } from '@/static/js/defult_value.js';
  257. export default {
  258. mounted() {
  259. console.log(echarts)
  260. // this.initChart('echarts1', this.option)
  261. // this.initChart('echarts2', this.option2)
  262. },
  263. methods: {
  264. initChart(dom, option) {
  265. let chart = echarts.init(document.getElementById(dom))
  266. chart.setOption(option)
  267. },
  268. // updateEcharts(newValue, oldValue, ownerInstance, instance) {
  269. // // 监听 service 层数据变更
  270. // myChart.setOption(newValue)
  271. // },
  272. onClick(event, ownerInstance) {
  273. // 调用 service 层的方法
  274. },
  275. check({
  276. type,
  277. value,
  278. age,
  279. sex
  280. }) {
  281. let msg = uni.getStorageSync('userData')
  282. let arr = config
  283. if (type == 'shrink' && age) {
  284. if (msg.age > 65) {
  285. if (value > arr['shrinktop'][1]) {
  286. return true
  287. }
  288. if (value < arr['shrinktop'][0]) {
  289. return true
  290. }
  291. } else {
  292. if (value > arr['shrinklow'][1]) {
  293. return true
  294. }
  295. if (value < arr['shrinklow'][0]) {
  296. return true
  297. }
  298. }
  299. }
  300. if (sex) {
  301. if (msg.sex == 1) {
  302. if (value > arr[type][0][1]) {
  303. return true
  304. }
  305. if (value < arr[type][0][0]) {
  306. return true
  307. }
  308. } else {
  309. if (value > arr[type][1][1]) {
  310. return true
  311. }
  312. if (value < arr[type][1][0]) {
  313. return true
  314. }
  315. }
  316. }
  317. if (value > arr[type][1]) {
  318. return true
  319. }
  320. if (value < arr[type][0]) {
  321. return true
  322. }
  323. return false
  324. },
  325. chartOption1(data, dom) {
  326. // console.log(data)
  327. let data1 = [],
  328. data2 = [],
  329. data3 = [],
  330. time = []
  331. data.map((item) => {
  332. time.push(this.$mf.timeTrans({
  333. time: item.uploadTime,
  334. format: 'M.D'
  335. }))
  336. data1.push(item.sbp)
  337. data2.push(item.rbp)
  338. data3.push(item.pulse)
  339. })
  340. let arr = []
  341. data.map((item, index) => {
  342. if (this.check({
  343. type: 'shrink',
  344. value: data1[index],
  345. age: true
  346. })) {
  347. arr.push({
  348. name: '收缩压',
  349. value: [item.uploadTime, data1[index]],
  350. symbolSize: 8,
  351. })
  352. }
  353. if (this.check({
  354. type: 'diastole',
  355. value: data2[index]
  356. })) {
  357. arr.push({
  358. name: '舒张压',
  359. value: [item.uploadTime, data2[index]],
  360. symbolSize: 8,
  361. })
  362. }
  363. })
  364. // console.log(arr)
  365. var option = (option = {
  366. legend: {
  367. data: ['收缩压', '舒张压', '心率'],
  368. },
  369. tooltip: {
  370. formatter: function(params) {
  371. console.log(params)
  372. let str =
  373. '<view style="padding:0px;width:140px"><view>' +
  374. params[0].name +
  375. '</view><view class="centerY" style="margin-top:6px"><view style="background:#5470c6;width:10px;height:10px;border-radius: 50%;" ></view><view class="" style="margin-left:4px">' +
  376. params[0].seriesName +
  377. '</view> <view class="ml-auto font-bold">' +
  378. params[0].value +
  379. '</view></view> <view class="centerY" style="margin-top:6px"><view style="background:#91cc75;width:10px;height:10px;border-radius: 50%;" ></view><view class="" style="margin-left:4px">' +
  380. params[1].seriesName +
  381. '</view><view class="ml-auto font-bold">' +
  382. params[1].value +
  383. '</view></view><view class="centerY" style="margin-top:6px"><view style="background:#fac858;width:10px;height:10px;border-radius: 50%;" ></view><view class="" style="margin-left:4px">' +
  384. params[2].seriesName +
  385. '</view><view class="ml-auto font-bold">' +
  386. params[2].value +
  387. '</view></view></view>'
  388. return str
  389. },
  390. trigger: 'axis',
  391. axisPointer: {
  392. type: 'cross',
  393. label: {
  394. backgroundColor: '#6a7985',
  395. },
  396. },
  397. },
  398. grid: {
  399. top: '20%',
  400. left: '3%',
  401. right: '5%',
  402. bottom: '3%',
  403. containLabel: true,
  404. },
  405. xAxis: [{
  406. type: 'category',
  407. axisPointer: {
  408. type: 'shadow',
  409. },
  410. data: time.reverse(),
  411. }, ],
  412. yAxis: [{
  413. type: 'value',
  414. }, ],
  415. series: [{
  416. name: '收缩压',
  417. label: {
  418. show: true,
  419. formatter: '{@score}',
  420. position: 'top'
  421. },
  422. smooth: true,
  423. type: 'line',
  424. data: data1.reverse(),
  425. },
  426. {
  427. name: '舒张压',
  428. label: {
  429. show: true,
  430. formatter: '{@score}',
  431. position: 'bottom',
  432. },
  433. smooth: true,
  434. type: 'line',
  435. data: data2.reverse(),
  436. },
  437. {
  438. type: 'effectScatter',
  439. coordinateSystem: 'cartesian2d',
  440. data: arr,
  441. showEffectOn: 'render',
  442. // zlevel:1,
  443. rippleEffect: {
  444. // 波纹的绘制方式,可选'stroke'和'fill'
  445. brushType: 'fill',
  446. },
  447. itemStyle: {
  448. color: '#F2597F'
  449. },
  450. hoverAnimation: false,
  451. },
  452. ],
  453. })
  454. if (document.getElementById(dom)) {
  455. this.initChart(dom, option)
  456. }
  457. },
  458. chartOption2(data) {
  459. // console.log(data)
  460. let data1 = [],
  461. time = []
  462. data.map((item) => {
  463. time.push(this.$mf.timeTrans({
  464. time: item.uploadTime,
  465. format: 'M.D'
  466. }))
  467. data1.push(item.glu)
  468. })
  469. let arr = []
  470. data.map((item, index) => {
  471. if (this.check({
  472. type: 'bloodGlucose',
  473. value: data1[index],
  474. age: true
  475. })) {
  476. arr.push({
  477. name: '血糖',
  478. value: [item.uploadTime, data1[index]],
  479. symbolSize: 8,
  480. })
  481. }
  482. })
  483. var option = (option = {
  484. legend: {
  485. data: ['血糖'],
  486. },
  487. tooltip: {
  488. trigger: 'axis',
  489. axisPointer: {
  490. type: 'cross',
  491. label: {
  492. backgroundColor: '#6a7985',
  493. },
  494. },
  495. },
  496. grid: {
  497. top: '20%',
  498. left: '3%',
  499. right: '5%',
  500. bottom: '3%',
  501. containLabel: true,
  502. },
  503. xAxis: [{
  504. type: 'category',
  505. axisPointer: {
  506. type: 'shadow',
  507. },
  508. data: time.reverse(),
  509. }, ],
  510. yAxis: [{
  511. type: 'value',
  512. }, ],
  513. series: [{
  514. name: '血糖',
  515. label: {
  516. show: true,
  517. formatter: '{@score}',
  518. position: 'top'
  519. },
  520. smooth: true,
  521. type: 'line',
  522. data: data1.reverse(),
  523. itemStyle: {
  524. color: '#369FE5'
  525. },
  526. },
  527. {
  528. type: 'effectScatter',
  529. coordinateSystem: 'cartesian2d',
  530. data: arr,
  531. showEffectOn: 'render',
  532. // zlevel:1,
  533. rippleEffect: {
  534. // 波纹的绘制方式,可选'stroke'和'fill'
  535. brushType: 'fill',
  536. },
  537. itemStyle: {
  538. color: '#F2597F'
  539. },
  540. hoverAnimation: false,
  541. },
  542. ],
  543. })
  544. this.$nextTick(() => {
  545. if (document.getElementById('echarts2')) {
  546. this.initChart('echarts2', option)
  547. }
  548. })
  549. },
  550. chartOption3(data, dom) {
  551. // console.log(data)
  552. let data1 = [],
  553. data2 = [],
  554. data3 = [],
  555. time = []
  556. data.map((item) => {
  557. time.push(this.$mf.timeTrans({
  558. time: item.uploadTime,
  559. format: 'M.D'
  560. }))
  561. data3.push(item.pulse)
  562. })
  563. let arr = []
  564. data.map((item, index) => {
  565. if (this.check({
  566. type: 'pulse',
  567. value: data3[index]
  568. })) {
  569. arr.push({
  570. name: '心率',
  571. value: [item.uploadTime, data3[index]],
  572. symbolSize: 10,
  573. })
  574. }
  575. })
  576. // console.log(arr)
  577. var option = (option = {
  578. legend: {
  579. data: ['心率'],
  580. },
  581. tooltip: {
  582. trigger: 'axis',
  583. axisPointer: {
  584. type: 'cross',
  585. label: {
  586. backgroundColor: '#6a7985',
  587. },
  588. },
  589. },
  590. grid: {
  591. top: '20%',
  592. left: '3%',
  593. right: '5%',
  594. bottom: '3%',
  595. containLabel: true,
  596. },
  597. xAxis: [{
  598. type: 'category',
  599. axisPointer: {
  600. type: 'shadow',
  601. },
  602. data: time.reverse(),
  603. }, ],
  604. yAxis: [{
  605. type: 'value',
  606. }, ],
  607. series: [{
  608. name: '心率',
  609. label: {
  610. show: true,
  611. formatter: '{@score}',
  612. position: 'top',
  613. },
  614. itemStyle: {
  615. color: '#35B79C'
  616. },
  617. smooth: true,
  618. type: 'line',
  619. data: data3.reverse(),
  620. areaStyle: {
  621. color: {
  622. type: 'linear',
  623. x: 0,
  624. y: 0,
  625. x2: 0,
  626. y2: 1,
  627. global: false,
  628. colorStops: [{
  629. offset: 0,
  630. color: 'rgba(53,183,156,.7)'
  631. },
  632. {
  633. offset: 0.5,
  634. color: 'rgba(53,183,156,0.3)'
  635. },
  636. {
  637. offset: 1,
  638. color: 'rgba(53,183,156,0)'
  639. }
  640. ]
  641. }
  642. },
  643. },
  644. {
  645. type: 'effectScatter',
  646. coordinateSystem: 'cartesian2d',
  647. data: arr,
  648. showEffectOn: 'render',
  649. // zlevel:1,
  650. rippleEffect: {
  651. // 波纹的绘制方式,可选'stroke'和'fill'
  652. brushType: 'fill',
  653. },
  654. itemStyle: {
  655. color: '#F2597F'
  656. },
  657. hoverAnimation: false,
  658. },
  659. ],
  660. })
  661. if (document.getElementById(dom)) {
  662. this.initChart(dom, option)
  663. }
  664. },
  665. }
  666. }
  667. </script>
  668. <style lang="scss">
  669. page {
  670. background: #F5F9FF;
  671. }
  672. .echarts {
  673. width: 100%;
  674. height: 400rpx;
  675. }
  676. </style>