2025-08-04 22:24:03 +08:00

141 lines
2.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pages/clockIn/index.js
import request from '~/api/request';
Page({
/**
* 页面的初始数据
*/
data: {
dataList: [],
// planId: '',
},
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));
// 早于今天且 status 为 1变为 2
if (diffDays < 0 && item.status === 1) {
return { ...item, status: 2 };
}
// If within 7 days and status is 1, update to 2
if (diffDays <= 7 && diffDays >= 0 && item.status === 1) {
return { ...item, status: 3, diffDays };
}
return item;
});
this.setData({
dataList: processedList
})
// const actObj = processedList.find(item => item.status === 2);
// if (actObj) {
// this.setData({
// planId: actObj.id
// })
// }
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getList()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
toQuestionnaire(e) {
const { item } = e.currentTarget.dataset
wx.navigateTo({
url: `/pages/followUp/index?planId=${item.id}&name=${item.plan_name}&time=${item.plan_date}&questionnaire_id=${item.questionnaire_id}`,
})
},
async goQuestionnaire(e) {
// const data = this.data.dataList
// const target = data.find(item => item.questionnaire_id == 0 && item.status == 2);
const token = await wx.getStorageSync('access_token')
if (!token) {
wx.navigateTo({
url: '/pages/login/login',
});
return
}
wx.navigateTo({
url: `/pages/followUp/index?planId=0&name=&time=&questionnaire_id=0`,
})
},
toRegister() {
wx.navigateTo({
url: '/pages/register/index',
})
},
async toEmergency() {
const token = await wx.getStorageSync('access_token')
if (!token) {
wx.navigateTo({
url: '/pages/login/login',
});
return
}
wx.navigateTo({
url: '/pages/emergency/index',
})
}
})