Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

index.js 2.9KB

před 1 rokem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. const reqInterface = require("../../../api/models");
  2. import {
  3. toLink
  4. } from '../../../utils/nav';
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. tabs: [{
  11. title: '全部',
  12. icon: '/icons/all.png'
  13. }, {
  14. title: '待审核',
  15. icon: '/icons/daishenhe.png'
  16. }, {
  17. title: '已审核',
  18. icon: '/icons/yishenhe.png'
  19. }, {
  20. title: '已公示',
  21. icon: '/icons/yigongshi.png'
  22. }, {
  23. title: '已发放',
  24. icon: '/icons/yifafang.png'
  25. }],
  26. applyForList: [],
  27. active: 0,
  28. isRefreshing: false,
  29. searchParams: {
  30. current: 1,
  31. size: 9,
  32. status: '',
  33. },
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad(options) {
  39. },
  40. /**
  41. * 生命周期函数--监听页面初次渲染完成
  42. */
  43. onReady() {
  44. },
  45. /**
  46. * 生命周期函数--监听页面显示
  47. */
  48. onShow() {
  49. let self = this;
  50. self.getApplyForList(self.data.searchParams);
  51. },
  52. getApplyForList(val) {
  53. let self = this;
  54. reqInterface.GetConsumerinfoDetail(val).then(res => {
  55. if (!res.records || res.records.length == 0) {
  56. wx.showToast({
  57. title: '没有更多数据',
  58. icon: 'none'
  59. })
  60. }
  61. self.setData({
  62. applyForList: res.records ? self.data.applyForList.concat(res.records) : self.data.applyForList.concat([]),
  63. isRefreshing: false
  64. })
  65. }).catch(err => {
  66. self.setData({
  67. isRefreshing: false
  68. })
  69. })
  70. },
  71. changeTab(e) {
  72. let self = this;
  73. if (e.currentTarget.dataset.idx == 0) {
  74. self.setData({
  75. applyForList: [],
  76. searchParams: {
  77. current: 1,
  78. size: 9,
  79. status: '',
  80. },
  81. active: e.currentTarget.dataset.idx
  82. })
  83. } else {
  84. self.setData({
  85. searchParams: {
  86. current: 1,
  87. size: 9,
  88. status: e.currentTarget.dataset.idx,
  89. },
  90. applyForList: [],
  91. active: e.currentTarget.dataset.idx
  92. })
  93. }
  94. self.getApplyForList(self.data.searchParams)
  95. },
  96. toApplyFor(e) {
  97. toLink('/pages/info/index/index', {
  98. id: e.currentTarget.dataset.id
  99. })
  100. },
  101. // 加载更多
  102. onLoadMore() {
  103. let self = this;
  104. let page = self.data.searchParams.current + 1; //获取当前页数并+1
  105. self.setData({
  106. 'searchParams.current': page, //更新当前页数
  107. })
  108. self.getApplyForList(self.data.searchParams); //重新调用请求获取下一页数据
  109. },
  110. // 下拉刷新
  111. onRefresherPulling(e) {
  112. this.setData({
  113. isRefreshing: true
  114. });
  115. },
  116. onRefresherRefresh(e) {
  117. this.getRefresh()
  118. },
  119. getRefresh() {
  120. let self = this;
  121. self.setData({
  122. applyForList: [],
  123. searchParams: {
  124. current: 1,
  125. status: self.data.searchParams.status,
  126. size: 9
  127. },
  128. active: self.data.active
  129. })
  130. self.getApplyForList(this.data.searchParams);
  131. },
  132. })