index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. const utils = require('../../utils/util')
  2. const app = getApp();
  3. Page({
  4. data: {
  5. currentTab: 0,
  6. bgColor: "linear-gradient(90deg, rgb(255, 118, 38), rgb(252, 30, 82))",
  7. navbar: [{
  8. name: "收入"
  9. }, {
  10. name: "支出"
  11. }],
  12. isPickerRender: false,
  13. isPickerShow: false,
  14. pickerConfig: {
  15. endDate: true,
  16. dateLimit: true,
  17. initStartTime: "2020-01-01",
  18. initEndTime: "2020-12-01",
  19. limitStartTime: "2015-01-01",
  20. limitEndTime: "2095-01-01"
  21. },
  22. searchParams: {
  23. startTime: "2019-01-01 ",
  24. endTime: "2019-12-01",
  25. pageNo: 1,
  26. pageSize: 10,
  27. createTime_begin:"",
  28. createTime_end:"",
  29. tradingStatus:1
  30. },
  31. dataStr: '',
  32. totalAmount:0,
  33. loadding: false,
  34. pullUpOn: true,
  35. list:[],
  36. },
  37. /**
  38. * 页面相关事件处理函数--监听用户下拉动作
  39. */
  40. onPullDownRefresh: function () {
  41. this.setData({
  42. ["searchParams.pageNo"]: 1,
  43. pullUpOn: true,
  44. loadding: false,
  45. list: []
  46. })
  47. this.getList()
  48. setTimeout(() => {
  49. wx.stopPullDownRefresh()
  50. }, 300);
  51. },
  52. /**
  53. * 页面上拉触底事件的处理函数
  54. */
  55. onReachBottom: function () {
  56. let that = this;
  57. //只是测试效果,逻辑以实际数据为准
  58. this.setData({
  59. loadding: true,
  60. pullUpOn: true
  61. })
  62. this.setData({
  63. ["searchParams.pageNo"]: that.data.searchParams.pageNo + 1
  64. })
  65. this.getList()
  66. },
  67. onLoad: function (options) {
  68. this.getList();
  69. },
  70. onReady: function (options) {
  71. },
  72. changeTab(e) {
  73. console.log(e)
  74. this.setData({
  75. currentTab: e.detail.index,
  76. list:[]
  77. })
  78. if(e.detail.index==0){//收入列表
  79. this.setData({
  80. ["searchParams.tradingStatus"]:1
  81. })
  82. }else if(e.detail.index==1){//支出列表
  83. this.setData({
  84. ["searchParams.tradingStatus"]:0
  85. })
  86. }
  87. this.getList();
  88. },
  89. timePickerShow: function () {
  90. this.setData({
  91. isPickerShow: true,
  92. isPickerRender: true,
  93. chartHide: true
  94. });
  95. },
  96. pickerHide: function () {
  97. this.setData({
  98. isPickerShow: false,
  99. chartHide: false
  100. });
  101. },
  102. setPickerTime: function (val) {
  103. let data = val.detail;
  104. let startTime = utils.formatDate(data.startTime,'yyyy-MM-dd')
  105. let endTime = utils.formatDate(data.endTime,'yyyy-MM-dd')
  106. this.setData({
  107. ["searchParams.startTime"]: data.startTime,
  108. ["searchParams.endTime"]: data.endTime,
  109. dataStr: startTime +" ~ "+ endTime,
  110. ["searchParams.createTime_begin"]: data.startTime,
  111. ["searchParams.createTime_end"]: data.endTime,
  112. list:[]
  113. });
  114. this.getList();
  115. },
  116. getList() {
  117. var that = this
  118. utils.request(utils.api.mgVmBillList, that.data.searchParams, "GET", true, false, app.globalData.token).then((res) => {
  119. if (res.code == 200) {
  120. that.setData({
  121. totalAmount: res.result.allMoney,
  122. })
  123. if (res.result.list.records.length > 0) {
  124. if (that.data.searchParams.pageNo > 0) {
  125. let list = that.data.list
  126. res.result.list.records.forEach((e)=>{
  127. list.push(e)
  128. })
  129. that.setData({
  130. list: list
  131. })
  132. }else{
  133. that.setData({
  134. list: res.result.list.records
  135. })
  136. }
  137. } else {
  138. that.setData({
  139. loadding: false,
  140. pullUpOn: false,
  141. ["searchParams.pageNo"]:that.data.searchParams.pageNo-1
  142. })
  143. }
  144. }
  145. }).catch((res) => {})
  146. },
  147. })