123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- var that;
- var Util = require('../../utils/util.js');
- Page({
- data: {
- urlHttp : '',
- tabId: 0,
- year : '',
- month : '',
- recordList: {},
- searchPageNum: 0,
- callbackcount: 10,
- searchLoading: false,
- searchLoadingComplete: false,
- scrollTrue: false,
- },
- onLoad: function (options) {
- var that = this;
- var host = getApp().globalData.servsers;
- that.setData({
- urlHttp: host,
- year: options.year,
- month: options.month,
- tabId: options.tabId
- })
- },
- onShow: function () {
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- var openid = getApp().globalData.openid;
- var userRole = getApp().globalData.userRole;
- var tabId = that.data.tabId;
- if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)) {
- wx.navigateTo({
- url: '/pages/authorize/authorize?link=partnerBusinessRecord',
- })
- } else {
- if (tabId == 0) {
-
- that.recordPerson();
- wx.setNavigationBarTitle({
- title: '邀请客户'
- })
- } else {
-
- that.recordEarnings();
- wx.setNavigationBarTitle({
- title: '收益记录'
- })
- }
- }
- },
-
- tabChange: function (e) {
- var that = this;
- var tabId = e.currentTarget.dataset.id;
- var tabIdOld = that.data.tabId;
- if (tabId == tabIdOld) {
- return false;
- } else {
- that.setData({
- tabId: tabId,
- recordList: {},
- searchPageNum: 0,
- callbackcount: 10,
- searchLoading: false,
- searchLoadingComplete: false,
- scrollTrue: false
- })
- if (tabId == 0) {
-
- that.recordPerson();
- wx.setNavigationBarTitle({
- title: '邀请客户'
- })
- } else {
-
- that.recordEarnings();
- wx.setNavigationBarTitle({
- title: '收益记录'
- })
- }
- }
- },
-
- monthPre:function(e){
- var that = this;
- var month = that.data.month;
- var year = that.data.year;
- var tabId = that.data.tabId;
- if (month >1){
- month --;
- }else{
- month = 12;
- year --;
- }
- that.setData({
- month: month,
- year: year
- })
- if (tabId == 0) {
-
- that.recordPerson();
- wx.setNavigationBarTitle({
- title: '邀请客户'
- })
- }else{
-
- that.recordEarnings();
- wx.setNavigationBarTitle({
- title: '收益记录'
- })
- }
-
- },
-
- monthN: function (e) {
- var that = this;
- var nowMonth = (new Date()).getMonth() + 1;
- var month = that.data.month;
- var year = that.data.year;
- var tabId = that.data.tabId;
- if (month < 12 && month < nowMonth){
- month++;
- } else if (month == 12){
- month = 1;
- year ++;
- }
- that.setData({
- month: month,
- year: year
- })
- if (tabId == 0) {
-
- that.recordPerson();
- wx.setNavigationBarTitle({
- title: '邀请客户'
- })
- } else {
-
- that.recordEarnings();
- wx.setNavigationBarTitle({
- title: '收益记录'
- })
- }
- },
-
- recordPerson: function (e) {
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- var openid = getApp().globalData.openid;
- var userRole = getApp().globalData.userRole;
- var year = that.data.year;
- var month = that.data.month < 10 ? '0' + that.data.month : that.data.month;
- wx.request({
- url: host + "api/distributeSell/getRelationList",
- data: {
- userId: un_id,
- userRole: userRole,
- date: year + '-' + month,
- offset: 0,
- limit: 10
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.data.total == 10) {
- that.setData({
- recordList: res.data.data.rows,
- searchPageNum: 0,
- searchSongList: [],
- isFromSearch: true,
- searchLoading: true,
- searchLoadingComplete: false,
- scrollTrue: true
- })
- } else if (res.data.data.total > 0 && res.data.data.total < 10) {
- that.setData({
- recordList: res.data.data.rows,
- searchPageNum: 0,
- searchSongList: [],
- isFromSearch: true,
- searchLoading: false,
- searchLoadingComplete: false,
- scrollTrue: true
- });
- }else{
- that.setData({
- recordList: '',
- searchPageNum: 0,
- searchSongList: [],
- isFromSearch: true,
- searchLoading: false,
- searchLoadingComplete: false,
- scrollTrue: true
- });
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- },
-
- recordEarnings: function (e) {
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- var openid = getApp().globalData.openid;
- var userRole = getApp().globalData.userRole;
- var year = that.data.year;
- var month = that.data.month < 10 ? '0' + that.data.month : that.data.month;
- wx.request({
- url: host + "api/distributeSell/getEarnList",
- data: {
- userId: un_id,
- userRole: userRole,
- date: year + '-' + month,
- offset: 0,
- limit: 10
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.data.total == 10) {
- that.setData({
- recordList: res.data.data.rows,
- searchPageNum: 0,
- searchSongList: [],
- isFromSearch: true,
- searchLoading: true,
- searchLoadingComplete: false,
- scrollTrue: true
- })
- } else if (res.data.data.total > 0 && res.data.data.total < 10) {
- that.setData({
- recordList: res.data.data.rows,
- searchPageNum: 0,
- searchSongList: [],
- isFromSearch: true,
- searchLoading: false,
- searchLoadingComplete: false,
- scrollTrue: true
- });
- }else{
- that.setData({
- recordList: '',
- searchPageNum: 0,
- searchSongList: [],
- isFromSearch: true,
- searchLoading: false,
- searchLoadingComplete: false,
- scrollTrue: true
- });
- }
- console.log(res.data.data.rows);
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- },
- fetchSearchList: function () {
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- var openid = getApp().globalData.openid;
- var userRole = getApp().globalData.userRole;
- var tabId = that.data.tabId;
- if (tabId == 0) {
-
- wx.request({
- url: host + "api/distributeSell/getRelationList",
- data: {
- userId: un_id,
- userRole: userRole,
- offset: parseInt(that.data.searchPageNum),
- limit: 10
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.data.total > 0) {
- let recordList = [];
-
- that.data.isFromSearch ? recordList = res.data.data.rows : recordList = that.data.recordList.concat(res.data.data.rows)
- that.setData({
- recordList: recordList,
- searchLoading: true,
- scrollTrue: true
- });
- } else {
- that.setData({
- searchLoadingComplete: true,
- searchLoading: false,
- scrollTrue: true
- });
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- } else {
-
- wx.request({
- url: host + "api/distributeSell/getEarnList",
- data: {
- userId: un_id,
- userRole: userRole,
- offset: parseInt(that.data.searchPageNum),
- limit: 10
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.data.total > 0) {
- let recordList = [];
-
- that.data.isFromSearch ? recordList = res.data.data.rows : recordList = that.data.recordList.concat(res.data.data.rows)
- that.setData({
- recordList: recordList,
- searchLoading: true,
- scrollTrue: true
- });
- } else {
- that.setData({
- searchLoadingComplete: true,
- searchLoading: false,
- scrollTrue: true
- });
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- }
- },
-
- searchScrollLower: function () {
- var that = this;
- if (that.data.searchLoading && !that.data.searchLoadingComplete) {
- that.setData({
- searchPageNum: that.data.searchPageNum + 1,
- isFromSearch: false
- });
- that.fetchSearchList();
- }
- },
- })
|