waistLine.vue 12 KB

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