index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. const utils = require('../../utils/util')
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. isPickerRender: false,
  9. isPickerShow: false,
  10. pickerConfig: {
  11. endDate: true,
  12. dateLimit: true,
  13. initStartTime: "2020-01-01",
  14. initEndTime: "2020-12-01",
  15. limitStartTime: "2015-01-01",
  16. limitEndTime: "2095-01-01",
  17. },
  18. searchParams: {
  19. startTime: "2019-01-01 ",
  20. endTime: "2019-12-01",
  21. pageNo: 1,
  22. pageSize: 10,
  23. createTime_begin:"",
  24. createTime_end:"",
  25. tradingStatus:0,
  26. storeName:""
  27. },
  28. dataStr: '',
  29. totalAmount:0,
  30. loadding: false,
  31. pullUpOn: true,
  32. list:[],
  33. },
  34. /**
  35. * 页面相关事件处理函数--监听用户下拉动作
  36. */
  37. onPullDownRefresh: function () {
  38. this.setData({
  39. ["searchParams.pageNo"]: 1,
  40. pullUpOn: true,
  41. loadding: false,
  42. list: []
  43. })
  44. this.getList()
  45. setTimeout(() => {
  46. wx.stopPullDownRefresh()
  47. }, 300);
  48. },
  49. /**
  50. * 页面上拉触底事件的处理函数
  51. */
  52. onReachBottom: function () {
  53. //只是测试效果,逻辑以实际数据为准
  54. let that = this;
  55. this.setData({
  56. loadding: true,
  57. pullUpOn: true
  58. })
  59. this.setData({
  60. ["searchParams.pageNo"]: that.data.searchParams.pageNo + 1
  61. })
  62. this.getList()
  63. },
  64. /**
  65. * 生命周期函数--监听页面加载
  66. */
  67. onLoad: function (options) {
  68. this.getList();
  69. },
  70. /**
  71. * 生命周期函数--监听页面初次渲染完成
  72. */
  73. onReady: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面显示
  77. */
  78. onShow: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面隐藏
  82. */
  83. onHide: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面卸载
  87. */
  88. onUnload: function () {
  89. },
  90. /**
  91. * 用户点击右上角分享
  92. */
  93. onShareAppMessage: function () {
  94. },
  95. timePickerShow: function () {
  96. this.setData({
  97. isPickerShow: true,
  98. isPickerRender: true,
  99. chartHide: true
  100. });
  101. },
  102. pickerHide: function () {
  103. this.setData({
  104. isPickerShow: false,
  105. chartHide: false
  106. });
  107. },
  108. setPickerTime: function (val) {
  109. let data = val.detail;
  110. let startTime = utils.formatDate(data.startTime,'yyyy-MM-dd')
  111. let endTime = utils.formatDate(data.endTime,'yyyy-MM-dd')
  112. this.setData({
  113. ["searchParams.startTime"]: data.startTime,
  114. ["searchParams.endTime"]: data.endTime,
  115. dataStr: startTime +" ~ "+ endTime,
  116. ["searchParams.createTime_begin"]: data.startTime,
  117. ["searchParams.createTime_end"]: data.endTime,
  118. list:[]
  119. });
  120. this.getList();
  121. },
  122. getList() {
  123. var that = this
  124. utils.request(utils.api.withdrawList, that.data.searchParams, "GET", true, false, app.globalData.token).then((res) => {
  125. if (res.code == 200) {
  126. console.log(res)
  127. if (res.result.records.length > 0) {
  128. if (that.data.searchParams.pageNo > 0) {
  129. let list = that.data.list
  130. res.result.records.forEach((e)=>{
  131. list.push(e)
  132. })
  133. that.setData({
  134. list: list
  135. })
  136. }else{
  137. that.setData({
  138. list: res.result.records
  139. })
  140. }
  141. } else {
  142. that.setData({
  143. loadding: false,
  144. pullUpOn: false,
  145. ["searchParams.pageNo"]:that.data.searchParams.pageNo-1
  146. })
  147. }
  148. var allList = that.data.list;
  149. var allNumber = 0;
  150. for (let i = 0; i < allList.length; i++) {
  151. allNumber+=allList[i].number==null?0:allList[i].number;
  152. }
  153. that.setData({
  154. totalAmount: allNumber.toFixed(2),
  155. })
  156. }
  157. }).catch((res) => {})
  158. },
  159. })