bloodSugar.vue 12 KB

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