This commit is contained in:
@zuopngfei 2025-08-12 15:31:30 +08:00
parent 4491ed5548
commit 4d2f74c0e1

View File

@ -8,15 +8,15 @@ Page({
list: [] list: []
}, },
toPath(){ toPath() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/AddTherapeuticRegimen/index', url: '/pages/AddTherapeuticRegimen/index',
}) })
}, },
async toPathDetails(e){ async toPathDetails(e) {
const data = this.data.list[e.currentTarget.dataset.index] const data = this.data.list[e.currentTarget.dataset.index]
await wx.setStorageSync('therapeuticRegimen',JSON.stringify(data)); await wx.setStorageSync('therapeuticRegimen', JSON.stringify(data));
wx.navigateTo({ wx.navigateTo({
url: `/pages/AddTherapeuticRegimen/index?id=${data.id}`, url: `/pages/AddTherapeuticRegimen/index?id=${data.id}`,
}) })
@ -25,30 +25,31 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
}, },
async getList(){ async getList() {
const res = await request('patient/medicine_schemes', 'get', { const res = await request('patient/medicine_schemes', 'get', {
page: 1, page: 1,
page_size: 30, page_size: 30,
}) })
const today = new Date() const today = new Date();
today.setHours(0, 0, 0, 0) const todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());
const list = res.list.map(item => { const list = res.list.map(item => {
const startDate = new Date(item.start_date) const startDate = new Date(item.start_date + 'T00:00:00'); // 将时间设置为午夜
const endDate = new Date(item.end_date) const endDate = new Date(item.end_date + 'T00:00:00'); // 将时间设置为午夜
if (todayDate > endDate) {
if (today > endDate) { item.status = '已结束';
item.status = '已结束' } else if (todayDate < startDate) {
} else if (today < startDate) { item.status = '未开始';
item.status = '未开始' } else {
} else if (today >= startDate && today <= endDate) { item.status = '进行中';
item.status = '进行中'
} }
item.detail = JSON.parse(item.detail)
return item item.detail = JSON.parse(item.detail);
}) return item;
});
this.setData({ this.setData({
list: list list: list
}) })
@ -58,7 +59,7 @@ Page({
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady() { onReady() {
}, },
/** /**