inviteUser.js 2.1 KB

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