This commit is contained in:
左哥 2025-06-17 22:48:15 +08:00
parent aab8aecd52
commit 8dff53cd2a
5 changed files with 465 additions and 63 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -1,19 +1,18 @@
import * as echarts from '../../ec-canvas/echarts.min'; import * as echarts from '../../ec-canvas/echarts.min';
import request from '~/api/request'; import request from '~/api/request';
const app = getApp(); const app = getApp();
let height = []
let weight = []
function initChart(canvas, width, height, dpr) { function initChart(canvas, width, height, dpr) {
const chart = echarts.init(canvas, null, { const chart = echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: dpr // new devicePixelRatio: dpr
}); });
canvas.setChart(chart); canvas.setChart(chart);
var option = { var option = {
title: { title: {
text: '身高cm', text: '',
left: 'left', left: 'left',
fontSize: 6 fontSize: 6
}, },
@ -25,8 +24,8 @@ function initChart(canvas, width, height, dpr) {
}, },
grid: { grid: {
containLabel: true, containLabel: true,
top: '12%', top: '5%',
left: '5%', left: '1%',
right: '5%', right: '5%',
bottom: '10%' bottom: '10%'
}, },
@ -37,8 +36,7 @@ function initChart(canvas, width, height, dpr) {
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], data: ['出生', '1月', '2月', '3月', '4月', '5月'],
// show: false
}, },
yAxis: { yAxis: {
x: 'center', x: 'center',
@ -48,13 +46,12 @@ function initChart(canvas, width, height, dpr) {
type: 'dashed' type: 'dashed'
} }
} }
// show: false
}, },
series: [{ series: [{
name: '实际身高', name: '实际身高',
type: 'line', type: 'line',
smooth: true, smooth: true,
data: height data: []
}, { }, {
name: '标准范围', name: '标准范围',
type: 'line', type: 'line',
@ -71,13 +68,13 @@ function initChart2(canvas, width, height, dpr) {
const chart = echarts.init(canvas, null, { const chart = echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: dpr // new devicePixelRatio: dpr
}); });
canvas.setChart(chart); canvas.setChart(chart);
var option = { var option = {
title: { title: {
text: '体重kg', text: '',
left: 'left', left: 'left',
fontSize: 12 fontSize: 12
}, },
@ -89,8 +86,8 @@ function initChart2(canvas, width, height, dpr) {
}, },
grid: { grid: {
containLabel: true, containLabel: true,
top: '12%', top: '5%',
left: '5%', left: '1%',
right: '5%', right: '5%',
bottom: '10%' bottom: '10%'
}, },
@ -101,8 +98,7 @@ function initChart2(canvas, width, height, dpr) {
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], data: ['出生', '1月', '2月', '3月', '4月', '5月'],
// show: false
}, },
yAxis: { yAxis: {
x: 'center', x: 'center',
@ -112,13 +108,12 @@ function initChart2(canvas, width, height, dpr) {
type: 'dashed' type: 'dashed'
} }
} }
// show: false
}, },
series: [{ series: [{
name: '实际体重', name: '实际体重',
type: 'line', type: 'line',
smooth: true, smooth: true,
data: weight data: []
}, { }, {
name: '标准范围', name: '标准范围',
type: 'line', type: 'line',
@ -142,16 +137,20 @@ Page({
}, },
data: { data: {
ec: { ec: {
onInit: '' lazyLoad: true
}, },
ec2: { ec2: {
onInit: '' lazyLoad: true
}, },
activeIndex: 0, activeIndex: 0,
sfData:{}, sfData:{},
sfListLength: 0, sfListLength: 0,
articles:[], articles:[],
articlesLength: 0 articlesLength: 0,
heightData: [],
weightData: [],
heightChart: null,
weightChart: null
}, },
// Helper function to strip HTML tags and convert to plain text // Helper function to strip HTML tags and convert to plain text
@ -198,35 +197,205 @@ Page({
async getChartData(){ async getChartData(){
const res = await request('patient/chat/0', 'get') const res = await request('patient/chat/0', 'get')
const heightData = []
const weightData = []
if(res.list.length > 0){ if(res.list.length > 0){
res.list.forEach(item => { res.list.forEach(item => {
height.push(item.height) heightData.push(item.height)
weight.push(item.weight) weightData.push(item.weight)
}) })
} }
this.setData({ this.setData({
ec: { heightData,
onInit: initChart weightData
}, }, () => {
ec2: { this.initCharts();
onInit: initChart2 });
},
})
}, },
initCharts() {
// 初始化身高图表
if (!this.heightChart) {
const chart1 = this.selectComponent('#mychart-dom-height');
if (chart1) {
chart1.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr
});
canvas.setChart(chart);
const option = {
title: {
text: '',
left: 'left',
fontSize: 6
},
legend: {
data: ['实际身高', '标准范围'],
bottom: 0,
left: 'center',
z: 100
},
grid: {
containLabel: true,
top: '5%',
left: '1%',
right: '5%',
bottom: '10%'
},
tooltip: {
show: true,
trigger: 'axis'
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['出生', '1月', '2月', '3月', '4月', '5月'],
},
yAxis: {
x: 'center',
type: 'value',
splitLine: {
lineStyle: {
type: 'dashed'
}
}
},
series: [{
name: '实际身高',
type: 'line',
smooth: true,
data: this.data.heightData
}, {
name: '标准范围',
type: 'line',
smooth: true,
data: [120, 130, 140, 150, 160, 170]
}]
};
chart.setOption(option);
this.heightChart = chart;
return chart;
});
}
}
// 初始化体重图表
if (!this.weightChart) {
const chart2 = this.selectComponent('#mychart-dom-weight');
if (chart2) {
chart2.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr
});
canvas.setChart(chart);
const option = {
title: {
text: '',
left: 'left',
fontSize: 12
},
legend: {
data: ['实际体重', '标准范围'],
bottom: 0,
left: 'center',
z: 100
},
grid: {
containLabel: true,
top: '5%',
left: '1%',
right: '5%',
bottom: '10%'
},
tooltip: {
show: true,
trigger: 'axis'
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['出生', '1月', '2月', '3月', '4月', '5月'],
},
yAxis: {
x: 'center',
type: 'value',
splitLine: {
lineStyle: {
type: 'dashed'
}
}
},
series: [{
name: '实际体重',
type: 'line',
smooth: true,
data: this.data.weightData
}, {
name: '标准范围',
type: 'line',
smooth: true,
data: [120, 130, 140, 150, 160, 170]
}]
};
chart.setOption(option);
this.weightChart = chart;
return chart;
});
}
}
},
onLoad(){ onLoad(){
this.getChartData()
this.getSfList() this.getSfList()
setTimeout(() => {
this.getChartData().then(() => {
if (this.data.activeIndex === 0) {
this.initHeightChart();
} else {
this.initWeightChart();
}
});
}, 500);
},
onReady() {
// setTimeout(() => {
// this.getChartData().then(() => {
// if (this.data.activeIndex === 0) {
// this.initHeightChart();
// } else {
// this.initWeightChart();
// }
// });
// }, 500);
}, },
changeChart(e) { changeChart(e) {
const index = e.currentTarget.dataset.index; const index = e.currentTarget.dataset.index;
console.log(index); if(index == this.data.activeIndex){
return
}
this.setData({ this.setData({
activeIndex: index activeIndex: index
}) }, () => {
}, setTimeout(() => {
if (index == 0) {
onReady() { this.initHeightChart();
} else {
this.initWeightChart();
}
}, 100);
});
}, },
toClockIn(){ toClockIn(){
@ -251,4 +420,64 @@ Page({
url: '/pages/article/index', url: '/pages/article/index',
}) })
}, },
onUnload() {
// 页面卸载时销毁图表实例
if (this.heightChart) {
this.heightChart.dispose();
this.heightChart = null;
}
if (this.weightChart) {
this.weightChart.dispose();
this.weightChart = null;
}
},
// 初始化身高图表
initHeightChart() {
const chartComp = this.selectComponent('#mychart-dom-height');
if (chartComp) {
chartComp.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, { width, height, devicePixelRatio: dpr });
canvas.setChart(chart);
chart.setOption({
title: { text: '', left: 'left', fontSize: 6 },
legend: { data: ['实际身高', '标准范围'], bottom: 0, left: 'center', z: 100 },
grid: { containLabel: true, top: '5%', left: '1%', right: '5%', bottom: '10%' },
tooltip: { show: true, trigger: 'axis' },
xAxis: { type: 'category', boundaryGap: false, data: ['出生', '1月', '2月', '3月', '4月', '5月'] },
yAxis: { x: 'center', type: 'value', splitLine: { lineStyle: { type: 'dashed' } } },
series: [
{ name: '实际身高', type: 'line', smooth: true, data: this.data.heightData },
{ name: '标准范围', type: 'line', smooth: true, data: [120, 130, 140, 150, 160, 170] }
]
});
return chart;
});
}
},
// 初始化体重图表
initWeightChart() {
const chartComp = this.selectComponent('#mychart-dom-weight');
if (chartComp) {
chartComp.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, { width, height, devicePixelRatio: dpr });
canvas.setChart(chart);
chart.setOption({
title: { text: '', left: 'left', fontSize: 12 },
legend: { data: ['实际体重', '标准范围'], bottom: 0, left: 'center', z: 100 },
grid: { containLabel: true, top: '5%', left: '1%', right: '5%', bottom: '10%' },
tooltip: { show: true, trigger: 'axis' },
xAxis: { type: 'category', boundaryGap: false, data: ['出生', '1月', '2月', '3月', '4月', '5月'] },
yAxis: { x: 'center', type: 'value', splitLine: { lineStyle: { type: 'dashed' } } },
series: [
{ name: '实际体重', type: 'line', smooth: true, data: this.data.weightData },
{ name: '标准范围', type: 'line', smooth: true, data: [120, 130, 140, 150, 160, 170] }
]
});
return chart;
});
}
},
}); });

