// pages/myProfit/myProfit.js Page({ /** * 页面的初始数据 */ data: { profitCount : '', //收益数据-人数 profitFinance : '', //收益数据-收益信息 profitUser : '', //收益数据-用户信息 incometCount : '', //收益统计-团队 incometFfinance : '', //收益统计-收益 incometOrder : '', //收益统计-订单 incometMonths : '', //收益数据-月份列表 monthsIndex : 1, //账变记录筛选index monthsValue : '', //账变记录筛选value changeStyle : 'report', //tab默认选择类型 //收益订单筛选列表 ordersWay : [ {value: '0', name: "充值", type: 'recharge'}, {value: '1', name: "产品", type: 'product'} ], ordersIndex : 0, //收益订单筛选列表index ordersValue : 'recharge', //收益订单筛选列表value publicData : [], //订单与团队 公共数据列表 //我的团队筛选列表 teamWay : [ {value: 0, name: "用户"}, {value: 1, name: "达人"} ], teamIndex : 0, //我的团队筛选列表index teamValue : 0, //我的团队筛选列表value teamSort : 'asc', //我的团队排序 page : {}, //下一页 lodingStats : false, //加载状态 }, /** * 生命周期函数--监听页面加载 */ onLoad (options) { // }) }, /** * 生命周期函数--监听页面显示 */ onShow () { // 获取我的收益数据 this.profitInfo(); // 获取本月收益统计 this.incomeInfo(); }, /** * tab栏选择 */ changeTabbar(e) { this.setData({ changeStyle: e.currentTarget.dataset.style }) if(e.currentTarget.dataset.style == 'report'){ // 获取收益统计 this.incomeInfo(); return } // 获取收益订单列表 + 我的团队列表 this.publicInfo(); }, /** * 我的收益数据 */ profitInfo() { wx.$api.user.myProfit().then(res=>{ this.setData({ profitCount : res.data.count, profitFinance: res.data.finance, profitUser : res.data.user }) }).catch(err=>{}) }, /** * 收益统计 */ incomeInfo() { wx.$api.user.myIncome(this.data.monthsValue).then(res=>{ this.setData({ incometCount : res.data.count, incometFfinance: res.data.finance, incometOrder : res.data.order, incometMonths : res.data.months, monthsIndex : parseInt(res.data.this_month) - 1 }) }).catch(err=>{}) }, /** * 收益订单列表 + 我的团队列表 */ publicInfo(page) { let newStyle = this.data.changeStyle let url = '' if(newStyle == 'order') url = wx.$api.user.profitOrders(this.data.ordersValue, page) if(newStyle == 'team') url = wx.$api.user.profitTeam(this.data.teamValue, this.data.teamSort, page) url.then(res=>{ let listArr = this.data.publicData, newData = [] if(page == 1 || page == undefined) listArr = [] newData = listArr.concat(res.data.data) this.setData({ publicData : newData, page : res.data.page, lodingStats : false }) wx.stopPullDownRefresh() }).catch(err=>{}) }, /** * 月份选择 */ screenBind(val) { let newValue = parseInt(val.detail.value) this.setData({ monthsValue : newValue + 1, monthsIndex : val.detail.value }) // 获取收益统计 this.incomeInfo(); }, /** * 订单类型选择 */ screenOrders(val) { this.setData({ ordersIndex: val.detail.value, ordersValue: this.data.ordersWay[val.detail.value].type }) // 获取收益订单列表 + 我的团队列表 this.publicInfo(); }, /** * 团队类型选择 */ screenTeam(val) { this.setData({ teamIndex: val.detail.value, teamValue: this.data.ordersWay[val.detail.value].value }) // 获取收益订单列表 + 我的团队列表 this.publicInfo(); }, /** * 销量排序 */ teamTap () { if (this.data.teamSort == 'asc') { this.setData({ teamSort : 'desc', }) } else { this.setData({ teamSort : 'asc', }) } // 获取收益订单列表 + 我的团队列表 this.publicInfo(); }, /** * 上拉加载 */ onReachBottom(){ this.setData({ lodingStats: true }) let pageNumber = this.data.page.current if(this.data.page.has_more){ pageNumber++ this.publicInfo(pageNumber) } } })