You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.8KB

1 yıl önce
1 yıl önce
1 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const reqInterface = require("../../../../api/models");
  2. import {
  3. toLink
  4. } from '../../../../utils/nav';
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isRefreshing: false,
  11. publicityList: [],
  12. searchParams: {
  13. current: 1,
  14. size: 9
  15. },
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onShow(options) {
  21. let self = this;
  22. self.setData({
  23. publicityList: []
  24. })
  25. this.getPublicityList(this.data.searchParams);
  26. },
  27. getPublicityList(val) {
  28. let self = this;
  29. reqInterface.GetConsumerinfopublicList(val).then(res => {
  30. if (!res.records || res.records.length == 0) {
  31. wx.showToast({
  32. title: '没有更多数据',
  33. icon: 'none'
  34. })
  35. }
  36. self.setData({
  37. publicityList: res.records ? self.data.publicityList.concat(res.records) : self.data.publicityList.concat([]),
  38. isRefreshing: false
  39. })
  40. }).catch(err => {
  41. self.setData({
  42. isRefreshing: false
  43. })
  44. })
  45. },
  46. // 加载更多
  47. onLoadMore() {
  48. let self = this;
  49. let page = self.data.searchParams.current + 1; //获取当前页数并+1
  50. self.setData({
  51. 'searchParams.current': page, //更新当前页数
  52. })
  53. self.getPublicityList(self.data.searchParams); //重新调用请求获取下一页数据
  54. },
  55. toDetail(e) {
  56. toLink('/pages/home/publicity/detail/index', {
  57. id: e.currentTarget.dataset.id
  58. })
  59. },
  60. // 下拉刷新
  61. onRefresherPulling(e) {
  62. this.setData({
  63. isRefreshing: true
  64. });
  65. },
  66. onRefresherRefresh(e) {
  67. this.getRefresh()
  68. },
  69. getRefresh() {
  70. let self = this;
  71. self.setData({
  72. publicityList: [],
  73. 'searchParams.current': 1, //更新当前页数
  74. 'searchParams.size': 9, //更新当前页数
  75. })
  76. self.getPublicityList(this.data.searchParams);
  77. },
  78. })