// pages/dxal/dxal.js import { $startWuxRefresher, $stopWuxRefresher, $stopWuxLoader } from '../../templeteDist/wuxDist/index'; var app = getApp(); Page({ /** * 页面的初始数据 */ data: { dongtai1_1: app.globalData.imgUrl + '/image/dongtai1-1.jpg', dongtai2_1: app.globalData.imgUrl + '/image/dongtai2-1.jpg', dongtai3_1: app.globalData.imgUrl + '/image/dongtai3-1.jpg', inputShowed: false, inputVal: "", items: [], count: 0, scrollTop: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { $startWuxRefresher(); }, onPageScroll(e) { this.setData({ scrollTop: e.scrollTop }) }, 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) } }, 1000) }, getList: (count = 10, step = 0) => [...new Array(count)].map((n, i) => ({ title: `Pull down ${i + step}`, content: 'Wux Weapp' })), linkFunction: function(event) { var str = event.currentTarget.dataset['str']; var id = event.currentTarget.dataset['id']; wx.navigateTo({ url: '../' + str + '/' + str + '?id=' + id }) }, showInput: function() { this.setData({ inputShowed: true }); }, hideInput: function() { this.setData({ inputVal: "", inputShowed: false }); }, clearInput: function() { this.setData({ inputVal: "" }, () => {}); }, })