diff --git a/src/views/insight/index.vue b/src/views/insight/index.vue index 7f3c0f5..7dc94f4 100644 --- a/src/views/insight/index.vue +++ b/src/views/insight/index.vue @@ -57,13 +57,24 @@ - + 更新 + + +
+ + + + +
+
{{ signsChartTitle }}
@@ -98,8 +109,8 @@

总步数:{{ stepsData.total || '--' }}

- - {{ Math.abs(stepsData.lastStepTotalCompare) || '--' }} + + {{ Math.abs(stepsData.compare) || '--' }}
@@ -107,8 +118,8 @@

平均步数:{{ stepsData.avg || '--' }}

- - {{ Math.abs(stepsData.lastStepAvgCompare) || '--' }} + + {{ Math.abs(stepsData.compare) || '--' }}
@@ -124,8 +135,8 @@

总消耗:{{ calorieData.total || '--' }}

- - {{ Math.abs(calorieData.lastCalorieTotalCompare) || '--' }} + + {{ Math.abs(calorieData.compare) || '--' }}
@@ -133,8 +144,8 @@

平均消耗:{{ calorieData.avg || '--' }}

- - {{ Math.abs(calorieData.avg) || '--' }} + + {{ Math.abs(calorieData.compare) || '--' }}
@@ -252,7 +263,8 @@ export default { height: '170', weight: '57', value: '24.5', - result: '肥胖' + result: '肥胖', + isBmiShow: false, }, upImg: require('@/assets/today/icons/up.png'), downImg: require('@/assets/today/icons/down.png'), @@ -284,7 +296,8 @@ export default { signData: {}, signDaysList: [], stepsData: {}, - calorieData: {} + calorieData: {}, + }; }, created() { @@ -718,6 +731,7 @@ export default { value: [index, item.MinValue, item.MaxValue] }; }); + console.log("this.weekAndMonData", this.weekAndMonData); // x轴显示数据 if (this.currentDays === 0) { // 显示今天数据 @@ -928,10 +942,6 @@ export default { }, initData() { //初始化图表 - /* if (!this.emotionChart) { - this.emotionChart = this.$echarts.init(document.getElementById('emotionChart')); - } */ - if (!this.signChart) { this.signChart = this.$echarts.init(document.getElementById('signChart')); } @@ -942,7 +952,6 @@ export default { this.calorieChart = this.$echarts.init(document.getElementById('calorieChart')); } //渲染图表 - /* this.initEmotionChart(); */ this.initSignChart(); }, initEmotionChart() { @@ -990,24 +999,25 @@ export default { let data = await this.getReportData('', this.date.start, this.date.end); if (this.signActive == 0) { //测试 - this.formateHeartRateData(option, data.day); + this.formateHeartRateData(option, data.days); this.signChart.setOption(option); } else if (this.signActive == 1) { //测试 - this.formateTemperatureData(option, data.day); + this.formateTemperatureData(option, data.days); this.signChart.setOption(option); } else if (this.signActive == 2) { option = this.getOption(false); let option2 = this.getOption(false); let data2 = await this.getReportData(3, this.date.start, this.date.end); - this.stepsData = { ...data }; - this.calorieData = { ...data2 }; + this.stepsData = { ...data.stepTotal, ...data.stepAvg }; + this.calorieData = { ...data2.calorieTotal, ...data2.calorieAvg }; - this.formateStepData(option, data.day); - this.formateCalorieData(option2, data2.day); + this.formateStepData(option, data.days); + this.formateCalorieData(option2, data2.days); this.stepChart.setOption(option); this.calorieChart.setOption(option2); + console.log("this.calorieData", this.calorieData); } }, formateEmotionData(option, data) { @@ -1060,24 +1070,11 @@ export default { let xdata = []; let ydata = []; let fill = []; - let max = 0; - data.forEach(item => { - if (item.value > max) { - max = item.value || '--'; - } - }); - data.forEach(item => { - xdata.push(item.date); - fill.push({ - value: max - item.value || '--', - label: { - show: false - }, - itemStyle: { - borderWidth: 3, - borderColor: this.calcColorByEvaluate(item.evaluate) - } - }); + data.forEach((item) => { + xdata.push(item.key); + /* fill.push({ + value: [index, Number(item.valueMax) || '--', Number(item.valueMin) || '--'], + }); */ ydata.push({ value: item.value || '--', label: { @@ -1085,13 +1082,47 @@ export default { }, itemStyle: { borderWidth: 3, - borderColor: this.calcColorByEvaluate(item.evaluate) + borderColor: this.calcColorByEvaluate(item.level) } - }); + }, + ); }); + fill = data.map((item, index) => { + return { + value: [index, item.valueMin || '--', item.valueMax || '--'] + }; + }) option.xAxis.data = xdata; option.series[0].data = ydata; - /* option.series[1].data = fill; */ + option.series[1].data = fill; + option[0] = + option.tooltip = { + trigger: 'axis', + textStyle: { + fontSize: 16 + }, + formatter: function (params) { + return ( + /* params[0].marker + */ + '平均值:' + + params[0].name + + '--' + + params[0].value + + '
' + + /* params[1].marker + */ + '最大值:' + + params[1].name + + '--' + + params[1].value[2] + + '
' + + /* params[1].marker + */ + '最小值:' + + params[1].name + + '--' + + params[1].value[1] + ); + } + }; // 规定最小值 option.yAxis.min = 40; // 规定最大值 @@ -1113,15 +1144,6 @@ export default { ] }; }, - formateHeartRateColor(value) { - if (value > 120) { - return this.heartRateMap.get('偏高'); - } else if (value >= 60) { - return this.heartRateMap.get('正常'); - } else { - return this.heartRateMap.get('偏低'); - } - }, formateTemperatureData(option, data) { let xdata = []; let ydata = []; @@ -1133,17 +1155,8 @@ export default { } }); data.forEach(item => { - xdata.push(item.date); - fill.push({ - value: max - item.value || '--', - label: { - show: false - }, - itemStyle: { - borderWidth: 3, - borderColor: this.calcColorByEvaluate(item.evaluate) - } - }); + xdata.push(item.key); + ydata.push({ value: item.value || '--', label: { @@ -1151,10 +1164,15 @@ export default { }, itemStyle: { borderWidth: 3, - borderColor: this.calcColorByEvaluate(item.evaluate) + borderColor: this.calcColorByEvaluate(item.level) } }); }); + fill = data.map((item, index) => { + return { + value: [index, item.valueMin || '--', item.valueMax || '--'] + }; + }) option.xAxis.data = xdata; option.series[0].data = ydata; option.series[0].markLine = { @@ -1175,24 +1193,46 @@ export default { }, ], } + option.series[1].data = fill; + option[0] = + option.tooltip = { + trigger: 'axis', + textStyle: { + fontSize: 16 + }, + formatter: function (params) { + return ( + /* params[0].marker + */ + '平均值:' + + params[0].name + + '--' + + params[0].value + + '
' + + /* params[1].marker + */ + '最大值:' + + params[1].name + + '--' + + params[1].value[2] + + '
' + + /* params[1].marker + */ + '最小值:' + + params[1].name + + '--' + + params[1].value[1] + ); + } + }; /* option.series[1].data = fill; */ // 规定最小值 option.yAxis.min = 34.5; // 规定最大值 option.yAxis.max = 42.5; }, - formateTemperatureColor(value) { - if (value > 38) { - return this.temperatureMap.get('发烧'); - } else { - return this.temperatureMap.get('正常'); - } - }, formateStepData(option, data) { let xdata = []; let ydata = []; data.forEach(item => { - xdata.push(item.date); + xdata.push(item.key); ydata.push({ value: item.value, label: { @@ -1200,7 +1240,7 @@ export default { }, itemStyle: { borderWidth: 3, - borderColor: this.calcColorByEvaluate(item.evaluate) + borderColor: this.calcColorByEvaluate(item.level) } }); }); @@ -1213,7 +1253,7 @@ export default { let xdata = []; let ydata = []; data.forEach(item => { - xdata.push(item.date); + xdata.push(item.key); ydata.push({ value: item.value, label: { @@ -1221,7 +1261,7 @@ export default { }, itemStyle: { borderWidth: 3, - borderColor: this.calcColorByEvaluate(item.evaluate) + borderColor: this.calcColorByEvaluate(item.level) } }); }); @@ -1231,6 +1271,77 @@ export default { option.yAxis.show = false; }, getOption(/* point = true */) { + let that = this; + let chartSeries = []; + if (this.signActive === 0 || this.signActive === 1) { + chartSeries = [ + { + name: '平均值', + type: 'scatter', + symbolSize: 14, + }, + { + name: '', + type: 'custom', + renderItem: function (params, api) { + let categoryIndex = api.value(0); + let end = (api.coord([categoryIndex, api.value(1)])); + let start = (api.coord([categoryIndex, api.value(2)])); + let width = 16; + let rectShape = that.$echarts.graphic.clipRectByRect( + { + x: start[0] - width / 2, + y: start[1], + width: 16, + height: end[1] - start[1] + }, + { + x: params.coordSys.x, + y: params.coordSys.y, + width: params.coordSys.width, + height: params.coordSys.height + } + ); + if (rectShape) { + rectShape.r = [20]; + } + return ( + rectShape && { + type: 'rect', + shape: rectShape, + style: api.style() + } + ); + }, + itemStyle: { + opacity: 0.8 + }, + encode: { + y: [1, 2], + x: 0 + } + }, + ] + } else { + chartSeries = [ + { + type: 'line', + padding: 10, + smooth: true, + symbol: 'circle', + symbolSize: 10, + itemStyle: { + color: '#fff', + borderWidth: 4 + }, + lineStyle: { + width: 6, + type: 'solid', + color: '#189b3b' + } + }, + ] + } let option = { grid: { show: true, @@ -1309,39 +1420,10 @@ export default { align: 'center' }, formatter: function (params) { - console.log("params", params); return params[0].marker + params[0].name + '
' + params[0].value; } }, - series: [ - { - type: 'line', - padding: 10, - smooth: true, - symbol: 'circle', - symbolSize: 10, - itemStyle: { - color: '#fff', - borderWidth: 4 - }, - lineStyle: { - width: 6, - type: 'solid', - color: '#189b3b' - } - }, - /* { - type: 'bar', - barMaxWidth: 15, - stack: 'value', - stackStrategy: 'all', - animation: false, - itemStyle: { - borderRadius: [12, 12, 0, 0], - show: false - } - } */ - ] + series: chartSeries }; /* if (!point) { @@ -1394,15 +1476,19 @@ export default { let color = ''; const intValue = Number(value); switch (intValue) { - case 1: + case 2: // 偏高 color = '#ff5f8b'; break; - case 2: + case 1: // 正常 color = '#189b3b'; break; - case 3: + case 99: + // 正常 + color = '#189b3b'; + break; + case 0: // 偏低 color = '#2ea7e0'; break; @@ -1424,9 +1510,9 @@ export default { }; return new Promise(resolve => { APIHealthUser.getReportData(reqBody).then(res => { - if (res.data.data.day) { - res.data.data.day = res.data.data.day.map(item => { - item.date = this.$dayjs(item.date).format('MM-DD'); + if (res.data.data.days) { + res.data.data.days = res.data.data.days.map(item => { + item.key = this.$dayjs(item.key).format('MM-DD'); return item; }); } @@ -1434,20 +1520,41 @@ export default { if (this.signActive === 1) { this.signDaysList = [ - { day: res.data.data.normal, name: '正常', color: '#189b3b' }, - { day: res.data.data.fever, name: '偏高', color: '#ff5f8b' } + { + day: res.data.data.normalDay.normalDay, name: '正常', color: '#189b3b' + }, + { day: res.data.data.highDay.highDay, name: '偏高', color: '#ff5f8b' } /* { day: res.data.data.low, name: '偏低', color: '#2ea7e0' } */ ]; + } else if (this.signActive === 0) { + this.signDaysList = [ + { + day: res.data.data.normalDay + .normalDay, name: '正常', color: '#189b3b' + }, + { day: res.data.data.highDay.highDay, name: '偏高', color: '#ff5f8b' }, + { day: res.data.data.lowDay.lowDay, name: '偏低', color: '#2ea7e0' } + ]; } else { this.signDaysList = [ - { day: res.data.data.normal, name: '正常', color: '#189b3b' }, - { day: res.data.data.high, name: '偏高', color: '#ff5f8b' }, - { day: res.data.data.low, name: '偏低', color: '#2ea7e0' } + { + day: res.data.data.normalDay, name: '正常', color: '#189b3b' + }, + { day: res.data.data.highDay, name: '偏高', color: '#ff5f8b' }, + { day: res.data.data.lowDay, name: '偏低', color: '#2ea7e0' } ]; } resolve(res.data.data); }); }); + }, + // 更新bmi + onUpdateBmi() { + // 打开输入弹窗 + this.bmi.isBmiShow = true; + }, + onConfirmBmi() { + } } }; @@ -1519,7 +1626,7 @@ export default { .van-button { padding: 5px 10px; - margin-left: 50px; + margin-left: 10px; font-size: 12px; color: #fff; border-radius: 30px; @@ -1527,6 +1634,15 @@ export default { } } + .bmiDialog { + padding: 40px 60px; + @include center(); + + .van-cell .van-field { + margin: 20px 0 !important; + } + } + .label { font-size: 36px; font-weight: bold; diff --git a/src/views/insight/signsReport.vue b/src/views/insight/signsReport.vue index 49f9d90..fa40d9a 100644 --- a/src/views/insight/signsReport.vue +++ b/src/views/insight/signsReport.vue @@ -1,7 +1,7 @@