willAccount.js 2.4 KB

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