hips.vue 12 KB

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