diff --git a/api/request.js b/api/request.js index fd2d794..af3b3c8 100644 --- a/api/request.js +++ b/api/request.js @@ -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; } diff --git a/pages/home/index.js b/pages/home/index.js index d1022f5..bbfe5ff 100644 --- a/pages/home/index.js +++ b/pages/home/index.js @@ -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; }); } diff --git a/pages/login/login.js b/pages/login/login.js index 0b93f79..e25ae6a 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -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 }) diff --git a/pages/loginCode/loginCode.js b/pages/loginCode/loginCode.js index 191cd18..c9f83c6 100644 --- a/pages/loginCode/loginCode.js +++ b/pages/loginCode/loginCode.js @@ -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, diff --git a/pages/my/index.js b/pages/my/index.js index da7fd47..f7f0164 100644 --- a/pages/my/index.js +++ b/pages/my/index.js @@ -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; }, diff --git a/pages/my/info-edit/index.js b/pages/my/info-edit/index.js index bd2b822..c2b541e 100644 --- a/pages/my/info-edit/index.js +++ b/pages/my/info-edit/index.js @@ -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: '提交成功', diff --git a/pages/my/info-edit/index.wxml b/pages/my/info-edit/index.wxml index 351494a..969da20 100644 --- a/pages/my/info-edit/index.wxml +++ b/pages/my/info-edit/index.wxml @@ -8,7 +8,7 @@ - + 姓名字数在2至20之间 @@ -20,61 +20,61 @@ - + 身份证号输入有误 - + 请选择出生日期 - + 请输入年龄 - + 请输入出生体重 - + 请选择胆道闭锁手术时间 - + 请选择胎次 - + 请选择产次 - + 请选择受孕方式 - + 请输入孕周 - + 请选择产检是否有异常 @@ -82,7 +82,7 @@ - + 请选择分娩方式 diff --git a/pages/therapeuticRegimen/index.less b/pages/therapeuticRegimen/index.less index f858728..2d99466 100644 --- a/pages/therapeuticRegimen/index.less +++ b/pages/therapeuticRegimen/index.less @@ -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; } } \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json index ac41ad3..b9b942c 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -154,7 +154,7 @@ ] } }, - "libVersion": "3.8.10", + "libVersion": "3.8.11", "setting": { "urlCheck": false, "compileHotReLoad": false