waistLine.vue 12 KB

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