import { loginStatusPage, post } from '@/utils/https'; import { toArray, toNumber } from '@/utils/util'; Page({ /** * 页面的初始数据 */ data: { process_count: [] as any[], seven_process_count: [] as any[], isLogin: false, }, handleLogin(e: any) { this.setData({ isLogin: e.detail }); if (e.detail) { this.init(); } }, init() { this.getList(); }, getList() { post('Index/index') .then((res: any) => { const process_count = toArray(res.process_count).filter((el) => { el.count = toNumber(el.count); return el.count > 0; }); const arr = toArray(res.seven_process_count).filter((el) => { el.count = toNumber(el.count); return el.count > 0; }); const map = new Map(); arr.forEach((el) => { if (!map.has(el.date)) { map.set(el.date, []); } map.get(el.date).push(el); }); // console.log([...map.values()]); this.setData({ seven_process_count: [...map.values()], process_count: process_count, }); }) .finally(() => { wx.stopPullDownRefresh(); }); }, /** * 生命周期函数--监听页面加载 */ onLoad(_options) {}, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() {}, /** * 生命周期函数--监听页面显示 */ onShow() { loginStatusPage(this); }, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { if (this.data.isLogin) { this.init(); } }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() {}, /** * 用户点击右上角分享 */ onShareAppMessage() {}, });