index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // pages/commission-details/index.js
  2. import { spreadCommission, spreadCount} from '../../api/user.js';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. parameter: {
  9. 'navbar': '1',
  10. 'return': '1',
  11. 'title': '佣金记录',
  12. 'color': true,
  13. 'class': '0'
  14. },
  15. name:'',
  16. type:0,
  17. page:0,
  18. limit:8,
  19. recordList:[],
  20. recordType:0,
  21. recordCount:0,
  22. status:false,
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. this.setData({ type: options.type });
  29. },
  30. /**
  31. * 生命周期函数--监听页面初次渲染完成
  32. */
  33. onReady: function () {
  34. },
  35. /**
  36. * 生命周期函数--监听页面显示
  37. */
  38. onShow: function () {
  39. var type = this.data.type;
  40. if (type == 1) {
  41. this.setData({ 'parameter.title': '提现记录', name: '提现总额', recordType: 4 });
  42. } else if (type == 2) {
  43. this.setData({ 'parameter.title': '佣金记录', name: '佣金记录', recordType: 3 });
  44. } else {
  45. wx.showToast({
  46. title: '参数错误',
  47. icon: 'none',
  48. duration: 1000,
  49. mask: true,
  50. success: function (res) { setTimeout(function () { wx.navigateBack({ delta: 1, }) }, 1200) },
  51. });
  52. }
  53. this.getRecordList();
  54. this.getRecordListCount();
  55. },
  56. /**
  57. * 获取余额使用记录
  58. */
  59. getRecordList: function () {
  60. var that = this;
  61. var page = that.data.page;
  62. var limit = that.data.limit;
  63. var status = that.data.status;
  64. var recordType = that.data.recordType;
  65. var recordList = that.data.recordList;
  66. var recordListNew = [];
  67. if (status == true) return ;
  68. spreadCommission(recordType,{page:page,limit:limit}).then(res=>{
  69. var len = res.data.length;
  70. var recordListData = res.data;
  71. recordListNew = recordList.concat(recordListData);
  72. that.setData({ status: limit > len, page: limit + page, recordList: recordListNew });
  73. });
  74. },
  75. getRecordListCount:function(){
  76. var that = this;
  77. spreadCount(that.data.recordType).then(res=>{
  78. that.setData({ recordCount: res.data.count });
  79. });
  80. },
  81. /**
  82. * 生命周期函数--监听页面隐藏
  83. */
  84. onHide: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面卸载
  88. */
  89. onUnload: function () {
  90. },
  91. /**
  92. * 页面相关事件处理函数--监听用户下拉动作
  93. */
  94. onPullDownRefresh: function () {
  95. },
  96. /**
  97. * 页面上拉触底事件的处理函数
  98. */
  99. onReachBottom: function () {
  100. this.getRecordList();
  101. },
  102. /**
  103. * 用户点击右上角分享
  104. */
  105. onShareAppMessage: function () {
  106. }
  107. })