This commit is contained in:
@zuopngfei 2025-07-24 18:00:35 +08:00
parent a11f8e330d
commit 0ee0842bc4
9 changed files with 237 additions and 152 deletions

View File

@ -1,19 +1,7 @@
// 在登录成功后请调用 resetTokenInvalid() 重置 isTokenInvalid 标志
let isTokenInvalid = false;
const baseUrl = 'https://ddbs.1024tool.vip/';
let isNavigatingToLogin = false;
// 重置 token 失效标志(登录成功后调用)
export function resetTokenInvalid() {
isTokenInvalid = false;
}
function request(url, method = 'GET', data = {}) {
// 如果 token 已失效,直接中断请求
if (isTokenInvalid && wx.getStorageSync('access_token')) {
return Promise.reject({ code: 10103, message: '登录已失效,请重新登录' });
}
const header = {
'content-type': 'application/json',
// 有其他content-type需求加点逻辑判断处理即可
@ -33,21 +21,13 @@ function request(url, method = 'GET', data = {}) {
success(res) {
if (res.data.code) {
if (res.data.code == 10103) {
isTokenInvalid = true;
wx.removeStorageSync('access_token');
if (!isNavigatingToLogin) {
const pages = getCurrentPages();
const currentRoute = pages[pages.length - 1]?.route;
if (currentRoute !== 'pages/login/login') {
isNavigatingToLogin = true;
wx.navigateTo({
url: '/pages/login/login',
complete: () => {
isNavigatingToLogin = false;
}
});
wx.navigateTo({
url: '/pages/login/login',
complete: () => {
isNavigatingToLogin = false;
}
}
});
reject(res.data);
return;
}

View File

@ -1,7 +1,10 @@
import * as echarts from '../../ec-canvas/echarts.min';
import request from '~/api/request';
import { heightList, weightList } from '../../assets/js/heightWeight';
import {
heightList,
weightList
} from '../../assets/js/heightWeight';
const app = getApp();
@ -11,8 +14,8 @@ Page({
return {
title: 'ECharts 可以在微信小程序中使用啦!',
path: '/pages/index/index',
success: function () { },
fail: function () { }
success: function () {},
fail: function () {}
}
},
data: {
@ -23,49 +26,40 @@ Page({
lazyLoad: true
},
activeIndex: 0,
sfData:{},
sfData: {},
sfListLength: 0,
articles:[],
articles: [],
articlesLength: 0,
heightData: [],
weightData: [],
heightChart: null,
weightChart: null,
xAxis: [],
carList: [],
carLength: 0,
},
standardHeight:[],
standardWeight:[],
heightChart: null,
weightChart: null,
standardHeight: [],
standardWeight: [],
// Helper function to strip HTML tags and convert to plain text
stripHtml(html) {
if (!html) return '';
return html.replace(/<[^>]*>/g, '');
},
async getPersonalInfo() {
const info = await request('patient/basic/0').then((res) => res);
if(info.sex == 1){
this.standardHeight = heightList.boy
this.standardWeight = weightList.boy
}else{
this.standardHeight = heightList.girl
this.standardWeight = weightList.girl
}
},
async getSfList(){
async getSfList() {
this.followPlans()
this.getArticleList()
this.getCarList()
},
async followPlans(){
async followPlans() {
const res = await request('patient/follow_plans', 'get', {
page: 1,
page_size: 10,
type: 1
})
// Calculate days between today and plan_date
const today = new Date()
const planDate = new Date(res.list[0].plan_date)
@ -80,8 +74,12 @@ Page({
}
})
},
async getArticleList(){
const res2 = await request('patient/articles', 'get', { title: '', page: 1, page_size: 2 });
async getArticleList() {
const res2 = await request('patient/articles', 'get', {
title: '',
page: 1,
page_size: 2
});
// Convert rich text content to plain text
const plainTextContent = this.stripHtml(res2.list[0].content);
const articleList = res2.list.map(item => {
@ -96,7 +94,7 @@ Page({
})
},
async getCarList() {
async getCarList() {
const res3 = await request('patient/medicine_records', 'get', {
time_type: 1,
status: 0,
@ -115,10 +113,13 @@ Page({
})
},
async medicineRecord(e){
const {id, status} = e.currentTarget.dataset
if(status == 1){
await request('patient/medicine_record/'+id, 'put', {})
async medicineRecord(e) {
const {
id,
status
} = e.currentTarget.dataset
if (status == 1) {
await request('patient/medicine_record/' + id, 'put', {})
wx.showToast({
type: 'success',
title: '打卡成功',
@ -127,46 +128,70 @@ Page({
}
},
async getChartData(){
const res = await request('patient/chat/0', 'get')
const heightData = []
const weightData = []
const xAxis = []
if(res.list.length > 0){
res.list.forEach(item => {
heightData.push(item.height)
weightData.push(item.weight)
xAxis.push(item.age)
})
async getChartData() {
try {
const res = await request('patient/chat/0', 'get')
this.getSfList()
const heightData = []
const weightData = []
const xAxis = []
if (res.list.length > 0) {
res.list.forEach(item => {
heightData.push(item.height)
weightData.push(item.weight)
xAxis.push(item.age)
})
}
this.setData({
heightData,
weightData,
xAxis
});
this.initHeightChart()
} catch (e) {
console.log(e)
}
this.setData({
heightData,
weightData,
xAxis
});
this.initHeightChart()
},
onLoad(){
onLoad() {
},
onReady() {
},
onShow(){
this.getSfList()
this.getChartData()
async getPersonalInfo() {
const user_info = await wx.getStorageSync('user_info')
console.log(user_info)
if (user_info) {
if (user_info.sex == 1) {
this.standardHeight = heightList.boy
this.standardWeight = weightList.boy
} else {
this.standardHeight = heightList.girl
this.standardWeight = weightList.girl
}
this.getChartData()
} else {
wx.navigateTo({
url: '/pages/login/login'
})
}
},
onShow() {
console.log(this.weightChart)
this.getPersonalInfo()
},
changeChart(e) {
const index = e.currentTarget.dataset.index;
if(index == this.data.activeIndex){
if (index == this.data.activeIndex) {
return
}
this.setData({
@ -182,24 +207,24 @@ Page({
});
},
toClockIn(){
toClockIn() {
wx.navigateTo({
url: '/pages/clockIn/index',
})
},
toEmergency(){
toEmergency() {
wx.navigateTo({
url: '/pages/emergency/index',
})
},
toArticle(){
toArticle() {
wx.navigateTo({
url: '/pages/articleList/index',
})
},
async toArticleDelit(e){
async toArticleDelit(e) {
const index = e.currentTarget.dataset.index;
await wx.setStorageSync('article',JSON.stringify(this.data.articles[index]));
await wx.setStorageSync('article', JSON.stringify(this.data.articles[index]));
wx.navigateTo({
url: '/pages/article/index',
})
@ -223,25 +248,39 @@ Page({
let totalList = []
standardHeight.forEach(item => {
this.data.xAxis.forEach(item2 => {
if(item.age == item2) {
totalList.push(item.value)
}
})
this.data.xAxis.forEach(item2 => {
if (item.age == item2) {
totalList.push(item.value)
}
})
})
const standardLower = totalList.map(item => item[0]);
const standardUpper = totalList.map(item => item[1]);
// const standardRange = standardUpper.map((up, i) => up - standardLower[i]);
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 });
const chart = echarts.init(canvas, null, {
width,
height,
devicePixelRatio: dpr
});
canvas.setChart(chart);
chart.setOption({
title: { text: '', left: 'left', fontSize: 6 },
grid: { containLabel: true, top: '5%', left: '5%', right: '7%', bottom: '3%' },
title: {
text: '',
left: 'left',
fontSize: 6
},
grid: {
containLabel: true,
top: '5%',
left: '5%',
right: '7%',
bottom: '3%'
},
tooltip: {
show: true,
trigger: 'axis',
@ -250,10 +289,21 @@ Page({
return `${param.axisValue}\n${param.seriesName}: ${param.value} cm`;
}
},
xAxis: { type: 'category', boundaryGap: false, data: this.data.xAxis },
yAxis: { x: 'center', type: 'value', splitLine: { lineStyle: { type: 'dashed' } } },
series: [
{
xAxis: {
type: 'category',
boundaryGap: false,
data: this.data.xAxis
},
yAxis: {
x: 'center',
type: 'value',
splitLine: {
lineStyle: {
type: 'dashed'
}
}
},
series: [{
name: '实际身高',
type: 'line',
smooth: true,
@ -264,23 +314,36 @@ Page({
type: 'line',
symbol: 'none',
data: standardUpper,
lineStyle: { opacity: 0 },
lineStyle: {
opacity: 0
},
stack: '标准范围',
areaStyle: { opacity: 0 },
tooltip: { show: true }
areaStyle: {
opacity: 0
},
tooltip: {
show: true
}
},
{
name: '标准下界',
type: 'line',
symbol: 'none',
data: standardLower,
lineStyle: { opacity: 0 },
lineStyle: {
opacity: 0
},
stack: '标准范围',
areaStyle: { color: 'rgba(135,206,250,0.3)' },
tooltip: { show: true }
areaStyle: {
color: 'rgba(135,206,250,0.3)'
},
tooltip: {
show: true
}
}
]
});
this.heightChart = chart;
return chart;
});
}
@ -292,26 +355,40 @@ Page({
let totalList = []
standardWeight.forEach(item => {
this.data.xAxis.forEach(item2 => {
if(item.age == item2) {
totalList.push(item.value)
}
})
this.data.xAxis.forEach(item2 => {
if (item.age == item2) {
totalList.push(item.value)
}
})
})
const standardLower = totalList.map(item => item[0]);
const standardUpper = totalList.map(item => item[1]);
const standardRange = standardUpper.map((up, i) => up - standardLower[i]);
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 });
const chart = echarts.init(canvas, null, {
width,
height,
devicePixelRatio: dpr
});
canvas.setChart(chart);
chart.setOption({
title: { text: '', left: 'left', fontSize: 6 },
grid: { containLabel: true, top: '5%', left: '5%', right: '7%', bottom: '3%' },
title: {
text: '',
left: 'left',
fontSize: 6
},
grid: {
containLabel: true,
top: '5%',
left: '5%',
right: '7%',
bottom: '3%'
},
tooltip: {
show: true,
trigger: 'axis',
@ -320,10 +397,21 @@ Page({
return `${param.axisValue}\n${param.seriesName}: ${param.value} kg`;
}
},
xAxis: { type: 'category', boundaryGap: false, data: this.data.xAxis },
yAxis: { x: 'center', type: 'value', splitLine: { lineStyle: { type: 'dashed' } } },
series: [
{
xAxis: {
type: 'category',
boundaryGap: false,
data: this.data.xAxis
},
yAxis: {
x: 'center',
type: 'value',
splitLine: {
lineStyle: {
type: 'dashed'
}
}
},
series: [{
name: '实际体重',
type: 'line',
smooth: true,
@ -334,23 +422,36 @@ Page({
type: 'line',
symbol: 'none',
data: standardUpper,
lineStyle: { opacity: 0 },
lineStyle: {
opacity: 0
},
stack: '标准范围',
areaStyle: { opacity: 0 },
tooltip: { show: true }
areaStyle: {
opacity: 0
},
tooltip: {
show: true
}
},
{
name: '标准下界',
type: 'line',
symbol: 'none',
data: standardUpper,
lineStyle: { opacity: 0 },
lineStyle: {
opacity: 0
},
stack: '标准范围',
areaStyle: { color: 'rgba(135,206,250,0.3)' },
tooltip: { show: true }
areaStyle: {
color: 'rgba(135,206,250,0.3)'
},
tooltip: {
show: true
}
}
]
});
this.weightChart = chart;
return chart;
});
}

View File

@ -1,6 +1,5 @@
import request from '~/api/request';
import { resetTokenInvalid } from '~/api/request';
Page({
data: {
@ -34,7 +33,6 @@ Page({
// console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
// console.log(e.detail.errno) // 错误码(失败时返回)
if (e.detail.code) {
resetTokenInvalid()
const res = await request('patient/quick_login', 'post', {
code: e.detail.code
})

View File

@ -1,5 +1,4 @@
import request from '~/api/request';
import {resetTokenInvalid } from '~/api/request';
Page({
data: {
code: '',
@ -108,7 +107,6 @@ Page({
// });
// return;
// }
resetTokenInvalid()
const res = await request('patient/code_login', 'post', {
code: this.data.code,

View File

@ -99,6 +99,7 @@ Page({
async getPersonalInfo() {
const info = await request('patient/basic/0').then((res) => res);
await wx.setStorageSync('user_info', info);
return info;
},

View File

@ -423,16 +423,21 @@ Page({
errorStatus.gestational_week = !/^\d+(\.\d+)?$/.test(obj.gestational_week) || Number(obj.gestational_week) <= 0;
errorStatus.prenatal_check_type = !obj.prenatal_check_type;
errorStatus.delivery_type = !obj.delivery_type;
errorStatus.prenatal_check_remark = !obj.prenatal_check_remark;
if(obj.delivery_type == '1'){
errorStatus.prenatal_check_remark = !obj.prenatal_check_remark;
}
if (obj.prenatal_check_type == 2) {
obj.prenatal_check_remark = '无';
errorStatus.prenatal_check_remark = false;
}
console.log(errorStatus);
this.setData({ errorStatus });
if (Object.values(errorStatus).some(v => v)) {
return;
}
obj.birth_weight = Number(obj.birth_weight);
obj.gestational_week = Number(obj.gestational_week);
if (obj.prenatal_check_type == 2) {
obj.prenatal_check_remark = '无';
}
await request('patient/set_personal_information', 'post', obj);
wx.showToast({
title: '提交成功',

View File

@ -8,7 +8,7 @@
</view>
<view class="info-item">
<t-cell class="info-edit__cell" required title="姓名" bordered="{{false}}">
<t-input bind:change="onNameChange" align="right" borderless placeholder="请输入患者姓名" slot="note" value="{{personInfo.username}}"/>
<t-input bind:change="onNameChange" always-embed="{{true}}" align="right" borderless placeholder="请输入患者姓名" slot="note" value="{{personInfo.username}}"/>
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.name}}">姓名字数在2至20之间</view>
</view>
@ -20,61 +20,61 @@
</view>
<view class="info-item">
<t-cell class="info-edit__cell" title="身份证号" bordered="{{false}}">
<t-input type="idcard" bind:change="onIdInput" align="right" borderless placeholder="请输入身份证号" slot="note" value="{{personInfo.id_number}}" />
<t-input type="idcard" always-embed="{{true}}" bind:change="onIdInput" align="right" borderless placeholder="请输入身份证号" slot="note" value="{{personInfo.id_number}}" />
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.id}}">身份证号输入有误</view>
</view>
<view class="info-item">
<t-cell required arrow bind:click="showPicker" data-mode="birth" title="出生日期" bordered="{{false}}">
<t-input align="right" borderless placeholder="请输选择" readonly slot="note" value="{{personInfo.birthday}}" />
<t-input align="right" always-embed="{{true}}" borderless placeholder="请输选择" readonly slot="note" value="{{personInfo.birthday}}" />
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.birthday}}">请选择出生日期</view>
</view>
<view class="info-item">
<t-cell class="info-edit__cell" align="right" required title="年龄" bordered="{{false}}">
<t-input align="right" borderless placeholder="请输入" readonly slot="note" value="{{personInfo.age}}" type="digit"/>
<t-input align="right" always-embed="{{true}}" borderless placeholder="请输入" readonly slot="note" value="{{personInfo.age}}" type="digit"/>
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.age}}">请输入年龄</view>
</view>
<view class="info-item">
<t-cell class="info-edit__cell" required title="出生体重" bordered="{{false}}">
<t-input align="right" bind:change="onWeightInput" borderless placeholder="请输入" slot="note" value="{{personInfo.birth_weight}}" suffix="g" type="digit"/>
<t-input align="right" always-embed="{{true}}" bind:change="onWeightInput" borderless placeholder="请输入" slot="note" value="{{personInfo.birth_weight}}" suffix="g" type="digit"/>
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.birth_weight}}">请输入出生体重</view>
</view>
<view class="info-item">
<t-cell required arrow bind:click="showPicker" data-mode="operative" title="胆道闭锁手术时间" bordered="{{false}}">
<t-input align="right" borderless placeholder="请选择" readonly slot="note" value="{{personInfo.operative_date}}" />
<t-input align="right" always-embed="{{true}}" borderless placeholder="请选择" readonly slot="note" value="{{personInfo.operative_date}}" />
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.operative_date}}">请选择胆道闭锁手术时间</view>
</view>
<view class="info-item">
<t-cell title="胎次" required arrow bordered="{{false}}" bind:click="showSelect" data-mode="parity_number" data-list="{{parity_numberList}}" >
<t-input align="right" borderless placeholder="请选择" readonly slot="note" value="{{parity_numberList[personInfo.parity_number - 1].label}}" />
<t-input align="right" always-embed="{{true}}" borderless placeholder="请选择" readonly slot="note" value="{{parity_numberList[personInfo.parity_number - 1].label}}" />
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.parity_number}}">请选择胎次</view>
</view>
<view class="info-item">
<t-cell title="产次" required arrow bordered="{{false}}" bind:click="showSelect" data-mode="birth_number" data-list="{{birth_numberList}}" >
<t-input align="right" borderless placeholder="请选择" readonly slot="note" value="{{birth_numberList[personInfo.birth_number - 1].label}}" />
<t-input align="right" always-embed="{{true}}" borderless placeholder="请选择" readonly slot="note" value="{{birth_numberList[personInfo.birth_number - 1].label}}" />
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.birth_number}}">请选择产次</view>
</view>
<view class="info-item">
<t-cell title="受孕方式" required arrow bordered="{{false}}" bind:click="showSelect" data-mode="conception_type" data-list="{{conception_typeList}}">
<t-input align="right" borderless placeholder="请选择" readonly slot="note" value="{{conception_typeList[personInfo.conception_type - 1].label}}" />
<t-input align="right" always-embed="{{true}}" borderless placeholder="请选择" readonly slot="note" value="{{conception_typeList[personInfo.conception_type - 1].label}}" />
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.conception_type}}">请选择受孕方式</view>
</view>
<view class="info-item">
<t-cell class="info-edit__cell" required bordered="{{false}}" title="孕周">
<t-input align="right" suffix="周" bind:change="onWeekInput" borderless placeholder="请输入" slot="note" value="{{personInfo.gestational_week}}" type="digit" />
<t-input align="right" always-embed="{{true}}" suffix="周" bind:change="onWeekInput" borderless placeholder="请输入" slot="note" value="{{personInfo.gestational_week}}" type="digit" />
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.gestational_week}}">请输入孕周</view>
</view>
<view class="info-item">
<t-cell title="产检是否有异常(如有,请填写)" bordered="{{false}}" required arrow bind:click="showSelect" data-mode="prenatal_check_type" data-list="{{prenatal_checkList}}" >
<t-input align="right" borderless placeholder="请选择" readonly slot="note" value="{{prenatal_checkList[personInfo.prenatal_check_type - 1].label}}" />
<t-input align="right" always-embed="{{true}}" borderless placeholder="请选择" readonly slot="note" value="{{prenatal_checkList[personInfo.prenatal_check_type - 1].label}}" />
</t-cell>
<t-textarea bind:change="onPrenatalCheckRemarkChange" t-class="external-class" wx:if="{{personInfo.prenatal_check_type == 1}}" placeholder="请输入异常描述" disableDefaultPadding="{{true}}" value="{{personInfo.prenatal_check_remark}}" />
<view class="info-edit__tips" wx:if="{{errorStatus.prenatal_check_type}}">请选择产检是否有异常</view>
@ -82,7 +82,7 @@
</view>
<view class="info-item">
<t-cell title="分娩方式" required arrow bordered="{{false}}" bind:click="showSelect" data-mode="delivery_type" data-list="{{deliveryList}}" >
<t-input align="right" borderless placeholder="请选择" readonly slot="note" value="{{deliveryList[personInfo.delivery_type - 1].label}}" />
<t-input align="right" always-embed="{{true}}" borderless placeholder="请选择" readonly slot="note" value="{{deliveryList[personInfo.delivery_type - 1].label}}" />
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.delivery_type}}">请选择分娩方式</view>
</view>

View File

@ -1,13 +1,14 @@
/* pages/therapeuticRegimen/index.wxss */
pages{
height: 100vh;
overflow: hidden;
// height: 100vh;
// overflow: hidden;
}
.therapeuticRegimen{
box-sizing: border-box;
// padding: 24rpx;
position: relative;
height: calc(100vh - 120rpx);
.scroll-view-box {
padding: 28rpx;
padding-bottom: 0;
@ -19,6 +20,7 @@ pages{
background-color: #fff;
border-radius: 24rpx;
position: relative;
z-index: 1;
overflow: hidden;
margin-bottom: 28rpx;
.tab-text{
@ -110,7 +112,7 @@ pages{
left: 0;
bottom: 0;
right: 0;
z-index: 100;
}
}

View File

@ -154,7 +154,7 @@
]
}
},
"libVersion": "3.8.10",
"libVersion": "3.8.11",
"setting": {
"urlCheck": false,
"compileHotReLoad": false