const DarkModeUtil = require('../../utils/dark-mode.js') Page({ data: { isDarkMode: false, loading: true, incomeStats: { totalIncome: '0.00', todayIncome: '0.00', pendingIncome: '0.00', withdrawable: '0.00' }, incomeList: [], page: 1, hasMore: true }, onLoad() { // 应用深色模式 DarkModeUtil.applyPageDarkMode(this) // 监听深色模式变化 DarkModeUtil.listenDarkModeChange(this) this.loadIncomeStats(); this.loadIncomeList(); }, // 加载收入统计 loadIncomeStats() { // TODO: Replace with actual API call setTimeout(() => { this.setData({ incomeStats: { totalIncome: '1234.56', todayIncome: '123.45', pendingIncome: '456.78', withdrawable: '789.01' }, loading: false }); }, 500); }, // 加载收入明细 loadIncomeList() { if (!this.data.hasMore) return; // TODO: Replace with actual API call setTimeout(() => { const newList = [{ id: 1, type: '分销佣金', amount: '99.00', status: '已结算', createTime: '2024-01-08 12:34:56', orderNo: 'DD20240108123456' }]; this.setData({ incomeList: [...this.data.incomeList, ...newList], page: this.data.page + 1, hasMore: newList.length === 10 }); }, 500); }, // 申请提现 applyWithdraw() { if (parseFloat(this.data.incomeStats.withdrawable) <= 0) { wx.showToast({ title: '暂无可提现金额', icon: 'none' }); return; } wx.navigateTo({ url: '/pages/income/withdraw' }); }, // 下拉刷新 onPullDownRefresh() { this.setData({ incomeList: [], page: 1, hasMore: true }, () => { Promise.all([ this.loadIncomeStats(), this.loadIncomeList() ]).then(() => { wx.stopPullDownRefresh(); }); }); }, // 触底加载更多 onReachBottom() { this.loadIncomeList(); } });