bodyTemperature.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view class="container">
  3. <uni-nav-bar fixed :border="false" :backgroundColor="`rgba(255,255,255,${opacity})`" title="体温"
  4. :statusBar="true" left-icon="left" @clickLeft="back"></uni-nav-bar>
  5. <image class="page-bg" src="@/static/images/pages_watch/images/temperature_top_bg.png" mode="widthFix"></image>
  6. <view class="container-body">
  7. <dateTimePicker @onChange="onChangeTime" />
  8. <!-- 体温趋势 -->
  9. <view class="box" style="padding-bottom: 0;">
  10. <view class="box-title y-f" :style="{visibility: chooseItem.time ? 'visible': 'hidden'}">
  11. <view>{{chooseItem.time}}</view>
  12. <view class="x-c" style="align-items: baseline;"><text class="box-title-num">{{chooseItem.temp || '--'}}</text><text class="box-title-unit">℃</text></view>
  13. </view>
  14. <view class="echartbox">
  15. <qiun-data-charts v-show="!isEmpty" type="column" :opts="opts" :chartData="chartData"
  16. tooltipFormat="temTooltip" @getIndex="getIndex" />
  17. <myEmpty v-show="isEmpty" style="padding: 40rpx 0 0 0;"></myEmpty>
  18. </view>
  19. <view class="legend" v-show="!loading && !isEmpty">
  20. <view class="legend-item">
  21. <view class="legend-dot" style="background-color: #52D087;"></view><text>{{'<'}}37.2℃</text>
  22. </view>
  23. <view class="legend-item">
  24. <view class="legend-dot" style="background-color: #FDBD27;"></view><text>37.2 - 38.0℃</text>
  25. </view>
  26. <view class="legend-item">
  27. <view class="legend-dot" style="background-color: #FF5558;"></view><text>{{'≥'}}38.0℃</text>
  28. </view>
  29. </view>
  30. <view class="statistics">
  31. <view class="statistics-item">
  32. <view>当前</view>
  33. <view class="statistics-num">{{last || '--'}}<text style="font-weight: 400;font-size: 28rpx;">℃</text></view>
  34. </view>
  35. <view class="statistics-item">
  36. <view>最低</view>
  37. <view class="statistics-num">{{min || '--'}}<text style="font-weight: 400;font-size: 28rpx;">℃</text></view>
  38. </view>
  39. <view class="statistics-item">
  40. <view>最高</view>
  41. <view class="statistics-num">{{max || '--'}}<text style="font-weight: 400;font-size: 28rpx;">℃</text></view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="box boxinfo">
  46. <view class="boxinfo-title x-f">
  47. <image src="@/static/images/pages_watch/icons/wendu_icon.png" mode="aspectFill"></image>
  48. <text>关于体温</text>
  49. </view>
  50. <view>
  51. <view>正常体温一天中不断变化,早晨体温低,中午和晚上体温高,正常的平均体温为37℃(98.6°F.).一般清晨2点5点体温最,下午5点到7点体温最高,其变动范围约在0.5到1℃之间.您的正常体温可能比该值稍高或稍低。</view>
  52. <view style="margin-top: 20rpx;">影响体温的因素有很多,包括剧烈运动、室外炎热程度和湿度以及月经周期。当然,生病时的体温也可能升高。休温过高通党称为发烧。</view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import myEmpty from "@/pages_watch/components/myEmpty/myEmpty.vue"
  60. import dateTimePicker from "@/pages_watch/components/dateTimePicker/dateTimePicker.vue"
  61. import {
  62. temperature
  63. } from "@/api/pages_watch/healthMonitoring.js";
  64. export default {
  65. components: {
  66. myEmpty,
  67. dateTimePicker
  68. },
  69. data() {
  70. return {
  71. opacity: 0,
  72. loading: true,
  73. isEmpty: false,
  74. // 0:正常,1:偏低2:偏高
  75. status1: 0,
  76. status2: 0,
  77. last: 0,
  78. min: 0,
  79. max: 0,
  80. chooseItem: {
  81. temp: '',
  82. time: ''
  83. },
  84. list: [],
  85. chartData: {},
  86. opts: {
  87. padding: [15, 0, 15, 0],
  88. enableScroll: false,
  89. dataLabel: false,
  90. legend: {
  91. show: false
  92. },
  93. xAxis: {
  94. disableGrid: true,
  95. fontSize: 12,
  96. axisLine: false,
  97. fontColor: '#ccc',
  98. labelCount: 7,
  99. format: "formatterTime",
  100. },
  101. yAxis: {
  102. gridType: "dash",
  103. dashLength: 2,
  104. data: [{
  105. fontColor: '#ccc',
  106. min: 0,
  107. // max: 100,
  108. axisLine: false,
  109. fontSize: 12,
  110. }]
  111. },
  112. extra: {
  113. tooltip: {
  114. gridType: "dash",
  115. showArrow: false,
  116. legendShow: true,
  117. legendShape: "circle"
  118. },
  119. column: {
  120. type: "group",
  121. width: 12,
  122. barBorderRadius: [4, 4, 0, 0],
  123. }
  124. }
  125. }
  126. }
  127. },
  128. methods: {
  129. back() {
  130. uni.navigateBack({
  131. delta: 1
  132. })
  133. },
  134. onChangeTime(time) {
  135. const param = {
  136. startTime: this.$timeFormat(time[0], 'yyyy/mm/dd hh:MM:ss'),
  137. endTime: this.$timeFormat(time[1], 'yyyy/mm/dd hh:MM:ss'),
  138. deviceId: uni.getStorageSync("deviceId") || ""
  139. }
  140. this.getServerData(param)
  141. },
  142. getServerData(param) {
  143. this.loading = true
  144. this.list = []
  145. this.chooseItem = {
  146. temp: '',
  147. time: ''
  148. }
  149. temperature(param).then((res) => {
  150. this.loading = false
  151. this.isEmpty = !(res.data && res.data.list && res.data.list.length > 0)
  152. if (res.code == 200 && res.data) {
  153. this.last = res.data.last
  154. this.min = res.data.min
  155. this.max = res.data.max
  156. this.list = res.data.list || []
  157. this.chooseItem.time = res.data.list[res.data.list.length - 1].createTime
  158. this.chooseItem.temp = res.data.list[res.data.list.length - 1].estTemp
  159. let chartData = {
  160. categories: res.data.list.map(item => item.createTime),
  161. series: [{
  162. name: "体温",
  163. data: res.data.list.map(item => ({
  164. value: item.estTemp,
  165. color: item.estTemp < 38 && item.estTemp > 37.2 ? "#FDBD27" : item.estTemp >= 38 ? "#FF5558" : "#52D087"
  166. }))
  167. }]
  168. }
  169. this.chartData = JSON.parse(JSON.stringify(chartData));
  170. } else {
  171. this.last = undefined
  172. this.max = undefined
  173. this.min = undefined
  174. }
  175. }).catch((err) => {
  176. this.loading = false
  177. });
  178. },
  179. getIndex(e) {
  180. if(e.currentIndex.index < 0) return;
  181. const index = e.currentIndex.index
  182. this.chooseItem = {
  183. temp: this.list[index].estTemp,
  184. time: this.list[index].createTime,
  185. }
  186. }
  187. },
  188. onPageScroll(e) {
  189. if (e.scrollTop <= 44) {
  190. this.opacity = e.scrollTop / 44 * 1
  191. } else if (e.scrollTop > 44) {
  192. this.opacity = 1
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss" scoped>
  198. @mixin u-flex($flexD, $alignI, $justifyC) {
  199. display: flex;
  200. flex-direction: $flexD;
  201. align-items: $alignI;
  202. justify-content: $justifyC;
  203. }
  204. .boxinfo {
  205. font-family: PingFang SC, PingFang SC;
  206. font-weight: 400;
  207. font-size: 26rpx;
  208. color: #757575;
  209. &-title {
  210. margin-bottom: 24rpx;
  211. font-weight: 500;
  212. font-size: 32rpx;
  213. color: #333333;
  214. image {
  215. height: 56rpx;
  216. width: 56rpx;
  217. margin-right: 6rpx;
  218. }
  219. }
  220. }
  221. .container {
  222. padding: 0 24rpx;
  223. position: relative;
  224. }
  225. .page-bg {
  226. width: 100%;
  227. height: auto;
  228. position: absolute;
  229. top: 0;
  230. left: 0;
  231. }
  232. .container-body {
  233. position: relative;
  234. z-index: 1;
  235. padding-bottom: 24rpx;
  236. }
  237. .box-title {
  238. font-family: PingFang SC, PingFang SC;
  239. font-weight: 400;
  240. font-size: 24rpx;
  241. color: #757575;
  242. &-num {
  243. font-weight: 500;
  244. font-size: 56rpx;
  245. color: #333333;
  246. }
  247. &-unit {
  248. font-size: 28rpx;
  249. color: #333333;
  250. }
  251. }
  252. .ytitle {
  253. margin-top: 10rpx;
  254. line-height: 34rpx;
  255. margin-bottom: 24rpx;
  256. font-family: PingFang SC, PingFang SC;
  257. font-weight: 400;
  258. font-size: 24rpx;
  259. color: #999999;
  260. }
  261. .legend {
  262. height: 48rpx;
  263. // margin-top: 44rpx;
  264. margin-bottom: 24rpx;
  265. @include u-flex(row, center, space-between);
  266. font-family: PingFang SC, PingFang SC;
  267. font-weight: 400;
  268. font-size: 24rpx;
  269. color: #757575;
  270. &-item {
  271. flex: 1;
  272. text-align: center;
  273. @include u-flex(row, center, center);
  274. }
  275. &-dot {
  276. width: 12rpx;
  277. height: 12rpx;
  278. border-radius: 50%;
  279. margin: 12rpx;
  280. }
  281. }
  282. .box {
  283. padding: 24rpx;
  284. margin-bottom: 20rpx;
  285. box-sizing: border-box;
  286. background: #FFFFFF;
  287. border-radius: 16rpx 16rpx 16rpx 16rpx;
  288. }
  289. .echartbox {
  290. height: 520rpx;
  291. width: 100%;
  292. }
  293. .statistics {
  294. @include u-flex(row, center, space-between);
  295. font-family: PingFang SC, PingFang SC;
  296. font-weight: 400;
  297. font-size: 26rpx;
  298. color: #999999;
  299. &-item {
  300. flex: 1;
  301. height: 160rpx;
  302. @include u-flex(column, center, center);
  303. }
  304. &-num {
  305. font-weight: 500;
  306. font-size: 48rpx;
  307. color: #333333;
  308. height: 68rpx;
  309. margin-top: 4rpx;
  310. }
  311. }
  312. </style>