123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- 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();
- }
- });
|