From 4d2f74c0e1e649376f01b2dc611c48f0c12fade7 Mon Sep 17 00:00:00 2001 From: "@zuopngfei" Date: Tue, 12 Aug 2025 15:31:30 +0800 Subject: [PATCH] dsdq --- pages/therapeuticRegimen/index.js | 43 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/pages/therapeuticRegimen/index.js b/pages/therapeuticRegimen/index.js index 756be68..d126fc2 100644 --- a/pages/therapeuticRegimen/index.js +++ b/pages/therapeuticRegimen/index.js @@ -8,15 +8,15 @@ Page({ list: [] }, - toPath(){ + toPath() { wx.navigateTo({ url: '/pages/AddTherapeuticRegimen/index', }) }, - async toPathDetails(e){ - const data = this.data.list[e.currentTarget.dataset.index] - await wx.setStorageSync('therapeuticRegimen',JSON.stringify(data)); + async toPathDetails(e) { + const data = this.data.list[e.currentTarget.dataset.index] + await wx.setStorageSync('therapeuticRegimen', JSON.stringify(data)); wx.navigateTo({ url: `/pages/AddTherapeuticRegimen/index?id=${data.id}`, }) @@ -25,30 +25,31 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { - + }, - async getList(){ + async getList() { const res = await request('patient/medicine_schemes', 'get', { page: 1, page_size: 30, }) - const today = new Date() - today.setHours(0, 0, 0, 0) + const today = new Date(); + const todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate()); + const list = res.list.map(item => { - const startDate = new Date(item.start_date) - const endDate = new Date(item.end_date) - - if (today > endDate) { - item.status = '已结束' - } else if (today < startDate) { - item.status = '未开始' - } else if (today >= startDate && today <= endDate) { - item.status = '进行中' + const startDate = new Date(item.start_date + 'T00:00:00'); // 将时间设置为午夜 + const endDate = new Date(item.end_date + 'T00:00:00'); // 将时间设置为午夜 + if (todayDate > endDate) { + item.status = '已结束'; + } else if (todayDate < startDate) { + item.status = '未开始'; + } else { + item.status = '进行中'; } - item.detail = JSON.parse(item.detail) - return item - }) + + item.detail = JSON.parse(item.detail); + return item; + }); this.setData({ list: list }) @@ -58,7 +59,7 @@ Page({ * 生命周期函数--监听页面初次渲染完成 */ onReady() { - + }, /**