View File

@ -17,7 +17,8 @@
.home-content { .home-content {
// height: calc(100% - @nav-bar-height); // height: calc(100% - @nav-bar-height);
padding: 30rpx; padding: 28rpx;
padding-bottom: 0;
position: relative; position: relative;
z-index: 1; z-index: 1;
.item-title-img{ .item-title-img{
@ -28,7 +29,7 @@
height: 96rpx; height: 96rpx;
position: relative; position: relative;
left: -24rpx; left: -24rpx;
margin-top: -28rpx; // margin-top: -28rpx;
} }
.item-title { .item-title {
font-family: Alibaba-PuHuiTi, Alibaba-PuHuiTi; font-family: Alibaba-PuHuiTi, Alibaba-PuHuiTi;
@ -54,8 +55,8 @@
.item-content { .item-content {
background-color: #fff; background-color: #fff;
border-radius: 24rpx; border-radius: 24rpx;
padding: 30rpx; padding: 28rpx;
margin-bottom: 30rpx; margin-bottom: 28rpx;
@ -90,7 +91,7 @@
vertical-align: middle; vertical-align: middle;
width: 36rpx; width: 36rpx;
height: 36rpx; height: 36rpx;
margin-right: 10rpx; margin-right: 20rpx;
} }
.item-title-right-text { .item-title-right-text {
position: absolute; position: absolute;
@ -186,6 +187,21 @@
.item-title-icon{ .item-title-icon{
margin-right: 18rpx; margin-right: 18rpx;
} }
}
.item-content-2{
background: linear-gradient( 180deg, #E7F2F2 0%, #F7FCFC 100%);
box-shadow: 0rpx 2rpx 20rpx 0rpx #E9F4F3;
border-radius: 24rpx;
border: 2rpx solid #FFFFFF;
position: relative;
padding-top:0 ;
.item-title{
margin-bottom: 0;
}
.item-box{
margin-top: 0;
}
} }
} }
.item-content-1{ .item-content-1{
@ -195,13 +211,7 @@
border: 2rpx solid #FFFFFF; border: 2rpx solid #FFFFFF;
position: relative; position: relative;
} }
.item-content-2{
background: linear-gradient( 180deg, #E7F2F2 0%, #F7FCFC 100%);
box-shadow: 0rpx 2rpx 20rpx 0rpx #E9F4F3;
border-radius: 24rpx;
border: 2rpx solid #FFFFFF;
position: relative;
}
} }
@ -220,4 +230,150 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
box-shadow: 0px 12px 32px 4px rgba(0, 0, 0, .04), 0px 8px 20px rgba(0, 0, 0, .08); box-shadow: 0px 12px 32px 4px rgba(0, 0, 0, .04), 0px 8px 20px rgba(0, 0, 0, .08);
}
.box_3 {
background-color: rgba(245,245,245,1.000000);
border-radius: 28rpx;
width: 250rpx;
flex-direction: row;
display: flex;
justify-content: space-between;
padding: 4rpx 28rpx 4rpx 4rpx;
white-space: nowrap;
margin-bottom: 16rpx;
margin-left:-4rpx;
}
.text-wrapper_1 {
border-radius: 28rpx;
display: flex;
flex-direction: column;
padding: 12rpx 24rpx 12rpx 24rpx;
}
.text-act{
background-color: rgba(255,255,255,1.000000);
}
.text_2 {
overflow-wrap: break-word;
color: rgba(34,34,34,1);
font-size: 24rpx;
font-family: Alibaba-PuHuiTi-M;
font-weight: normal;
text-align: left;
white-space: nowrap;
line-height: 24rpx;
}
.echarts-title{
font-size: 24rpx;
color: #909399;
line-height: 34rpx;
}
.image-text_3 {
width: 110rpx;
flex-direction: row;
display: flex;
justify-content: space-between;
margin: 32rpx 0rpx 18rpx 0;
}
.box_6 {
border-radius: 100%;
width: 16rpx;
height: 16rpx;
border: 2px solid rgba(0,91,162,1);
display: flex;
flex-direction: column;
margin: 6rpx 0 6rpx 0;
box-sizing: border-box;
}
.text-group_3 {
overflow-wrap: break-word;
color: rgba(34,34,34,1);
font-size: 28rpx;
font-family: Alibaba-PuHuiTi-M;
font-weight: normal;
text-align: left;
white-space: nowrap;
line-height: 28rpx;
}
.box_9 {
background-color: rgba(255,255,255,1.000000);
border-radius: 16rpx;
position: relative;
z-index: 1;
flex-direction: row;
display: flex;
justify-content: flex-center;
padding: 24rpx 24rpx 24rpx 24rpx;
margin-left: 30rpx;
}
.image-text_5 {
width: 298rpx;
flex-direction: row;
display: flex;
justify-content: space-between;
}
.box_10 {
border-radius: 16rpx;
background-image: url(https://lanhu-dds-backend.oss-cn-beijing.aliyuncs.com/merge_image/imgs/c46fcd8a7c644cbbb347a75b175350c6_mergeImage.png);
width: 100rpx;
height: 100rpx;
border: 1px solid rgba(0,91,162,0.1);
display: flex;
flex-direction: column;
box-sizing: border-box;
margin-right:16rpx ;
}
.text-group_5 {
display: flex;
flex-direction: column;
margin: 12rpx 0 12rpx 0;
}
.text_21 {
overflow-wrap: break-word;
color: rgba(34,34,34,1);
font-size: 32rpx;
font-family: Alibaba-PuHuiTi-M;
font-weight: normal;
text-align: right;
white-space: nowrap;
line-height: 32rpx;
margin-right: 86rpx;
}
.text_22 {
overflow-wrap: break-word;
color: rgba(144,147,153,1);
font-size: 28rpx;
font-family: Alibaba-PuHuiTi-R;
font-weight: normal;
text-align: left;
white-space: nowrap;
line-height: 28rpx;
margin-top: 16rpx;
}
.box_11 {
background-color: rgba(237,243,248,1.000000);
width: 2rpx;
height: 62rpx;
display: flex;
flex-direction: column;
margin: 20rpx 0 18rpx 100rpx;
}
.text-wrapper_6 {
background-color: rgba(0,91,162,1.000000);
border-radius: 32rpx;
display: flex;
flex-direction: column;
margin: 22rpx 0 22rpx 24rpx;
padding: 12rpx 40rpx 12rpx 40rpx;
}
.text_23 {
overflow-wrap: break-word;
color: rgba(255,255,255,1);
font-size: 28rpx;
font-family: Alibaba-PuHuiTi-M;
font-weight: normal;
text-align: right;
white-space: nowrap;
line-height: 32rpx;
} }

View File

@ -6,17 +6,19 @@
<image class="item-title-icon" src="../../assets/images/home/icon_1.svg"></image> <image class="item-title-icon" src="../../assets/images/home/icon_1.svg"></image>
宝宝成长曲线</view> 宝宝成长曲线</view>
<view class="item-content"> <view class="item-content">
<view class="echarts-legend">
<view class="{{ activeIndex == 0 ? 'active' : '' }}" data-index="0" bindtap="changeChart"> <view class="box_3">
身高曲线 <view class="{{activeIndex == 0 ? 'text-wrapper_1 text-act' : 'text-wrapper_1'}}" data-index="0" bindtap="changeChart">
<text lines="1" class="text_2">身高曲线</text>
</view> </view>
<view class="{{ activeIndex == 1 ? 'active' : '' }}" data-index="1" bindtap="changeChart"> <view class="{{activeIndex == 1 ? 'text-wrapper_1 text-act' : 'text-wrapper_1'}}" data-index="1" bindtap="changeChart">
体重曲线 <text lines="1" class="text_2">体重曲线</text>
</view> </view>
</view> </view>
<text class="echarts-title">{{activeIndex == 0 ? '身高cm':'体重g'}}</text>
<view class="echarts-canvas-container"> <view class="echarts-canvas-container">
<ec-canvas wx:if="{{ activeIndex == 0 }}" id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas> <ec-canvas wx:if="{{ activeIndex == 0 }}" id="mychart-dom-height" canvas-id="mychart-height" ec="{{ ec }}" force-use-old-canvas="true"></ec-canvas>
<ec-canvas wx:else id="mychart-dom-bar" canvas-id="mychart-bar2" ec="{{ ec2 }}"></ec-canvas> <ec-canvas wx:else id="mychart-dom-weight" canvas-id="mychart-weight" ec="{{ ec2 }}" force-use-old-canvas="true"></ec-canvas>
</view> </view>
</view> </view>
<view class="item-content item-content-1"> <view class="item-content item-content-1">
@ -27,8 +29,8 @@
更多 更多
</view> </view>
</view> </view>
<view class="item-box"> <!-- <view class="item-box"> -->
<view class="item-box-title"> <!-- <view class="item-box-title">
<view class="item-box-title-left"> <view class="item-box-title-left">
中午 12:00 中午 12:00
</view> </view>
@ -36,18 +38,33 @@
未完成 未完成
</view> </view>
</view> </view>
<!-- 药品名字 -->
<view class="drug-name"> <view class="drug-name">
布洛芬 布洛芬
</view> </view>
<!-- 药品用量 -->
<view class="drug-usage"> <view class="drug-usage">
1片 饭后复用 1片 饭后复用
</view> </view>
<t-button theme="primary" block>打卡</t-button> <t-button theme="primary" block>打卡</t-button> -->
</view> <view class="image-text_3">
<view class="box_6"></view>
<text lines="1" class="text-group_3">08:00</text>
</view>
<view class="box_9">
<view class="image-text_5">
<view class="box_10"></view>
<view class="text-group_5">
<text lines="1" class="text_21">优思弗</text>
<text lines="1" class="text_22">1片饭后服用</text>
</view>
</view>
<view class="box_11"></view>
<view class="text-wrapper_6">
<text lines="1" class="text_23">打卡</text>
</view>
</view>
<!-- </view> -->
</view> </view>
<view class="item-content item-content-2" wx:if="{{sfListLength > 0}}"> <view class="item-content item-content-2" wx:if="{{sfListLength > 0}}">
<image class="item-content-1-bg" src="../../assets/images/home/img_2.png" mode="widthFix"></image> <image class="item-content-1-bg" src="../../assets/images/home/img_2.png" mode="widthFix"></image>

View File

@ -169,9 +169,9 @@
height: 120rpx; height: 120rpx;
margin-bottom: 48rpx; margin-bottom: 48rpx;
background-color: rgba(255,255,255,0.5); background-color: rgba(255,255,255,0.5);
padding: 20rpx; // padding: 20rpx;
border-radius: 120rpx; border-radius: 120rpx;
border: 4rpx solid rgba(255,255,255,1); // border: 4rpx solid rgba(255,255,255,1);
image{ image{
width: 100%; width: 100%;
height: 100%; height: 100%;