inviteUserDetail.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. const util = require('../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. type: 0,
  6. id: '',
  7. roleType:'',
  8. tabIndex:0,
  9. queryData: {
  10. pageIndex: 1,
  11. pageSize: 10,
  12. },
  13. info:{},
  14. list:[],
  15. total: 0,
  16. loadMore: true
  17. },
  18. onLoad(options) {
  19. this.setData({type: options.type, id: options.id, roleType: options.roleType, tabIndex:options.type == 1 ? 0 : 1})
  20. this.getList(false);
  21. this.info();
  22. },
  23. setTabbar(e){
  24. let index = e.currentTarget.dataset.index;
  25. this.data.queryData.pageIndex = 1;
  26. this.setData({ tabIndex: index, queryData: this.data.queryData, list: [] });
  27. this.getList(true);
  28. },
  29. info() {
  30. let that = this;
  31. util.ajax({
  32. func: `v2/${this.data.roleType}/invitee/info`,
  33. data: {id:that.data.id},
  34. load: false
  35. }, res => {
  36. if (res.code == 0) {
  37. that.setData({ info: res.data });
  38. }
  39. });
  40. },
  41. getList(load){
  42. let that = this, url = '';
  43. if(this.data.type == 1 && this.data.tabIndex == 0){
  44. url = `v2/${this.data.roleType}/indirectMember/list`;
  45. }else if(this.data.tabIndex == 1){
  46. url = 'v2/user/coin/list';
  47. }else if(this.data.tabIndex == 2){
  48. url = 'v2/user/coin/transition/list';
  49. }
  50. util.ajax({
  51. func:url,
  52. data:{pageSize:that.data.queryData.pageSize,pageIndex:that.data.queryData.pageIndex, id: that.data.id, level:(that.data.type*1+1),transitionType:0},
  53. load: load
  54. },function(res){
  55. if (res.code == 0) {
  56. let loadMore = true, newData = res.data.list || [], oldData = !load ? newData : [...that.data.list, ...newData];
  57. if (newData.length < that.data.queryData.pageSize && oldData.length > that.data.queryData.pageSize) loadMore = false;
  58. that.setData({ list: oldData, loadMore, total: res.data.total });
  59. } else
  60. util.showTips(res.reason);
  61. });
  62. },
  63. binderror(e) {
  64. var list = this.data.list, index = e.currentTarget.dataset.index;
  65. list[index].avatar = '/images/default_logo.jpg'
  66. this.setData({ list });
  67. },
  68. onPullDownRefresh() {
  69. var self = this;
  70. wx.showNavigationBarLoading();
  71. setTimeout(function () {
  72. self.data.queryData.pageIndex = 1;
  73. self.setData({ queryData: self.data.queryData });
  74. self.getList(false);
  75. wx.hideNavigationBarLoading();
  76. wx.stopPullDownRefresh();
  77. }, 1000);
  78. },
  79. onReachBottom() {
  80. var self = this;
  81. if (self.data.loadMore == false || self.data.total <= self.data.queryData.pageSize) return false;
  82. setTimeout(function () {
  83. self.data.queryData.pageIndex = self.data.queryData.pageIndex + 1;
  84. self.setData({ queryData: self.data.queryData });
  85. self.getList(true);
  86. }, 1000);
  87. },
  88. })