healthReport.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="container">
  3. <view class="user">
  4. <view class="user-info border-line">
  5. <view class="user-info-head">
  6. <image class="user-info-avatar" :src="$isEmpty(reportUser.avatar) ? avatar : reportUser.avatar" mode="aspectFill"></image>
  7. <view style="flex: 1;overflow: hidden;">
  8. <view class="user-info-name">{{reportUser.nickname || '--'}}</view>
  9. <view class="user-info-tag">
  10. <view>{{reportUser.sex == 1 ? '男' : reportUser.sex == 2 ? '女': '未知'}}</view>
  11. <view>{{reportUser.age || '--'}}岁</view>
  12. <view>{{reportUser.height || '--'}}cm</view>
  13. <view>{{reportUser.weight || '--'}}kg</view>
  14. </view>
  15. <view class="user-info-desc textOne">病史:无病史</view>
  16. </view>
  17. </view>
  18. <!-- <image class="arrow_right_icon" src="@/static/images/pages_watch/icons/right_arrow_right_icon24@2x.png"></image> -->
  19. </view>
  20. <view class="history-report" @click="handleList">
  21. <view>
  22. <image class="history_report_icon" src="@/static/images/pages_watch/icons/history_report_icon.png" mode="aspectFill"></image>
  23. <text>历史健康报告</text>
  24. </view>
  25. <view class="history-report-r">
  26. <text>去看看</text>
  27. <image class="arrow_right_icon" src="@/static/images/pages_watch/icons/right_arrow_right_icon24@2x.png"></image>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="reportbox">
  32. <dateTimePicker ref="dateTimePicker" from="report" :showType="false" :formatType="1" @onChange="onChangeTime" />
  33. <bpChart ref="bpChart" :loading="bpLoading" :boxstyle="{padding: 0,marginTop: '52rpx',marginBottom: '40rpx'}" />
  34. <!-- <view class="tipsbox">
  35. 该月血压整体偏高,应多注意休息,合理安排作息,吃降压药等其它降压手段保持血压正常。
  36. </view> -->
  37. <bsChart ref="bsChart" :loading="bsLoading" :boxstyle="{padding: 0,marginTop: '52rpx',marginBottom: '40rpx'}" />
  38. <!-- <view class="tipsbox">
  39. 该月血糖整体偏高,应多注意休息,合理安排作息,吃降糖药等其它手段保持血糖正常。
  40. </view> -->
  41. <heartChart ref="heartChart" :loading="heartLoading" :boxstyle="{padding: 0,marginTop: '52rpx',marginBottom: '40rpx'}" />
  42. <!-- <view class="tipsbox">
  43. 该月心率多次出现异常,应多注意休息,合理安排作息,吃养心药等其它手段保持心率正常。
  44. </view> -->
  45. <boChart ref="boChart" :loading="boLoading" :boxstyle="{padding: 0,marginTop: '52rpx',marginBottom: '40rpx'}" />
  46. <!-- <view class="tipsbox">
  47. 血氧各项指标正常,请多保持!!!
  48. </view> -->
  49. <sleep ref="sleep" :loading="sleepLoading" :boxstyle="{padding: 0,marginTop: '52rpx',marginBottom: '40rpx'}" />
  50. <!-- <view class="tipsbox">
  51. 您的睡眠质量较好,打败了80%的人,请继续保持,好的睡眠才是养好身体的关键。
  52. </view> -->
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. bpInfo,
  59. bgInfo,
  60. heartRateInfo,
  61. spInfo,
  62. sleepInfo
  63. } from "@/api/pages_watch/healthMonitoring.js";
  64. import {getUserByDeviceId} from "@/api/pages_watch/health.js";
  65. import dateTimePicker from "@/pages_watch/components/dateTimePicker/dateTimePicker.vue";
  66. import bpChart from "@/pages_watch/components/echart/bpChart.vue"; // 血压
  67. import bsChart from "@/pages_watch/components/echart/bsChart.vue"; // 血糖
  68. import heartChart from "@/pages_watch/components/echart/heartChart.vue"; // 心率
  69. import boChart from "@/pages_watch/components/echart/boChart.vue"; // 血氧
  70. import sleep from "@/pages_watch/components/echart/sleep.vue"; // 睡眠
  71. const avatar="/static/images/pages_watch/images/my_heads_icon.png";
  72. export default {
  73. components: {
  74. dateTimePicker,
  75. bpChart,
  76. bsChart,
  77. heartChart,
  78. boChart,
  79. sleep
  80. },
  81. data() {
  82. return {
  83. avatar,
  84. deviceId: uni.getStorageSync("deviceId"),
  85. reportUser: {},
  86. bpLoading: false,
  87. bsLoading: false,
  88. heartLoading: false,
  89. boLoading: false,
  90. sleepLoading: false,
  91. isFamily: false
  92. }
  93. },
  94. onLoad(option) {
  95. this.isFamily = option.selectUser!='0'
  96. this.getReportUser()
  97. uni.$on('refreshReport', (params) => {
  98. if(params) {
  99. this.$refs.dateTimePicker.value = params
  100. this.$refs.dateTimePicker.resetTime()
  101. }
  102. });
  103. },
  104. onUnload() {
  105. // 页面销毁时移除监听,避免重复监听
  106. uni.$off('refreshReport');
  107. },
  108. methods: {
  109. handleList() {
  110. uni.navigateTo({
  111. url: "/pages_watch/health/healthReportHistory"
  112. })
  113. },
  114. onChangeTime(time) {
  115. // [startTime,endTime,value]
  116. // 月份
  117. const param = {
  118. startTime: this.$timeFormat(time[0], 'yyyy/mm/dd hh:MM:ss'),
  119. endTime: this.$timeFormat(time[1], 'yyyy/mm/dd hh:MM:ss'),
  120. deviceId: uni.getStorageSync("deviceId") || ""
  121. }
  122. this.$nextTick(()=>{
  123. this.getBpByDate(param)
  124. this.getBgByDate(param)
  125. this.getHrByDate(param)
  126. this.getSpByDate(param)
  127. this.getSleepByDate(param)
  128. })
  129. },
  130. getReportUser() {
  131. const deviceId = uni.getStorageSync('deviceId') || ''
  132. const param = {
  133. deviceId: deviceId,
  134. isFamily: this.isFamily
  135. }
  136. getUserByDeviceId(param).then((res) => {
  137. this.reportUser = this.$isEmpty(res.data) ? {} : res.data
  138. })
  139. },
  140. // 血压
  141. getBpByDate(param) {
  142. this.bpLoading = true
  143. bpInfo(param).then((res) => {
  144. this.bpLoading = false
  145. this.$refs.bpChart.setChartData(res.data)
  146. }).catch((err) => {
  147. this.bpLoading = false
  148. });
  149. },
  150. // 血糖
  151. getBgByDate(param) {
  152. this.bsLoading = true
  153. bgInfo(param).then((res) => {
  154. this.bsLoading = false
  155. this.$refs.bsChart.setChartData(res.data)
  156. }).catch((err) => {
  157. this.bsLoading = false
  158. });
  159. },
  160. // 心率
  161. getHrByDate(param) {
  162. this.heartLoading = true
  163. heartRateInfo(param).then((res) => {
  164. this.heartLoading = false
  165. this.$refs.heartChart.setChartData(res.data)
  166. }).catch((err) => {
  167. this.heartLoading = false
  168. });
  169. },
  170. // 血氧
  171. getSpByDate(param) {
  172. this.boLoading = true
  173. spInfo(param).then((res) => {
  174. this.boLoading = false
  175. this.$refs.boChart.setChartData(res.data)
  176. }).catch((err) => {
  177. this.boLoading = false
  178. });
  179. },
  180. // 睡眠
  181. getSleepByDate(param) {
  182. this.sleepLoading = true
  183. sleepInfo(param).then((res) => {
  184. this.sleepLoading = false
  185. this.$refs.sleep.setChartData(res.data)
  186. }).catch((err) => {
  187. this.sleepLoading = false
  188. });
  189. },
  190. }
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. @mixin u-flex($flexD, $alignI, $justifyC) {
  195. display: flex;
  196. flex-direction: $flexD;
  197. align-items: $alignI;
  198. justify-content: $justifyC;
  199. }
  200. .user {
  201. padding: 0 32rpx;
  202. background-color: #fff;
  203. font-family: PingFang SC, PingFang SC;
  204. &-info {
  205. padding: 22rpx 0;
  206. @include u-flex(row,center,space-between);
  207. &-name {
  208. font-weight: 600;
  209. font-size: 32rpx;
  210. color: #222222;
  211. }
  212. &-desc{
  213. margin-top: 18rpx;
  214. font-weight: 400;
  215. font-size: 24rpx;
  216. color: #999999;
  217. }
  218. &-tag {
  219. @include u-flex(row,center,flex-start);
  220. // gap: 12rpx;
  221. margin: 16rpx -12rpx -12rpx 0;
  222. flex-wrap: wrap;
  223. font-weight: 400;
  224. font-size: 22rpx;
  225. color: #FF5C03;
  226. view {
  227. min-width: 62rpx;
  228. height: 42rpx;
  229. padding: 0 20rpx;
  230. margin: 0 12rpx 12rpx 0;
  231. box-sizing: border-box;
  232. background: #FCF0E7;
  233. border-radius: 24rpx 24rpx 24rpx 24rpx;
  234. text-align: center;
  235. line-height: 42rpx;
  236. }
  237. }
  238. }
  239. &-info-head {
  240. @include u-flex(row,flex-start,flex-start);
  241. overflow: hidden;
  242. }
  243. &-info-avatar {
  244. flex-shrink: 0;
  245. height: 140rpx;
  246. width: 140rpx;
  247. border-radius: 50%;
  248. overflow: hidden;
  249. margin-right: 28rpx;
  250. }
  251. .arrow_right_icon {
  252. flex-shrink: 0;
  253. height: 48rpx;
  254. width: 48rpx;
  255. }
  256. .history-report {
  257. height: 96rpx;
  258. @include u-flex(row,center,space-between);
  259. font-family: PingFang SC, PingFang SC;
  260. font-weight: 400;
  261. font-size: 28rpx;
  262. color: #222222;
  263. line-height: 96rpx;
  264. &-r {
  265. font-weight: 400;
  266. font-size: 24rpx;
  267. color: #757575;
  268. display: flex;
  269. align-items: center;
  270. }
  271. }
  272. .history_report_icon {
  273. height: 32rpx;
  274. width: 32rpx;
  275. vertical-align: middle;
  276. margin-right: 18rpx;
  277. }
  278. }
  279. .reportbox {
  280. margin-top: 20rpx;
  281. background-color: #fff;
  282. padding: 20rpx 32rpx 0 32rpx;
  283. ::v-deep .pickebox-picker {
  284. margin: 0 !important;
  285. }
  286. }
  287. .tipsbox {
  288. padding: 24rpx;
  289. background: #F5F7FA;
  290. border-radius: 16rpx 16rpx 16rpx 16rpx;
  291. border: 2rpx solid #F5F7FA;
  292. font-family: PingFang SC, PingFang SC;
  293. font-weight: 400;
  294. font-size: 26rpx;
  295. color: #333333;
  296. word-break: break-all;
  297. }
  298. </style>