monetaryDetail.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const util = require('../../../utils/util.js');
  2. Page({
  3. data: {
  4. activeTab:1,
  5. viewDate:{
  6. year:util.getNowFormatDate('yyyy'),
  7. month:util.getNowFormatDate('MM')
  8. },
  9. dateList:[],
  10. pageIndex:1,
  11. noMore:false
  12. },
  13. onLoad: function (options) {
  14. let nowDate=util.getNowFormatDate('yyyy-MM')
  15. this.getList()
  16. },
  17. onShow: function () {
  18. },
  19. // 页面上拉触底事件的处理函数
  20. onReachBottom: function () {
  21. this.getList(true)
  22. },
  23. getList(type){
  24. let that=this,data={};
  25. data.addType=that.data.activeTab;
  26. data.pageIndex=that.data.pageIndex;
  27. data.pageSize=15;
  28. data.crtYear=this.data.viewDate.year;
  29. data.crtMonth=this.data.viewDate.month;
  30. util.ajax({
  31. func: "v2/user/userCoin/list",
  32. method:'post',
  33. data: data,
  34. load:false
  35. }, function (res) {
  36. if (res.code==0) {
  37. res.data.list.forEach(el => {
  38. el.date_time=util.formatDate(el.crtTime,'',false);
  39. });
  40. that.setData({dateList:type?[...that.data.dateList,...res.data.list]:res.data.list,noMore:res.data.list.length<data.pageSize?true:false,pageIndex:that.data.pageIndex+1})
  41. }else{
  42. util.showTips(res.reason)
  43. }
  44. })
  45. },
  46. bindDateChange(e){
  47. console.log(e)
  48. let date ={
  49. year:e.detail.value.split('-')[0],
  50. month:e.detail.value.split('-')[1]
  51. }
  52. this.setData({viewDate:date,pageIndex:1})
  53. this.getList()
  54. },
  55. selectTab(e){
  56. console.log(e)
  57. let i=e.currentTarget.dataset.index;
  58. if (this.data.activeTab!=i) {
  59. this.setData({activeTab:i,pageIndex:1})
  60. this.getList()
  61. }
  62. }
  63. })