123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- const reqInterface = require("../../../../api/models");
- import {
- toLink
- } from '../../../../utils/nav';
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- isRefreshing: false,
- publicityList: [],
- searchParams: {
- current: 1,
- size: 9
- },
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onShow(options) {
- let self = this;
- self.setData({
- publicityList: []
- })
- this.getPublicityList(this.data.searchParams);
- },
- getPublicityList(val) {
- let self = this;
- reqInterface.GetConsumerinfopublicList(val).then(res => {
- if (!res.records || res.records.length == 0) {
- wx.showToast({
- title: '没有更多数据',
- icon: 'none'
- })
- }
- self.setData({
- publicityList: res.records ? self.data.publicityList.concat(res.records) : self.data.publicityList.concat([]),
- isRefreshing: false
- })
- }).catch(err => {
- self.setData({
- isRefreshing: false
- })
- })
- },
- // 加载更多
- onLoadMore() {
- let self = this;
- let page = self.data.searchParams.current + 1; //获取当前页数并+1
- self.setData({
- 'searchParams.current': page, //更新当前页数
- })
- self.getPublicityList(self.data.searchParams); //重新调用请求获取下一页数据
- },
-
- toDetail(e) {
- toLink('/pages/home/publicity/detail/index', {
- id: e.currentTarget.dataset.id
- })
- },
-
- // 下拉刷新
- onRefresherPulling(e) {
- this.setData({
- isRefreshing: true
- });
- },
-
- onRefresherRefresh(e) {
- this.getRefresh()
- },
-
- getRefresh() {
- let self = this;
- self.setData({
- publicityList: [],
- 'searchParams.current': 1, //更新当前页数
- 'searchParams.size': 9, //更新当前页数
- })
- self.getPublicityList(this.data.searchParams);
- },
- })
|