微信小店联盟带货小程序

team.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. const app = getApp()
  2. Page({
  3. data: {
  4. totalMembers: 36,
  5. directMembers: 12,
  6. indirectMembers: 24,
  7. levelOptions: ['全部', '直属下级', '间接下级'],
  8. currentLevelIndex: 0,
  9. searchKeyword: '',
  10. loading: false,
  11. noMore: false,
  12. page: 1,
  13. pageSize: 10,
  14. teamMembers: [
  15. {
  16. id: '1',
  17. nickname: '小明',
  18. avatar: '/static/images/avatar/avatar1.png',
  19. level: '普通会员',
  20. joinTime: '2023-11-15',
  21. parentNickname: '系统邀请',
  22. commission: '256.50'
  23. },
  24. {
  25. id: '2',
  26. nickname: '小红',
  27. avatar: '/static/images/avatar/avatar2.png',
  28. level: '白银会员',
  29. joinTime: '2023-12-01',
  30. parentNickname: '小明',
  31. commission: '356.80'
  32. },
  33. {
  34. id: '3',
  35. nickname: '小李',
  36. avatar: '/static/images/avatar/avatar3.png',
  37. level: '黄金会员',
  38. joinTime: '2023-12-10',
  39. parentNickname: '小红',
  40. commission: '456.20'
  41. }
  42. ]
  43. },
  44. onLoad() {
  45. // 可以在这里请求实际的数据
  46. },
  47. // 切换会员等级筛选
  48. onLevelChange(e) {
  49. const index = e.detail.value
  50. this.setData({
  51. currentLevelIndex: index,
  52. page: 1,
  53. teamMembers: []
  54. }, () => {
  55. this.loadTeamMembers()
  56. })
  57. },
  58. // 搜索团队成员
  59. onSearchInput(e) {
  60. const keyword = e.detail.value
  61. this.setData({
  62. searchKeyword: keyword,
  63. page: 1,
  64. teamMembers: []
  65. }, () => {
  66. this.loadTeamMembers()
  67. })
  68. },
  69. // 加载团队成员
  70. loadTeamMembers(isLoadMore = false) {
  71. if (this.data.loading) return
  72. this.setData({ loading: true })
  73. // 模拟异步加载数据
  74. setTimeout(() => {
  75. // 这里可以根据 levelOptions 和 searchKeyword 进行过滤
  76. const newList = this.data.teamMembers
  77. this.setData({
  78. teamMembers: isLoadMore ? [...this.data.teamMembers, ...newList] : newList,
  79. loading: false,
  80. noMore: true
  81. })
  82. }, 500)
  83. },
  84. // 加载更多
  85. loadMore() {
  86. if (this.data.noMore) return
  87. this.setData({
  88. page: this.data.page + 1
  89. }, () => {
  90. this.loadTeamMembers(true)
  91. })
  92. }
  93. })