bloodSugar.vue 12 KB

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