微信小店联盟带货小程序

index.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. const DarkModeUtil = require('../../utils/dark-mode.js')
  2. Page({
  3. data: {
  4. isDarkMode: false,
  5. loading: true,
  6. incomeStats: {
  7. totalIncome: '0.00',
  8. todayIncome: '0.00',
  9. pendingIncome: '0.00',
  10. withdrawable: '0.00'
  11. },
  12. incomeList: [],
  13. page: 1,
  14. hasMore: true
  15. },
  16. onLoad() {
  17. // 应用深色模式
  18. DarkModeUtil.applyPageDarkMode(this)
  19. // 监听深色模式变化
  20. DarkModeUtil.listenDarkModeChange(this)
  21. this.loadIncomeStats();
  22. this.loadIncomeList();
  23. },
  24. // 加载收入统计
  25. loadIncomeStats() {
  26. // TODO: Replace with actual API call
  27. setTimeout(() => {
  28. this.setData({
  29. incomeStats: {
  30. totalIncome: '1234.56',
  31. todayIncome: '123.45',
  32. pendingIncome: '456.78',
  33. withdrawable: '789.01'
  34. },
  35. loading: false
  36. });
  37. }, 500);
  38. },
  39. // 加载收入明细
  40. loadIncomeList() {
  41. if (!this.data.hasMore) return;
  42. // TODO: Replace with actual API call
  43. setTimeout(() => {
  44. const newList = [{
  45. id: 1,
  46. type: '分销佣金',
  47. amount: '99.00',
  48. status: '已结算',
  49. createTime: '2024-01-08 12:34:56',
  50. orderNo: 'DD20240108123456'
  51. }];
  52. this.setData({
  53. incomeList: [...this.data.incomeList, ...newList],
  54. page: this.data.page + 1,
  55. hasMore: newList.length === 10
  56. });
  57. }, 500);
  58. },
  59. // 申请提现
  60. applyWithdraw() {
  61. if (parseFloat(this.data.incomeStats.withdrawable) <= 0) {
  62. wx.showToast({
  63. title: '暂无可提现金额',
  64. icon: 'none'
  65. });
  66. return;
  67. }
  68. wx.navigateTo({
  69. url: '/pages/income/withdraw'
  70. });
  71. },
  72. // 下拉刷新
  73. onPullDownRefresh() {
  74. this.setData({
  75. incomeList: [],
  76. page: 1,
  77. hasMore: true
  78. }, () => {
  79. Promise.all([
  80. this.loadIncomeStats(),
  81. this.loadIncomeList()
  82. ]).then(() => {
  83. wx.stopPullDownRefresh();
  84. });
  85. });
  86. },
  87. // 触底加载更多
  88. onReachBottom() {
  89. this.loadIncomeList();
  90. }
  91. });