hips.vue 12 KB

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