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 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. this.getPublicityList(this.data.searchParams);
  22. },
  23. getPublicityList(val) {
  24. let self = this;
  25. reqInterface.GetConsumerinfopublicList(val).then(res => {
  26. if (!res.records || res.records.length == 0) {
  27. wx.showToast({
  28. title: '没有更多数据',
  29. icon: 'none'
  30. })
  31. }
  32. self.setData({
  33. publicityList: res.records ? self.data.publicityList.concat(res.records) : self.data.publicityList.concat([]),
  34. isRefreshing: false
  35. })
  36. }).catch(err => {
  37. self.setData({
  38. isRefreshing: false
  39. })
  40. })
  41. },
  42. // 加载更多
  43. onLoadMore() {
  44. let self = this;
  45. let page = self.data.searchParams.current + 1; //获取当前页数并+1
  46. self.setData({
  47. 'searchParams.current': page, //更新当前页数
  48. })
  49. self.getPublicityList(self.data.searchParams); //重新调用请求获取下一页数据
  50. },
  51. toDetail(e) {
  52. toLink('/pages/home/publicity/detail/index', {
  53. id: e.currentTarget.dataset.id
  54. })
  55. },
  56. // 下拉刷新
  57. onRefresherPulling(e) {
  58. this.setData({
  59. isRefreshing: true
  60. });
  61. },
  62. onRefresherRefresh(e) {
  63. this.getRefresh()
  64. },
  65. getRefresh() {
  66. let self = this;
  67. self.setData({
  68. publicityList: [],
  69. 'searchParams.current': 1, //更新当前页数
  70. 'searchParams.size': 9, //更新当前页数
  71. })
  72. self.getPublicityList(this.data.searchParams);
  73. },
  74. })