| | |
| | | // pages/dxal/dxal.js |
| | | import { |
| | | $startWuxRefresher, |
| | | $stopWuxRefresher, |
| | | $stopWuxLoader |
| | | } from '../../templeteDist/wuxDist/index'; |
| | | |
| | | var app = getApp(); |
| | | |
| | |
| | | dongtai3_1: app.globalData.imgUrl + '/image/dongtai3-1.jpg', |
| | | inputShowed: false, |
| | | inputVal: "", |
| | | |
| | | page:1, |
| | | content: '------加载中------', |
| | | items: [], |
| | | count: 0, |
| | | scrollTop: 0, |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad: function(options) { |
| | | $startWuxRefresher(); |
| | | var that = this; |
| | | wx.showLoading(); |
| | | wx.request({ |
| | | url: app.globalData.url + '/api/article/publicMsgQuery', |
| | | data: { |
| | | page: that.data.page, |
| | | size: 10, |
| | | flag: '典型案例', |
| | | }, |
| | | onPageScroll(e) { |
| | | this.setData({ |
| | | scrollTop: e.scrollTop |
| | | success: function(res) { |
| | | wx.hideLoading(); |
| | | console.log('res', res); |
| | | if (res.data.code == 0) { |
| | | let content = res.data.data.result.content.map(({ |
| | | createTime, |
| | | ...i |
| | | }) => ({ |
| | | ...i, |
| | | createTime: app.formatDate(createTime), |
| | | })); |
| | | console.log(content) |
| | | if (content.length < 10) { |
| | | that.setData({ |
| | | items: [...that.data.items, ...content], |
| | | hasMoreData: false, |
| | | content: '------我是有底线的------' |
| | | }) |
| | | }, |
| | | onRefresh() { |
| | | console.log('onRefresh') |
| | | |
| | | this.setData({ |
| | | count: 10 |
| | | }) |
| | | |
| | | setTimeout(() => { |
| | | this.setData({ |
| | | items: this.getList() |
| | | }) |
| | | $stopWuxRefresher() |
| | | }, 1000) |
| | | }, |
| | | onLoadmore() { |
| | | console.log('onLoadmore') |
| | | setTimeout(() => { |
| | | this.setData({ |
| | | items: [...this.data.items, ...this.getList(10, this.data.count)], |
| | | count: this.data.count + 10, |
| | | }) |
| | | |
| | | if (this.data.items.length < 30) { |
| | | $stopWuxLoader() |
| | | } else { |
| | | console.log('没有更多数据') |
| | | $stopWuxLoader('#wux-refresher', this, true) |
| | | that.setData({ |
| | | items: [...that.data.items, ...content], |
| | | hasMoreData: true, |
| | | content: '------加载更多------', |
| | | page: that.data.page + 1 |
| | | }) |
| | | } |
| | | }, 1000) |
| | | } else { |
| | | wx.showToast({ |
| | | title: res.data.msg, |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | |
| | | |
| | | |
| | | getList: (count = 10, step = 0) => [...new Array(count)].map((n, i) => ({ |
| | | title: `Pull down ${i + step}`, |
| | | content: 'Wux Weapp' |