income.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. var app = getApp();
  2. var status = require('../../utils/index.js');
  3. Page({
  4. mixins: [require('../../mixin/globalMixin.js')],
  5. data: {
  6. currentTab: 0,
  7. pageSize: 10,
  8. navList: [{
  9. name: "全部",
  10. status: "-1"
  11. }, {
  12. name: "待结算",
  13. status: "0"
  14. }, {
  15. name: "已结算",
  16. status: "1"
  17. }, {
  18. name: "已失效",
  19. status: "2"
  20. }
  21. ],
  22. list: [],
  23. loadText: "加载中...",
  24. info: {},
  25. noData: 0,
  26. loadMore: true,
  27. stateArr: ["待结算", "已结算", "已失效"]
  28. },
  29. page: 1,
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. status.setNavBgColor();
  35. this.getInfo();
  36. this.getData();
  37. },
  38. getInfo: function () {
  39. wx.showLoading();
  40. var token = wx.getStorageSync('token');
  41. let that = this;
  42. app.util.request({
  43. url: 'entry/wxapp/user',
  44. data: {
  45. controller: 'groupdo.get_pincommiss_account_info',
  46. token: token
  47. },
  48. dataType: 'json',
  49. success: function (res) {
  50. wx.hideLoading();
  51. if (res.data.code == 0) {
  52. that.setData({ info: res.data.data })
  53. } else {
  54. wx.showModal({
  55. title: '提示',
  56. content: res.data.msg || '获取失败',
  57. showCancel: false,
  58. success(res) {
  59. if (res.confirm) {
  60. console.log('用户点击确定')
  61. wx.reLaunch({
  62. url: '/lionfish_comshop/pages/user/me',
  63. })
  64. }
  65. }
  66. })
  67. }
  68. }
  69. })
  70. },
  71. getData: function () {
  72. let that = this;
  73. let token = wx.getStorageSync('token');
  74. let currentTab = this.data.currentTab;
  75. let state = this.data.navList[currentTab].status;
  76. wx.showLoading();
  77. app.util.request({
  78. 'url': 'entry/wxapp/index',
  79. 'data': {
  80. controller: 'groupdo.listorder_list',
  81. token: token,
  82. state: state,
  83. page: this.page
  84. },
  85. dataType: 'json',
  86. success: function (res) {
  87. if (res.data.code == 0) {
  88. let h = {};
  89. let list = res.data.data;
  90. if (list.length < 6) h.noMore = true;
  91. let oldList = that.data.list;
  92. list = oldList.concat(list);
  93. that.page++;
  94. that.setData({ list, ...h })
  95. } else {
  96. // 无数据
  97. if (that.page == 1) that.setData({ noData: 1 })
  98. that.setData({ loadMore: false, noMore: false, loadText: "没有更多记录了~" })
  99. }
  100. wx.hideLoading();
  101. }
  102. })
  103. },
  104. getCurrentList: function () {
  105. if (!this.data.loadMore) return false;
  106. this.getData();
  107. this.setData({
  108. isHideLoadMore: false
  109. })
  110. },
  111. onReachBottom: function(){
  112. this.getCurrentList();
  113. },
  114. bindChange: function () {
  115. this.page = 1;
  116. this.setData({
  117. list: [],
  118. noData: 0,
  119. loadMore: true,
  120. loadText: "加载中...",
  121. }, () => {
  122. console.log('我变啦');
  123. this.getData();
  124. });
  125. },
  126. /**
  127. * 切换导航
  128. */
  129. switchNav: function (e) {
  130. let that = this;
  131. if (this.data.currentTab === 1 * e.target.dataset.current) return false;
  132. this.setData({
  133. currentTab: 1 * e.target.dataset.current
  134. }, ()=>{
  135. that.bindChange()
  136. });
  137. }
  138. })