2025-06-08 22:57:41 +08:00

103 lines
1.7 KiB
JavaScript

// pages/clockIn/index.js
import request from '~/api/request';
Page({
/**
* 页面的初始数据
*/
data: {
dataList: [],
},
async getList(){
const res = await request('patient/follow_plans', 'get', {
page: 1,
page_size: 100,
type: 2
})
// Process the list to check dates
const processedList = res.list.map(item => {
const planDate = new Date(item.plan_date);
const today = new Date();
const diffTime = planDate - today;
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
// If within 7 days and status is 1, update to 2
if (diffDays <= 7 && diffDays >= 0 && item.status === 1) {
return { ...item, status: 3 };
}
return item;
});
this.setData({
dataList: processedList
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getList()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
toQuestionnaire() {
wx.navigateTo({
url: '/pages/followUp/index',
})
},
toRegister() {
wx.navigateTo({
url: '/pages/register/index',
})
}
})