123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- const app = getApp()
- Page({
- data: {
- totalMembers: 36,
- directMembers: 12,
- indirectMembers: 24,
- levelOptions: ['全部', '直属下级', '间接下级'],
- currentLevelIndex: 0,
- searchKeyword: '',
- loading: false,
- noMore: false,
- page: 1,
- pageSize: 10,
- teamMembers: [
- {
- id: '1',
- nickname: '小明',
- avatar: '/static/images/avatar/avatar1.png',
- level: '普通会员',
- joinTime: '2023-11-15',
- parentNickname: '系统邀请',
- commission: '256.50'
- },
- {
- id: '2',
- nickname: '小红',
- avatar: '/static/images/avatar/avatar2.png',
- level: '白银会员',
- joinTime: '2023-12-01',
- parentNickname: '小明',
- commission: '356.80'
- },
- {
- id: '3',
- nickname: '小李',
- avatar: '/static/images/avatar/avatar3.png',
- level: '黄金会员',
- joinTime: '2023-12-10',
- parentNickname: '小红',
- commission: '456.20'
- }
- ]
- },
- onLoad() {
- // 可以在这里请求实际的数据
- },
- // 切换会员等级筛选
- onLevelChange(e) {
- const index = e.detail.value
- this.setData({
- currentLevelIndex: index,
- page: 1,
- teamMembers: []
- }, () => {
- this.loadTeamMembers()
- })
- },
- // 搜索团队成员
- onSearchInput(e) {
- const keyword = e.detail.value
- this.setData({
- searchKeyword: keyword,
- page: 1,
- teamMembers: []
- }, () => {
- this.loadTeamMembers()
- })
- },
- // 加载团队成员
- loadTeamMembers(isLoadMore = false) {
- if (this.data.loading) return
- this.setData({ loading: true })
- // 模拟异步加载数据
- setTimeout(() => {
- // 这里可以根据 levelOptions 和 searchKeyword 进行过滤
- const newList = this.data.teamMembers
- this.setData({
- teamMembers: isLoadMore ? [...this.data.teamMembers, ...newList] : newList,
- loading: false,
- noMore: true
- })
- }, 500)
- },
- // 加载更多
- loadMore() {
- if (this.data.noMore) return
- this.setData({
- page: this.data.page + 1
- }, () => {
- this.loadTeamMembers(true)
- })
- }
- })
|