|
1 | 1 | <template> |
2 | | - <!-- #ifdef APP-VUE --> |
| 2 | + <!-- #ifndef APP-NVUE --> |
3 | 3 | <view class="uni-list"> |
4 | 4 | <slot /> |
5 | 5 | </view> |
|
9 | 9 | <slot /> |
10 | 10 | </list> |
11 | 11 | <!-- #endif --> |
12 | | - <!-- #ifdef H5 || MP-WEIXIN || MP-QQ --> |
13 | | - <scroll-view class="uni-list" :enableBackToTop="enableBackToTop" :scroll-y="scrollY" @scrolltolower="loadMore" @touchstart="refresh.touchstart" @touchmove="refresh.touchmove" @touchend="refresh.touchend"> |
14 | | - <slot /> |
15 | | - </scroll-view> |
16 | | - <!-- #endif --> |
17 | | - <!-- #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO --> |
18 | | - <scroll-view class="uni-list" :scroll-y="scrollY" @scrolltolower="loadMore" @touchstart="ontouchstart" @touchmove="ontouchmove" @touchend="ontouchend"> |
19 | | - <slot /> |
20 | | - </scroll-view> |
21 | | - <!-- #endif --> |
22 | 12 | </template> |
23 | 13 |
|
24 | | -<script src="./uni-refresh.wxs" module="refresh" lang="wxs"></script> |
25 | | - |
26 | 14 | <script> |
27 | 15 | export default { |
28 | 16 | name: 'UniList', |
|
48 | 36 | }, |
49 | 37 | created() { |
50 | 38 | this.firstChildAppend = false |
51 | | - // #ifndef APP-NVUE |
52 | | - this.pullDown = { |
53 | | - threshold: 95, |
54 | | - maxHeight: 200, |
55 | | - callRefresh: 'onrefresh', |
56 | | - callPullingDown: 'onpullingdown', |
57 | | - refreshSelector: '.uni-refresh' |
58 | | - }; |
59 | | - this.height = 0; |
60 | | - this.canPullDown = false; |
61 | | - this.refreshInstance = {}; |
62 | | - // #endif |
63 | 39 | }, |
64 | 40 | methods: { |
65 | 41 | loadMore(e) { |
66 | 42 | this.$emit("scrolltolower"); |
67 | | - }, |
68 | | - ontouchstart(e) { |
69 | | - if (!this.canPullDown) { |
70 | | - return |
71 | | - } |
72 | | -
|
73 | | - this.height = 0; |
74 | | - this.touchStartY = e.touches[0].pageY || e.changedTouches[0].pageY; |
75 | | - this._updateRefresh(0); |
76 | | - this.refreshInstance.callMethod("onchange", true); |
77 | | - }, |
78 | | - ontouchmove(e) { |
79 | | - if (!this.canPullDown) { |
80 | | - return |
81 | | - } |
82 | | -
|
83 | | - var oldHeight = this.height; |
84 | | - var endY = e.touches[0].pageY || e.changedTouches[0].pageY; |
85 | | - var newHeight = endY - this.touchStartY; |
86 | | - if (newHeight > this.pullDown.maxHeight) { |
87 | | - return; |
88 | | - } |
89 | | -
|
90 | | - this._updateRefresh(newHeight); |
91 | | -
|
92 | | - newHeight = newHeight < this.pullDown.maxHeight ? newHeight : this.pullDown.maxHeight; |
93 | | - this.height = newHeight; |
94 | | -
|
95 | | - this.refreshInstance.callMethod(this.pullDown.callPullingDown, { |
96 | | - height: newHeight |
97 | | - }); |
98 | | - }, |
99 | | - ontouchend(e) { |
100 | | - if (!this.canPullDown) { |
101 | | - return |
102 | | - } |
103 | | -
|
104 | | - this.refreshInstance.callMethod("onchange", false); |
105 | | -
|
106 | | - if (this.height > this.pullDown.threshold) { |
107 | | - refreshInstance.callMethod(this.pullDown.callRefresh); |
108 | | - return; |
109 | | - } |
110 | | -
|
111 | | - this._updateRefresh(0); |
112 | | - }, |
113 | | - _updateRefresh(height) { |
114 | | - this.refreshInstance.setStyle({ |
115 | | - 'height': height |
116 | | - }); |
117 | 43 | } |
118 | 44 | } |
119 | 45 | } |
|
0 commit comments