tmp
This commit is contained in:
@@ -1,66 +1,90 @@
|
||||
// pages/home/index.js
|
||||
const API = require('../../utils/api.js')
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
todayCount: 0,
|
||||
pendingCount: 0,
|
||||
completedCount: 0,
|
||||
menuList: [
|
||||
{ icon: '/images/icon_order.png', name: '订单管理', url: '/pages/order/index' },
|
||||
{ icon: '/images/icon_patient.png', name: '患者管理', url: '/pages/patient/index' },
|
||||
{ icon: '/images/icon_escort.png', name: '陪诊员管理', url: '/pages/escort/index' },
|
||||
{ icon: '/images/icon_schedule.png', name: '排班管理', url: '/pages/schedule/index' },
|
||||
{ icon: '/images/icon_stats.png', name: '数据统计', url: '/pages/stats/index' },
|
||||
{ icon: '/images/icon_setting.png', name: '系统设置', url: '/pages/setting/index' }
|
||||
],
|
||||
todayOrders: [],
|
||||
statusMap: {
|
||||
pending: '待确认',
|
||||
confirmed: '已确认',
|
||||
in_progress: '进行中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '暖橙陪诊后台', // 转发标题
|
||||
path: '/pages/home/index',
|
||||
}
|
||||
},
|
||||
|
||||
onShareTimeline: function () {
|
||||
return {
|
||||
title: '暖橙陪诊后台',
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.getTodayOrders();
|
||||
this.getStats();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.getTodayOrders();
|
||||
this.getStats();
|
||||
},
|
||||
|
||||
async getStats() {
|
||||
const today = new Date().toISOString().substring(0, 10);
|
||||
const [todayRes, pendingRes, completedRes] = await Promise.all([
|
||||
API.escort.getMyRecords({ appointmentDate: today }),
|
||||
API.escort.getMyRecords({ status: ['pending', 'confirmed'] }),
|
||||
API.escort.getMyRecords({ status: ['completed'] })
|
||||
]);
|
||||
this.setData({
|
||||
todayCount: todayRes.code === 0 ? (todayRes.data.records || []).length : 0,
|
||||
pendingCount: pendingRes.code === 0 ? (pendingRes.data.records || []).length : 0,
|
||||
completedCount: completedRes.code === 0 ? (completedRes.data.records || []).length : 0,
|
||||
});
|
||||
},
|
||||
|
||||
async getTodayOrders() {
|
||||
const res = await API.escort.getMyRecords({
|
||||
appointmentDate: new Date().toISOString().substring(0, 10),
|
||||
});
|
||||
if (res.code == 0) {
|
||||
const records = (res.data.records || []).map(item => {
|
||||
if (item.schedule && item.schedule.date) {
|
||||
const d = new Date(item.schedule.date);
|
||||
item.schedule.date = d.toISOString().substring(0, 10) + ' ' + d.toTimeString().substring(0, 5);
|
||||
}
|
||||
return item;
|
||||
});
|
||||
this.setData({ todayOrders: records });
|
||||
}
|
||||
},
|
||||
|
||||
navigateTo(e) {
|
||||
const url = e.currentTarget.dataset.url
|
||||
wx.navigateTo({ url })
|
||||
},
|
||||
|
||||
viewAllOrders() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/order/index'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user