forked from nsjcy/frontEnd/nsjcy

liuwh
2020-03-29 9c7c21e8eacda173feb418bdfe739f7f97358233
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// 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: "",
    value: '知识产权',
    items: [],
    count: 1000,
    scrollTop: 0,
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    $startWuxRefresher();
  },
 
  showList: function () {
    var that = this;
    // wx.showLoading();
    wx.request({
      url: app.globalData.url + '/api/v1/searchLaw/search?page=1&size=' + this.data.count + '&words=' + this.data.value,
      success: function (res) {
        // wx.hideLoading();
        console.log('res.data.data', res.data.data.data)
        console.log('res', res)
        if (res.data.code == 0) {
          that.setData({
            items: [...res.data.data.data]
          })
          $stopWuxRefresher()
          $stopWuxLoader('#wux-refresher', this, true)
        } else {
          wx.showToast({
            title: res.data.msg,
          })
        }
      }
    })
  },
  onPageScroll(e) {
    this.setData({
      scrollTop: e.scrollTop
    })
  },
  onRefresh() {
    console.log('onRefresh')
 
    // this.setData({
    //   count: 10
    // })
 
    this.showList();
 
 
    // setTimeout(() => {
    //   this.setData({
    //     items: this.getList()
    //   })
    //   $stopWuxRefresher()
    // }, 1000)
  },
  onLoadmore() {
    console.log('onLoadmore')
    this.showList();
  },
 
  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: ""
    }, () => {});
  },
 
  onChange(e) {
    console.log('onChange', e)
    this.setData({
      value: e.detail.value,
    })
  },
  onFocus(e) {
    console.log('onFocus', e)
  },
  onBlur(e) {
    console.log('onBlur', e)
    this.setData({
      value: e.detail.value
    })
    this.showList();
  },
  onConfirm(e) {
    console.log('onConfirm', e)
  },
  onClear(e) {
    console.log('onClear', e)
    this.setData({
      value: '',
    })
  },
  onCancel(e) {
    console.log('onCancel', e)
  },
})