天波h5前端应用
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

167 lignes
5.8KB

  1. <template>
  2. <div class="psychological-main-container">
  3. <van-nav-bar title="今日情绪" :border="true" @click-left="onNavBack">
  4. <template #left>
  5. <div v-show="isShowLeft" class="nav-bar-title">
  6. <van-icon name="arrow-left" size="23"/><span>返回</span>
  7. </div>
  8. </template>
  9. <template #title>
  10. <span>今日情绪</span>
  11. </template>
  12. </van-nav-bar>
  13. <div class="main">
  14. <div class="list">
  15. <div v-for="(item,index) in healhtList" :key="index" :class="['item', item.class]" @click="onClick(item)">
  16. <p class="health-value" :style="{ color: calcColor(item.value) }">
  17. {{ item.value || '--' }}
  18. </p>
  19. <p class="health-name">
  20. {{ item.name || '--'}}
  21. </p>
  22. <div class="health-result">
  23. <div :class="['left', item.class]">
  24. <p class="result">
  25. {{ item.result || '暂无数据'}}
  26. </p>
  27. </div>
  28. <div class="right">
  29. <!-- img -->
  30. <img :src="item.img" alt="">
  31. </div>
  32. </div>
  33. <div class="health-time">
  34. <p class="time">{{ item.time || '--' }}</p>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import axios from "axios";
  43. export default {
  44. name: 'psychologicalMain',
  45. data(){
  46. return {
  47. healhtList: [
  48. /* { value: 40, name: '抑郁倾向', class: 'depression',result: '无抑郁倾向', time: '17:52', img: require('@/assets/img/regardless.png') },
  49. { value: 55, name: '压力', class: 'stress', result: '轻度压力', time: '17:52', img: require('@/assets/img/regardless.png') },
  50. { value: 75, name: '疲劳', class: 'tiredness', result: '中度疲劳', time: '17:52', img: require('@/assets/img/moderate.png') }, */
  51. ],
  52. uid: '',
  53. routeDate: '',
  54. params: {}
  55. }
  56. },
  57. computed: {
  58. isShowLeft() {
  59. return this.$route.query.fromUrl !== undefined;
  60. }
  61. },
  62. created() {
  63. this.loadParams();
  64. this.getHomeData();
  65. },
  66. mounted() {
  67. window.document.title = '心理监测';
  68. },
  69. methods: {
  70. loadParams() {
  71. let params = this.$route.query;
  72. if (params) {
  73. this.uid = params.uid;
  74. this.routeDate = params.date;
  75. this.params = params;
  76. }
  77. },
  78. getHomeData() {
  79. this.$toast.loading('数据加载中');
  80. console.log("this.$store.getters.ssjlToken", this.$store.getters.ssjlToken);
  81. let reqUrl = `https://dbmq.rzliot.com/heart/api/Data/GetHomeData`;
  82. let reqParams = {
  83. uid: this.uid,
  84. date: this.routeDate || this.$dayjs(new Date()).format('YYYY-MM-DD')
  85. };
  86. axios.get(reqUrl, {
  87. params: { ...reqParams },
  88. headers: { 'AuthToken': this.$store.getters.ssjlToken }
  89. }).then(res => {
  90. console.log("res", res);
  91. const data = res.data.response;
  92. this.healhtList = [
  93. // 抑郁
  94. { value: data.DepScore, name: '抑郁倾向', class: 'depression', result: data.DepDesc, time: data.DepMeasureTime ? this.$dayjs(data.DepMeasureTime).format('HH:mm'): '', level: data.DepLevel, img: this.calcImg(data.DepLevel) },
  95. // 压力
  96. { value: data.StressScore, name: '压力', class: 'stress', result: data.StressDesc, time: data.StressMeasureTime ? this.$dayjs(data.StressMeasureTime).format('HH:mm') : '', level: data.StressLevel, img: this.calcImg(data.StressLevel) },
  97. // 疲劳
  98. { value: data.TirScore, name: '疲劳', class: 'tiredness', result: data.TirDesc, time: data.TirMeasureTime ? this.$dayjs(data.TirMeasureTime).format('HH:mm') : '', level: data.TirLevel, img: this.calcImg(data.TirLevel) },
  99. ];
  100. this.$toast.success('数据加载完成');
  101. }).catch(() =>{}).finally(() => { this.$toast.clear() })
  102. },
  103. onClick(item) {
  104. this.$router.replace({
  105. name: 'psychological',
  106. query: {
  107. name: item.class,
  108. uid: this.uid,
  109. date: this.routeDate,
  110. ...this.params
  111. }
  112. })
  113. },
  114. onNavBack() {
  115. if(this.isShowLeft && this.$route.query.fromUrl !== undefined) {
  116. window.location.href = `${this.$route.query.fromUrl}/#/device`;
  117. } else {
  118. this.$router.go(-1);
  119. }
  120. },
  121. // 计算表情
  122. calcImg(level) {
  123. let imgUrl = '';
  124. switch(level) {
  125. case '0':
  126. imgUrl = require('@/assets/img/regardless.png');
  127. break;
  128. case '1':
  129. imgUrl = require('@/assets/img/regardless.png');
  130. break;
  131. case '2':
  132. imgUrl = require('@/assets/img/moderate.png');
  133. break;
  134. case '3':
  135. imgUrl = require('@/assets/img/moderate.png');
  136. break;
  137. }
  138. return imgUrl;
  139. },
  140. // 计算颜色
  141. calcColor(value) {
  142. let color = "";
  143. if (value <= 40) {
  144. color = "#62BD48";
  145. } else if (value > 40 && value <= 65) {
  146. color = "#FEC350";
  147. } else if (value > 65 && value <= 80) {
  148. color = "#F86825";
  149. } else if (value > 80) {
  150. color = "#EB1D15";
  151. } else {
  152. color = "";
  153. }
  154. return color;
  155. }
  156. }
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. @import "./index.scss";
  161. </style>