@10yun/cv-mobile-ui 0.5.20 → 0.5.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugins/jumps.js +57 -12
- package/plugins/lbs.js +17 -8
- package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
- package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
- package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
- package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
- package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
- package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
- package/uni-ui/lib/uni-card/uni-card.vue +124 -1
- package/uni-ui/lib/uni-col/uni-col.vue +1 -1
- package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
- package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
- package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
- package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
- package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
- package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
- package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
- package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
- package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
- package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
- package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
- package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
- package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
- package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
- package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
- package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
- package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
- package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
- package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
- package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
- package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
- package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
- package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
- package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
- package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
- package/uni-ui/lib/uni-group/uni-group.vue +85 -1
- package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
- package/uni-ui/lib/uni-list/uni-list.vue +81 -1
- package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
- package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
- package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
- package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
- package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
- package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
- package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
- package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
- package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
- package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
- package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
- package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
- package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
- package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
- package/uni-ui/lib/uni-row/uni-row.vue +1 -1
- package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
- package/uni-ui/lib/uni-section/uni-section.vue +109 -1
- package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
- package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
- package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
- package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
- package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
- package/uni-ui/lib/uni-table/uni-table.vue +297 -1
- package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
- package/uni-ui/lib/uni-td/uni-td.vue +78 -1
- package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
- package/uni-ui/lib/uni-th/uni-th.vue +224 -1
- package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
- package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
- package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
|
@@ -1 +1,294 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view class="uni-indexed-list" ref="list" id="list">
|
|
3
2
|
<!-- #ifdef APP-NVUE -->
|
|
4
3
|
<list class="uni-indexed-list__scroll" scrollable="true" show-scrollbar="false">
|
|
5
4
|
<cell v-for="(list, idx) in lists" :key="idx" :ref="'uni-indexed-list-' + idx">
|
|
6
5
|
<!-- #endif -->
|
|
7
6
|
<!-- #ifndef APP-NVUE -->
|
|
8
7
|
<scroll-view :scroll-into-view="scrollViewId" class="uni-indexed-list__scroll" scroll-y>
|
|
9
8
|
<view v-for="(list, idx) in lists" :key="idx" :id="'uni-indexed-list-' + idx">
|
|
10
9
|
<!-- #endif -->
|
|
11
10
|
<indexed-list-item
|
|
12
11
|
:list="list"
|
|
13
12
|
:loaded="loaded"
|
|
14
13
|
:idx="idx"
|
|
15
14
|
:showSelect="showSelect"
|
|
16
15
|
@itemClick="onClick"
|
|
17
16
|
></indexed-list-item>
|
|
18
17
|
<!-- #ifndef APP-NVUE -->
|
|
19
18
|
</view>
|
|
20
19
|
</scroll-view>
|
|
21
20
|
<!-- #endif -->
|
|
22
21
|
<!-- #ifdef APP-NVUE -->
|
|
23
22
|
</cell>
|
|
24
23
|
</list>
|
|
25
24
|
<!-- #endif -->
|
|
26
25
|
<view
|
|
27
26
|
class="uni-indexed-list__menu"
|
|
28
27
|
@touchstart="touchStart"
|
|
29
28
|
@touchmove.stop.prevent="touchMove"
|
|
30
29
|
@touchend="touchEnd"
|
|
31
30
|
@mousedown.stop="mousedown"
|
|
32
31
|
@mousemove.stop.prevent="mousemove"
|
|
33
32
|
@mouseleave.stop="mouseleave"
|
|
34
33
|
>
|
|
35
34
|
<view
|
|
36
35
|
v-for="(list, key) in lists"
|
|
37
36
|
:key="key"
|
|
38
37
|
class="uni-indexed-list__menu-item"
|
|
39
38
|
:class="touchmoveIndex == key ? 'uni-indexed-list__menu--active' : ''"
|
|
40
39
|
>
|
|
41
40
|
<text class="uni-indexed-list__menu-text" :class="touchmoveIndex == key ? 'uni-indexed-list__menu-text--active' : ''">
|
|
42
41
|
{{ list.key }}
|
|
43
42
|
</text>
|
|
44
43
|
</view>
|
|
45
44
|
</view>
|
|
46
45
|
<view v-if="touchmove" class="uni-indexed-list__alert-wrapper">
|
|
47
46
|
<text class="uni-indexed-list__alert">{{ lists[touchmoveIndex].key }}</text>
|
|
48
47
|
</view>
|
|
49
48
|
</view>
|
|
50
49
|
var prev = Date.now();
|
|
51
50
|
return function () {
|
|
52
51
|
var context = this;
|
|
53
52
|
var args = arguments;
|
|
54
53
|
var now = Date.now();
|
|
55
54
|
if (now - prev >= delay) {
|
|
56
55
|
func.apply(context, args);
|
|
57
56
|
prev = Date.now();
|
|
58
57
|
}
|
|
59
58
|
};
|
|
60
59
|
let pageY = e.touches[0].pageY;
|
|
61
60
|
let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight);
|
|
62
61
|
if (this.touchmoveIndex === index) {
|
|
63
62
|
return false;
|
|
64
63
|
}
|
|
65
64
|
let item = this.lists[index];
|
|
66
65
|
if (item) {
|
|
67
66
|
// #ifndef APP-NVUE
|
|
68
67
|
this.scrollViewId = 'uni-indexed-list-' + index;
|
|
69
68
|
this.touchmoveIndex = index;
|
|
70
69
|
// #endif
|
|
71
70
|
// #ifdef APP-NVUE
|
|
72
71
|
dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], {
|
|
73
72
|
animated: false
|
|
74
73
|
});
|
|
75
74
|
this.touchmoveIndex = index;
|
|
76
75
|
// #endif
|
|
77
76
|
}
|
|
78
77
|
* IndexedList 索引列表
|
|
79
78
|
* @description 用于展示索引列表
|
|
80
79
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=375
|
|
81
80
|
* @property {Boolean} showSelect = [true|false] 展示模式
|
|
82
81
|
* @value true 展示模式
|
|
83
82
|
* @value false 选择模式
|
|
84
83
|
* @property {Object} options 索引列表需要的数据对象
|
|
85
84
|
* @event {Function} click 点击列表事件 ,返回当前选择项的事件对象
|
|
86
85
|
* @example <uni-indexed-list options="" showSelect="false" @click=""></uni-indexed-list>
|
|
87
86
|
*/
|
|
88
87
|
name: 'UniIndexedList',
|
|
89
88
|
components: {
|
|
90
89
|
indexedListItem
|
|
91
90
|
},
|
|
92
91
|
emits: ['click'],
|
|
93
92
|
props: {
|
|
94
93
|
options: {
|
|
95
94
|
type: Array,
|
|
96
95
|
default() {
|
|
97
96
|
return [];
|
|
98
97
|
}
|
|
99
98
|
},
|
|
100
99
|
showSelect: {
|
|
101
100
|
type: Boolean,
|
|
102
101
|
default: false
|
|
103
102
|
}
|
|
104
103
|
},
|
|
105
104
|
data() {
|
|
106
105
|
return {
|
|
107
106
|
lists: [],
|
|
108
107
|
winHeight: 0,
|
|
109
108
|
itemHeight: 0,
|
|
110
109
|
winOffsetY: 0,
|
|
111
110
|
touchmove: false,
|
|
112
111
|
touchmoveIndex: -1,
|
|
113
112
|
scrollViewId: '',
|
|
114
113
|
touchmovable: true,
|
|
115
114
|
loaded: false,
|
|
116
115
|
isPC: false
|
|
117
116
|
};
|
|
118
117
|
},
|
|
119
118
|
watch: {
|
|
120
119
|
options: {
|
|
121
120
|
handler: function () {
|
|
122
121
|
this.setList();
|
|
123
122
|
},
|
|
124
123
|
deep: true
|
|
125
124
|
}
|
|
126
125
|
},
|
|
127
126
|
mounted() {
|
|
128
127
|
// #ifdef H5
|
|
129
128
|
this.isPC = this.IsPC();
|
|
130
129
|
// #endif
|
|
131
130
|
setTimeout(() => {
|
|
132
131
|
this.setList();
|
|
133
132
|
}, 50);
|
|
134
133
|
setTimeout(() => {
|
|
135
134
|
this.loaded = true;
|
|
136
135
|
}, 300);
|
|
137
136
|
},
|
|
138
137
|
methods: {
|
|
139
138
|
setList() {
|
|
140
139
|
let index = 0;
|
|
141
140
|
this.lists = [];
|
|
142
141
|
this.options.forEach((value) => {
|
|
143
142
|
if (value.data.length === 0) {
|
|
144
143
|
return;
|
|
145
144
|
}
|
|
146
145
|
let indexBefore = index;
|
|
147
146
|
let items = value.data.map((item) => {
|
|
148
147
|
let obj = {};
|
|
149
148
|
obj['key'] = value.letter;
|
|
150
149
|
obj['name'] = item;
|
|
151
150
|
obj['itemIndex'] = index;
|
|
152
151
|
index++;
|
|
153
152
|
obj.checked = item.checked ? item.checked : false;
|
|
154
153
|
return obj;
|
|
155
154
|
});
|
|
156
155
|
this.lists.push({
|
|
157
156
|
title: value.letter,
|
|
158
157
|
key: value.letter,
|
|
159
158
|
items: items,
|
|
160
159
|
itemIndex: indexBefore
|
|
161
160
|
});
|
|
162
161
|
});
|
|
163
162
|
// #ifndef APP-NVUE
|
|
164
163
|
uni
|
|
165
164
|
.createSelectorQuery()
|
|
166
165
|
.in(this)
|
|
167
166
|
.select('#list')
|
|
168
167
|
.boundingClientRect()
|
|
169
168
|
.exec((ret) => {
|
|
170
169
|
this.winOffsetY = ret[0].top;
|
|
171
170
|
this.winHeight = ret[0].height;
|
|
172
171
|
this.itemHeight = this.winHeight / this.lists.length;
|
|
173
172
|
});
|
|
174
173
|
// #endif
|
|
175
174
|
// #ifdef APP-NVUE
|
|
176
175
|
dom.getComponentRect(this.$refs['list'], (res) => {
|
|
177
176
|
this.winOffsetY = res.size.top;
|
|
178
177
|
this.winHeight = res.size.height;
|
|
179
178
|
this.itemHeight = this.winHeight / this.lists.length;
|
|
180
179
|
});
|
|
181
180
|
// #endif
|
|
182
181
|
},
|
|
183
182
|
touchStart(e) {
|
|
184
183
|
this.touchmove = true;
|
|
185
184
|
let pageY = this.isPC ? e.pageY : e.touches[0].pageY;
|
|
186
185
|
let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight);
|
|
187
186
|
let item = this.lists[index];
|
|
188
187
|
if (item) {
|
|
189
188
|
this.scrollViewId = 'uni-indexed-list-' + index;
|
|
190
189
|
this.touchmoveIndex = index;
|
|
191
190
|
// #ifdef APP-NVUE
|
|
192
191
|
dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], {
|
|
193
192
|
animated: false
|
|
194
193
|
});
|
|
195
194
|
// #endif
|
|
196
195
|
}
|
|
197
196
|
},
|
|
198
197
|
touchMove(e) {
|
|
199
198
|
// #ifndef APP-PLUS
|
|
200
199
|
let pageY = this.isPC ? e.pageY : e.touches[0].pageY;
|
|
201
200
|
let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight);
|
|
202
201
|
if (this.touchmoveIndex === index) {
|
|
203
202
|
return false;
|
|
204
203
|
}
|
|
205
204
|
let item = this.lists[index];
|
|
206
205
|
if (item) {
|
|
207
206
|
this.scrollViewId = 'uni-indexed-list-' + index;
|
|
208
207
|
this.touchmoveIndex = index;
|
|
209
208
|
}
|
|
210
209
|
// #endif
|
|
211
210
|
// #ifdef APP-PLUS
|
|
212
211
|
throttleTouchMove.call(this, e);
|
|
213
212
|
// #endif
|
|
214
213
|
},
|
|
215
214
|
touchEnd() {
|
|
216
215
|
this.touchmove = false;
|
|
217
216
|
// this.touchmoveIndex = -1
|
|
218
217
|
},
|
|
219
218
|
/**
|
|
220
219
|
* 兼容 PC @tian
|
|
221
220
|
*/
|
|
222
221
|
mousedown(e) {
|
|
223
222
|
if (!this.isPC) return;
|
|
224
223
|
this.touchStart(e);
|
|
225
224
|
},
|
|
226
225
|
mousemove(e) {
|
|
227
226
|
if (!this.isPC) return;
|
|
228
227
|
this.touchMove(e);
|
|
229
228
|
},
|
|
230
229
|
mouseleave(e) {
|
|
231
230
|
if (!this.isPC) return;
|
|
232
231
|
this.touchEnd(e);
|
|
233
232
|
},
|
|
234
233
|
// #ifdef H5
|
|
235
234
|
IsPC() {
|
|
236
235
|
var userAgentInfo = navigator.userAgent;
|
|
237
236
|
var Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
|
|
238
237
|
var flag = true;
|
|
239
238
|
for (let v = 0; v < Agents.length - 1; v++) {
|
|
240
239
|
if (userAgentInfo.indexOf(Agents[v]) > 0) {
|
|
241
240
|
flag = false;
|
|
242
241
|
break;
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
244
|
return flag;
|
|
246
245
|
},
|
|
247
246
|
// #endif
|
|
248
247
|
onClick(e) {
|
|
249
248
|
let { idx, index } = e;
|
|
250
249
|
let obj = {};
|
|
251
250
|
for (let key in this.lists[idx].items[index]) {
|
|
252
251
|
obj[key] = this.lists[idx].items[index][key];
|
|
253
252
|
}
|
|
254
253
|
let select = [];
|
|
255
254
|
if (this.showSelect) {
|
|
256
255
|
this.lists[idx].items[index].checked = !this.lists[idx].items[index].checked;
|
|
257
256
|
this.lists.forEach((value, idx) => {
|
|
258
257
|
value.items.forEach((item, index) => {
|
|
259
258
|
if (item.checked) {
|
|
260
259
|
let obj = {};
|
|
261
260
|
for (let key in this.lists[idx].items[index]) {
|
|
262
261
|
obj[key] = this.lists[idx].items[index][key];
|
|
263
262
|
}
|
|
264
263
|
select.push(obj);
|
|
265
264
|
}
|
|
266
265
|
});
|
|
267
266
|
});
|
|
268
267
|
}
|
|
269
268
|
this.$emit('click', {
|
|
270
269
|
item: obj,
|
|
271
270
|
select: select
|
|
272
271
|
});
|
|
273
272
|
}
|
|
274
273
|
}
|
|
274
|
+
<template>
|
|
275
|
+
<view class="uni-indexed-list" ref="list" id="list">
|
|
276
|
+
<!-- #ifdef APP-NVUE -->
|
|
277
|
+
<list class="uni-indexed-list__scroll" scrollable="true" show-scrollbar="false">
|
|
278
|
+
<cell v-for="(list, idx) in lists" :key="idx" :ref="'uni-indexed-list-' + idx">
|
|
279
|
+
<!-- #endif -->
|
|
280
|
+
<!-- #ifndef APP-NVUE -->
|
|
281
|
+
<scroll-view :scroll-into-view="scrollViewId" class="uni-indexed-list__scroll" scroll-y>
|
|
282
|
+
<view v-for="(list, idx) in lists" :key="idx" :id="'uni-indexed-list-' + idx">
|
|
283
|
+
<!-- #endif -->
|
|
284
|
+
<indexed-list-item
|
|
285
|
+
:list="list"
|
|
286
|
+
:loaded="loaded"
|
|
287
|
+
:idx="idx"
|
|
288
|
+
:showSelect="showSelect"
|
|
289
|
+
@itemClick="onClick"
|
|
290
|
+
></indexed-list-item>
|
|
291
|
+
<!-- #ifndef APP-NVUE -->
|
|
292
|
+
</view>
|
|
293
|
+
</scroll-view>
|
|
294
|
+
<!-- #endif -->
|
|
295
|
+
<!-- #ifdef APP-NVUE -->
|
|
296
|
+
</cell>
|
|
297
|
+
</list>
|
|
298
|
+
<!-- #endif -->
|
|
299
|
+
<view
|
|
300
|
+
class="uni-indexed-list__menu"
|
|
301
|
+
@touchstart="touchStart"
|
|
302
|
+
@touchmove.stop.prevent="touchMove"
|
|
303
|
+
@touchend="touchEnd"
|
|
304
|
+
@mousedown.stop="mousedown"
|
|
305
|
+
@mousemove.stop.prevent="mousemove"
|
|
306
|
+
@mouseleave.stop="mouseleave"
|
|
307
|
+
>
|
|
308
|
+
<view
|
|
309
|
+
v-for="(list, key) in lists"
|
|
310
|
+
:key="key"
|
|
311
|
+
class="uni-indexed-list__menu-item"
|
|
312
|
+
:class="touchmoveIndex == key ? 'uni-indexed-list__menu--active' : ''"
|
|
313
|
+
>
|
|
314
|
+
<text class="uni-indexed-list__menu-text" :class="touchmoveIndex == key ? 'uni-indexed-list__menu-text--active' : ''">
|
|
315
|
+
{{ list.key }}
|
|
316
|
+
</text>
|
|
317
|
+
</view>
|
|
318
|
+
</view>
|
|
319
|
+
<view v-if="touchmove" class="uni-indexed-list__alert-wrapper">
|
|
320
|
+
<text class="uni-indexed-list__alert">{{ lists[touchmoveIndex].key }}</text>
|
|
321
|
+
</view>
|
|
322
|
+
</view>
|
|
323
|
+
</template>
|
|
324
|
+
<script>
|
|
325
|
+
import indexedListItem from './uni-indexed-list-item.vue';
|
|
326
|
+
// #ifdef APP-NVUE
|
|
327
|
+
const dom = weex.requireModule('dom');
|
|
328
|
+
// #endif
|
|
329
|
+
// #ifdef APP-PLUS
|
|
330
|
+
function throttle(func, delay) {
|
|
331
|
+
var prev = Date.now();
|
|
332
|
+
return function () {
|
|
333
|
+
var context = this;
|
|
334
|
+
var args = arguments;
|
|
335
|
+
var now = Date.now();
|
|
336
|
+
if (now - prev >= delay) {
|
|
337
|
+
func.apply(context, args);
|
|
338
|
+
prev = Date.now();
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function touchMove(e) {
|
|
343
|
+
let pageY = e.touches[0].pageY;
|
|
344
|
+
let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight);
|
|
345
|
+
if (this.touchmoveIndex === index) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
let item = this.lists[index];
|
|
349
|
+
if (item) {
|
|
350
|
+
// #ifndef APP-NVUE
|
|
351
|
+
this.scrollViewId = 'uni-indexed-list-' + index;
|
|
352
|
+
this.touchmoveIndex = index;
|
|
353
|
+
// #endif
|
|
354
|
+
// #ifdef APP-NVUE
|
|
355
|
+
dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], {
|
|
356
|
+
animated: false
|
|
357
|
+
});
|
|
358
|
+
this.touchmoveIndex = index;
|
|
359
|
+
// #endif
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const throttleTouchMove = throttle(touchMove, 40);
|
|
363
|
+
// #endif
|
|
364
|
+
/**
|
|
365
|
+
* IndexedList 索引列表
|
|
366
|
+
* @description 用于展示索引列表
|
|
367
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=375
|
|
368
|
+
* @property {Boolean} showSelect = [true|false] 展示模式
|
|
369
|
+
* @value true 展示模式
|
|
370
|
+
* @value false 选择模式
|
|
371
|
+
* @property {Object} options 索引列表需要的数据对象
|
|
372
|
+
* @event {Function} click 点击列表事件 ,返回当前选择项的事件对象
|
|
373
|
+
* @example <uni-indexed-list options="" showSelect="false" @click=""></uni-indexed-list>
|
|
374
|
+
*/
|
|
375
|
+
export default {
|
|
376
|
+
name: 'UniIndexedList',
|
|
377
|
+
components: {
|
|
378
|
+
indexedListItem
|
|
379
|
+
},
|
|
380
|
+
emits: ['click'],
|
|
381
|
+
props: {
|
|
382
|
+
options: {
|
|
383
|
+
type: Array,
|
|
384
|
+
default() {
|
|
385
|
+
return [];
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
showSelect: {
|
|
389
|
+
type: Boolean,
|
|
390
|
+
default: false
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
data() {
|
|
394
|
+
return {
|
|
395
|
+
lists: [],
|
|
396
|
+
winHeight: 0,
|
|
397
|
+
itemHeight: 0,
|
|
398
|
+
winOffsetY: 0,
|
|
399
|
+
touchmove: false,
|
|
400
|
+
touchmoveIndex: -1,
|
|
401
|
+
scrollViewId: '',
|
|
402
|
+
touchmovable: true,
|
|
403
|
+
loaded: false,
|
|
404
|
+
isPC: false
|
|
405
|
+
};
|
|
406
|
+
},
|
|
407
|
+
watch: {
|
|
408
|
+
options: {
|
|
409
|
+
handler: function () {
|
|
410
|
+
this.setList();
|
|
411
|
+
},
|
|
412
|
+
deep: true
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
mounted() {
|
|
416
|
+
// #ifdef H5
|
|
417
|
+
this.isPC = this.IsPC();
|
|
418
|
+
// #endif
|
|
419
|
+
setTimeout(() => {
|
|
420
|
+
this.setList();
|
|
421
|
+
}, 50);
|
|
422
|
+
setTimeout(() => {
|
|
423
|
+
this.loaded = true;
|
|
424
|
+
}, 300);
|
|
425
|
+
},
|
|
426
|
+
methods: {
|
|
427
|
+
setList() {
|
|
428
|
+
let index = 0;
|
|
429
|
+
this.lists = [];
|
|
430
|
+
this.options.forEach((value) => {
|
|
431
|
+
if (value.data.length === 0) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
let indexBefore = index;
|
|
435
|
+
let items = value.data.map((item) => {
|
|
436
|
+
let obj = {};
|
|
437
|
+
obj['key'] = value.letter;
|
|
438
|
+
obj['name'] = item;
|
|
439
|
+
obj['itemIndex'] = index;
|
|
440
|
+
index++;
|
|
441
|
+
obj.checked = item.checked ? item.checked : false;
|
|
442
|
+
return obj;
|
|
443
|
+
});
|
|
444
|
+
this.lists.push({
|
|
445
|
+
title: value.letter,
|
|
446
|
+
key: value.letter,
|
|
447
|
+
items: items,
|
|
448
|
+
itemIndex: indexBefore
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
// #ifndef APP-NVUE
|
|
452
|
+
uni
|
|
453
|
+
.createSelectorQuery()
|
|
454
|
+
.in(this)
|
|
455
|
+
.select('#list')
|
|
456
|
+
.boundingClientRect()
|
|
457
|
+
.exec((ret) => {
|
|
458
|
+
this.winOffsetY = ret[0].top;
|
|
459
|
+
this.winHeight = ret[0].height;
|
|
460
|
+
this.itemHeight = this.winHeight / this.lists.length;
|
|
461
|
+
});
|
|
462
|
+
// #endif
|
|
463
|
+
// #ifdef APP-NVUE
|
|
464
|
+
dom.getComponentRect(this.$refs['list'], (res) => {
|
|
465
|
+
this.winOffsetY = res.size.top;
|
|
466
|
+
this.winHeight = res.size.height;
|
|
467
|
+
this.itemHeight = this.winHeight / this.lists.length;
|
|
468
|
+
});
|
|
469
|
+
// #endif
|
|
470
|
+
},
|
|
471
|
+
touchStart(e) {
|
|
472
|
+
this.touchmove = true;
|
|
473
|
+
let pageY = this.isPC ? e.pageY : e.touches[0].pageY;
|
|
474
|
+
let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight);
|
|
475
|
+
let item = this.lists[index];
|
|
476
|
+
if (item) {
|
|
477
|
+
this.scrollViewId = 'uni-indexed-list-' + index;
|
|
478
|
+
this.touchmoveIndex = index;
|
|
479
|
+
// #ifdef APP-NVUE
|
|
480
|
+
dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], {
|
|
481
|
+
animated: false
|
|
482
|
+
});
|
|
483
|
+
// #endif
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
touchMove(e) {
|
|
487
|
+
// #ifndef APP-PLUS
|
|
488
|
+
let pageY = this.isPC ? e.pageY : e.touches[0].pageY;
|
|
489
|
+
let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight);
|
|
490
|
+
if (this.touchmoveIndex === index) {
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
let item = this.lists[index];
|
|
494
|
+
if (item) {
|
|
495
|
+
this.scrollViewId = 'uni-indexed-list-' + index;
|
|
496
|
+
this.touchmoveIndex = index;
|
|
497
|
+
}
|
|
498
|
+
// #endif
|
|
499
|
+
// #ifdef APP-PLUS
|
|
500
|
+
throttleTouchMove.call(this, e);
|
|
501
|
+
// #endif
|
|
502
|
+
},
|
|
503
|
+
touchEnd() {
|
|
504
|
+
this.touchmove = false;
|
|
505
|
+
// this.touchmoveIndex = -1
|
|
506
|
+
},
|
|
507
|
+
/**
|
|
508
|
+
* 兼容 PC @tian
|
|
509
|
+
*/
|
|
510
|
+
mousedown(e) {
|
|
511
|
+
if (!this.isPC) return;
|
|
512
|
+
this.touchStart(e);
|
|
513
|
+
},
|
|
514
|
+
mousemove(e) {
|
|
515
|
+
if (!this.isPC) return;
|
|
516
|
+
this.touchMove(e);
|
|
517
|
+
},
|
|
518
|
+
mouseleave(e) {
|
|
519
|
+
if (!this.isPC) return;
|
|
520
|
+
this.touchEnd(e);
|
|
521
|
+
},
|
|
522
|
+
// #ifdef H5
|
|
523
|
+
IsPC() {
|
|
524
|
+
var userAgentInfo = navigator.userAgent;
|
|
525
|
+
var Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
|
|
526
|
+
var flag = true;
|
|
527
|
+
for (let v = 0; v < Agents.length - 1; v++) {
|
|
528
|
+
if (userAgentInfo.indexOf(Agents[v]) > 0) {
|
|
529
|
+
flag = false;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return flag;
|
|
534
|
+
},
|
|
535
|
+
// #endif
|
|
536
|
+
onClick(e) {
|
|
537
|
+
let { idx, index } = e;
|
|
538
|
+
let obj = {};
|
|
539
|
+
for (let key in this.lists[idx].items[index]) {
|
|
540
|
+
obj[key] = this.lists[idx].items[index][key];
|
|
541
|
+
}
|
|
542
|
+
let select = [];
|
|
543
|
+
if (this.showSelect) {
|
|
544
|
+
this.lists[idx].items[index].checked = !this.lists[idx].items[index].checked;
|
|
545
|
+
this.lists.forEach((value, idx) => {
|
|
546
|
+
value.items.forEach((item, index) => {
|
|
547
|
+
if (item.checked) {
|
|
548
|
+
let obj = {};
|
|
549
|
+
for (let key in this.lists[idx].items[index]) {
|
|
550
|
+
obj[key] = this.lists[idx].items[index][key];
|
|
551
|
+
}
|
|
552
|
+
select.push(obj);
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
this.$emit('click', {
|
|
558
|
+
item: obj,
|
|
559
|
+
select: select
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
</script>
|
|
565
|
+
<style>
|
|
566
|
+
@import 'style.css';
|
|
567
|
+
</style>
|