forked from nsjcy/frontEnd/nsjcy

liuwh
2020-05-09 62a240df3ff2f1bcddea834ccb15fccefc51ae26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// 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: ""
    }, () => {});
  },
})