@kengic/uni 0.5.1 → 0.5.2-beta.1

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.
Files changed (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -1,367 +1,372 @@
1
1
  <template>
2
- <view class="uni-indexed-list" ref="list" id="list">
3
- <!-- #ifdef APP-NVUE -->
4
- <list class="uni-indexed-list__scroll" scrollable="true" show-scrollbar="false">
5
- <cell v-for="(list, idx) in lists" :key="idx" :ref="'uni-indexed-list-' + idx">
6
- <!-- #endif -->
7
- <!-- #ifndef APP-NVUE -->
8
- <scroll-view :scroll-into-view="scrollViewId" class="uni-indexed-list__scroll" scroll-y>
9
- <view v-for="(list, idx) in lists" :key="idx" :id="'uni-indexed-list-' + idx">
10
- <!-- #endif -->
11
- <indexed-list-item :list="list" :loaded="loaded" :idx="idx" :showSelect="showSelect"
12
- @itemClick="onClick"></indexed-list-item>
13
- <!-- #ifndef APP-NVUE -->
14
- </view>
15
- </scroll-view>
16
- <!-- #endif -->
17
- <!-- #ifdef APP-NVUE -->
18
- </cell>
19
- </list>
20
- <!-- #endif -->
21
- <view class="uni-indexed-list__menu" @touchstart="touchStart" @touchmove.stop.prevent="touchMove"
22
- @touchend="touchEnd" @mousedown.stop="mousedown" @mousemove.stop.prevent="mousemove"
23
- @mouseleave.stop="mouseleave">
24
- <view v-for="(list, key) in lists" :key="key" class="uni-indexed-list__menu-item"
25
- :class="touchmoveIndex == key ? 'uni-indexed-list__menu--active' : ''">
26
- <text class="uni-indexed-list__menu-text"
27
- :class="touchmoveIndex == key ? 'uni-indexed-list__menu-text--active' : ''">{{ list.key }}</text>
28
- </view>
29
- </view>
30
- <view v-if="touchmove" class="uni-indexed-list__alert-wrapper">
31
- <text class="uni-indexed-list__alert">{{ lists[touchmoveIndex].key }}</text>
32
- </view>
33
- </view>
2
+ <view class="uni-indexed-list" ref="list" id="list">
3
+ <!-- #ifdef APP-NVUE -->
4
+ <list class="uni-indexed-list__scroll" scrollable="true" show-scrollbar="false">
5
+ <cell v-for="(list, idx) in lists" :key="idx" :ref="'uni-indexed-list-' + idx">
6
+ <!-- #endif -->
7
+ <!-- #ifndef APP-NVUE -->
8
+ <scroll-view :scroll-into-view="scrollViewId" class="uni-indexed-list__scroll" scroll-y>
9
+ <view v-for="(list, idx) in lists" :key="idx" :id="'uni-indexed-list-' + idx">
10
+ <!-- #endif -->
11
+ <indexed-list-item :list="list" :loaded="loaded" :idx="idx" :showSelect="showSelect" @itemClick="onClick"></indexed-list-item>
12
+ <!-- #ifndef APP-NVUE -->
13
+ </view>
14
+ </scroll-view>
15
+ <!-- #endif -->
16
+ <!-- #ifdef APP-NVUE -->
17
+ </cell>
18
+ </list>
19
+ <!-- #endif -->
20
+ <view
21
+ class="uni-indexed-list__menu"
22
+ @touchstart="touchStart"
23
+ @touchmove.stop.prevent="touchMove"
24
+ @touchend="touchEnd"
25
+ @mousedown.stop="mousedown"
26
+ @mousemove.stop.prevent="mousemove"
27
+ @mouseleave.stop="mouseleave"
28
+ >
29
+ <view
30
+ v-for="(list, key) in lists"
31
+ :key="key"
32
+ class="uni-indexed-list__menu-item"
33
+ :class="touchmoveIndex == key ? 'uni-indexed-list__menu--active' : ''"
34
+ >
35
+ <text class="uni-indexed-list__menu-text" :class="touchmoveIndex == key ? 'uni-indexed-list__menu-text--active' : ''">{{ list.key }}</text>
36
+ </view>
37
+ </view>
38
+ <view v-if="touchmove" class="uni-indexed-list__alert-wrapper">
39
+ <text class="uni-indexed-list__alert">{{ lists[touchmoveIndex].key }}</text>
40
+ </view>
41
+ </view>
34
42
  </template>
35
43
  <script>
36
- import indexedListItem from './uni-indexed-list-item.vue'
37
- // #ifdef APP-NVUE
38
- const dom = weex.requireModule('dom');
39
- // #endif
40
- // #ifdef APP-PLUS
41
- function throttle(func, delay) {
42
- var prev = Date.now();
43
- return function() {
44
- var context = this;
45
- var args = arguments;
46
- var now = Date.now();
47
- if (now - prev >= delay) {
48
- func.apply(context, args);
49
- prev = Date.now();
50
- }
51
- }
52
- }
44
+ import indexedListItem from './uni-indexed-list-item.vue';
45
+ // #ifdef APP-NVUE
46
+ const dom = weex.requireModule('dom');
47
+ // #endif
48
+ // #ifdef APP-PLUS
49
+ function throttle(func, delay) {
50
+ var prev = Date.now();
51
+ return function () {
52
+ var context = this;
53
+ var args = arguments;
54
+ var now = Date.now();
55
+ if (now - prev >= delay) {
56
+ func.apply(context, args);
57
+ prev = Date.now();
58
+ }
59
+ };
60
+ }
53
61
 
54
- function touchMove(e) {
55
- let pageY = e.touches[0].pageY
56
- let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight)
57
- if (this.touchmoveIndex === index) {
58
- return false
59
- }
60
- let item = this.lists[index]
61
- if (item) {
62
- // #ifndef APP-NVUE
63
- this.scrollViewId = 'uni-indexed-list-' + index
64
- this.touchmoveIndex = index
65
- // #endif
66
- // #ifdef APP-NVUE
67
- dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], {
68
- animated: false
69
- })
70
- this.touchmoveIndex = index
71
- // #endif
72
- }
73
- }
74
- const throttleTouchMove = throttle(touchMove, 40)
75
- // #endif
62
+ function touchMove(e) {
63
+ let pageY = e.touches[0].pageY;
64
+ let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight);
65
+ if (this.touchmoveIndex === index) {
66
+ return false;
67
+ }
68
+ let item = this.lists[index];
69
+ if (item) {
70
+ // #ifndef APP-NVUE
71
+ this.scrollViewId = 'uni-indexed-list-' + index;
72
+ this.touchmoveIndex = index;
73
+ // #endif
74
+ // #ifdef APP-NVUE
75
+ dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], {
76
+ animated: false,
77
+ });
78
+ this.touchmoveIndex = index;
79
+ // #endif
80
+ }
81
+ }
82
+ const throttleTouchMove = throttle(touchMove, 40);
83
+ // #endif
76
84
 
77
- /**
78
- * IndexedList 索引列表
79
- * @description 用于展示索引列表
80
- * @tutorial https://ext.dcloud.net.cn/plugin?id=375
81
- * @property {Boolean} showSelect = [true|false] 展示模式
82
- * @value true 展示模式
83
- * @value false 选择模式
84
- * @property {Object} options 索引列表需要的数据对象
85
- * @event {Function} click 点击列表事件 ,返回当前选择项的事件对象
86
- * @example <uni-indexed-list options="" showSelect="false" @click=""></uni-indexed-list>
87
- */
88
- export default {
89
- name: 'UniIndexedList',
90
- components: {
91
- indexedListItem
92
- },
93
- emits: ['click'],
94
- props: {
95
- options: {
96
- type: Array,
97
- default () {
98
- return []
99
- }
100
- },
101
- showSelect: {
102
- type: Boolean,
103
- default: false
104
- }
105
- },
106
- data() {
107
- return {
108
- lists: [],
109
- winHeight: 0,
110
- itemHeight: 0,
111
- winOffsetY: 0,
112
- touchmove: false,
113
- touchmoveIndex: -1,
114
- scrollViewId: '',
115
- touchmovable: true,
116
- loaded: false,
117
- isPC: false
118
- }
119
- },
120
- watch: {
121
- options: {
122
- handler: function() {
123
- this.setList()
124
- },
125
- deep: true
126
- }
127
- },
128
- mounted() {
129
- // #ifdef H5
130
- this.isPC = this.IsPC()
131
- // #endif
132
- setTimeout(() => {
133
- this.setList()
134
- }, 50)
135
- setTimeout(() => {
136
- this.loaded = true
137
- }, 300);
138
- },
139
- methods: {
140
- setList() {
141
- let index = 0;
142
- this.lists = []
143
- this.options.forEach((value) => {
144
- if (value.data.length === 0) {
145
- return
146
- }
147
- let indexBefore = index
148
- let items = value.data.map(item => {
149
- let obj = {}
150
- obj['key'] = value.letter
151
- obj['name'] = item
152
- obj['itemIndex'] = index
153
- index++
154
- obj.checked = item.checked ? item.checked : false
155
- return obj
156
- })
157
- this.lists.push({
158
- title: value.letter,
159
- key: value.letter,
160
- items: items,
161
- itemIndex: indexBefore
162
- })
163
- })
164
- // #ifndef APP-NVUE
165
- uni.createSelectorQuery()
166
- .in(this)
167
- .select('#list')
168
- .boundingClientRect()
169
- .exec(ret => {
170
- this.winOffsetY = ret[0].top
171
- this.winHeight = ret[0].height
172
- this.itemHeight = this.winHeight / this.lists.length
173
- })
174
- // #endif
175
- // #ifdef APP-NVUE
176
- dom.getComponentRect(this.$refs['list'], (res) => {
177
- this.winOffsetY = res.size.top
178
- this.winHeight = res.size.height
179
- this.itemHeight = this.winHeight / this.lists.length
180
- })
181
- // #endif
182
- },
183
- touchStart(e) {
184
- this.touchmove = true
185
- let pageY = this.isPC ? e.pageY : e.touches[0].pageY
186
- let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight)
187
- let item = this.lists[index]
188
- if (item) {
189
- this.scrollViewId = 'uni-indexed-list-' + index
190
- this.touchmoveIndex = index
191
- // #ifdef APP-NVUE
192
- dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], {
193
- animated: false
194
- })
195
- // #endif
196
- }
197
- },
198
- touchMove(e) {
199
- // #ifndef APP-PLUS
200
- let pageY = this.isPC ? e.pageY : e.touches[0].pageY
201
- let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight)
202
- if (this.touchmoveIndex === index) {
203
- return false
204
- }
205
- let item = this.lists[index]
206
- if (item) {
207
- this.scrollViewId = 'uni-indexed-list-' + index
208
- this.touchmoveIndex = index
209
- }
210
- // #endif
211
- // #ifdef APP-PLUS
212
- throttleTouchMove.call(this, e)
213
- // #endif
214
- },
215
- touchEnd() {
216
- this.touchmove = false
217
- // this.touchmoveIndex = -1
218
- },
85
+ /**
86
+ * IndexedList 索引列表
87
+ * @description 用于展示索引列表
88
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=375
89
+ * @property {Boolean} showSelect = [true|false] 展示模式
90
+ * @value true 展示模式
91
+ * @value false 选择模式
92
+ * @property {Object} options 索引列表需要的数据对象
93
+ * @event {Function} click 点击列表事件 ,返回当前选择项的事件对象
94
+ * @example <uni-indexed-list options="" showSelect="false" @click=""></uni-indexed-list>
95
+ */
96
+ export default {
97
+ name: 'UniIndexedList',
98
+ components: {
99
+ indexedListItem,
100
+ },
101
+ emits: ['click'],
102
+ props: {
103
+ options: {
104
+ type: Array,
105
+ default() {
106
+ return [];
107
+ },
108
+ },
109
+ showSelect: {
110
+ type: Boolean,
111
+ default: false,
112
+ },
113
+ },
114
+ data() {
115
+ return {
116
+ lists: [],
117
+ winHeight: 0,
118
+ itemHeight: 0,
119
+ winOffsetY: 0,
120
+ touchmove: false,
121
+ touchmoveIndex: -1,
122
+ scrollViewId: '',
123
+ touchmovable: true,
124
+ loaded: false,
125
+ isPC: false,
126
+ };
127
+ },
128
+ watch: {
129
+ options: {
130
+ handler: function () {
131
+ this.setList();
132
+ },
133
+ deep: true,
134
+ },
135
+ },
136
+ mounted() {
137
+ // #ifdef H5
138
+ this.isPC = this.IsPC();
139
+ // #endif
140
+ setTimeout(() => {
141
+ this.setList();
142
+ }, 50);
143
+ setTimeout(() => {
144
+ this.loaded = true;
145
+ }, 300);
146
+ },
147
+ methods: {
148
+ setList() {
149
+ let index = 0;
150
+ this.lists = [];
151
+ this.options.forEach((value) => {
152
+ if (value.data.length === 0) {
153
+ return;
154
+ }
155
+ let indexBefore = index;
156
+ let items = value.data.map((item) => {
157
+ let obj = {};
158
+ obj['key'] = value.letter;
159
+ obj['name'] = item;
160
+ obj['itemIndex'] = index;
161
+ index++;
162
+ obj.checked = item.checked ? item.checked : false;
163
+ return obj;
164
+ });
165
+ this.lists.push({
166
+ title: value.letter,
167
+ key: value.letter,
168
+ items: items,
169
+ itemIndex: indexBefore,
170
+ });
171
+ });
172
+ // #ifndef APP-NVUE
173
+ uni.createSelectorQuery()
174
+ .in(this)
175
+ .select('#list')
176
+ .boundingClientRect()
177
+ .exec((ret) => {
178
+ this.winOffsetY = ret[0].top;
179
+ this.winHeight = ret[0].height;
180
+ this.itemHeight = this.winHeight / this.lists.length;
181
+ });
182
+ // #endif
183
+ // #ifdef APP-NVUE
184
+ dom.getComponentRect(this.$refs['list'], (res) => {
185
+ this.winOffsetY = res.size.top;
186
+ this.winHeight = res.size.height;
187
+ this.itemHeight = this.winHeight / this.lists.length;
188
+ });
189
+ // #endif
190
+ },
191
+ touchStart(e) {
192
+ this.touchmove = true;
193
+ let pageY = this.isPC ? e.pageY : e.touches[0].pageY;
194
+ let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight);
195
+ let item = this.lists[index];
196
+ if (item) {
197
+ this.scrollViewId = 'uni-indexed-list-' + index;
198
+ this.touchmoveIndex = index;
199
+ // #ifdef APP-NVUE
200
+ dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], {
201
+ animated: false,
202
+ });
203
+ // #endif
204
+ }
205
+ },
206
+ touchMove(e) {
207
+ // #ifndef APP-PLUS
208
+ let pageY = this.isPC ? e.pageY : e.touches[0].pageY;
209
+ let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight);
210
+ if (this.touchmoveIndex === index) {
211
+ return false;
212
+ }
213
+ let item = this.lists[index];
214
+ if (item) {
215
+ this.scrollViewId = 'uni-indexed-list-' + index;
216
+ this.touchmoveIndex = index;
217
+ }
218
+ // #endif
219
+ // #ifdef APP-PLUS
220
+ throttleTouchMove.call(this, e);
221
+ // #endif
222
+ },
223
+ touchEnd() {
224
+ this.touchmove = false;
225
+ // this.touchmoveIndex = -1
226
+ },
219
227
 
220
- /**
221
- * 兼容 PC @tian
222
- */
228
+ /**
229
+ * 兼容 PC @tian
230
+ */
223
231
 
224
- mousedown(e) {
225
- if (!this.isPC) return
226
- this.touchStart(e)
227
- },
228
- mousemove(e) {
229
- if (!this.isPC) return
230
- this.touchMove(e)
231
- },
232
- mouseleave(e) {
233
- if (!this.isPC) return
234
- this.touchEnd(e)
235
- },
232
+ mousedown(e) {
233
+ if (!this.isPC) return;
234
+ this.touchStart(e);
235
+ },
236
+ mousemove(e) {
237
+ if (!this.isPC) return;
238
+ this.touchMove(e);
239
+ },
240
+ mouseleave(e) {
241
+ if (!this.isPC) return;
242
+ this.touchEnd(e);
243
+ },
236
244
 
237
- // #ifdef H5
238
- IsPC() {
239
- var userAgentInfo = navigator.userAgent;
240
- var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
241
- var flag = true;
242
- for (let v = 0; v < Agents.length - 1; v++) {
243
- if (userAgentInfo.indexOf(Agents[v]) > 0) {
244
- flag = false;
245
- break;
246
- }
247
- }
248
- return flag;
249
- },
250
- // #endif
245
+ // #ifdef H5
246
+ IsPC() {
247
+ var userAgentInfo = navigator.userAgent;
248
+ var Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
249
+ var flag = true;
250
+ for (let v = 0; v < Agents.length - 1; v++) {
251
+ if (userAgentInfo.indexOf(Agents[v]) > 0) {
252
+ flag = false;
253
+ break;
254
+ }
255
+ }
256
+ return flag;
257
+ },
258
+ // #endif
251
259
 
252
-
253
- onClick(e) {
254
- let {
255
- idx,
256
- index
257
- } = e
258
- let obj = {}
259
- for (let key in this.lists[idx].items[index]) {
260
- obj[key] = this.lists[idx].items[index][key]
261
- }
262
- let select = []
263
- if (this.showSelect) {
264
- this.lists[idx].items[index].checked = !this.lists[idx].items[index].checked
265
- this.lists.forEach((value, idx) => {
266
- value.items.forEach((item, index) => {
267
- if (item.checked) {
268
- let obj = {}
269
- for (let key in this.lists[idx].items[index]) {
270
- obj[key] = this.lists[idx].items[index][key]
271
- }
272
- select.push(obj)
273
- }
274
- })
275
- })
276
- }
277
- this.$emit('click', {
278
- item: obj,
279
- select: select
280
- })
281
- }
282
- }
283
- }
260
+ onClick(e) {
261
+ let { idx, index } = e;
262
+ let obj = {};
263
+ for (let key in this.lists[idx].items[index]) {
264
+ obj[key] = this.lists[idx].items[index][key];
265
+ }
266
+ let select = [];
267
+ if (this.showSelect) {
268
+ this.lists[idx].items[index].checked = !this.lists[idx].items[index].checked;
269
+ this.lists.forEach((value, idx) => {
270
+ value.items.forEach((item, index) => {
271
+ if (item.checked) {
272
+ let obj = {};
273
+ for (let key in this.lists[idx].items[index]) {
274
+ obj[key] = this.lists[idx].items[index][key];
275
+ }
276
+ select.push(obj);
277
+ }
278
+ });
279
+ });
280
+ }
281
+ this.$emit('click', {
282
+ item: obj,
283
+ select: select,
284
+ });
285
+ },
286
+ },
287
+ };
284
288
  </script>
285
- <style lang="scss" >
286
- .uni-indexed-list {
287
- position: absolute;
288
- left: 0;
289
- top: 0;
290
- right: 0;
291
- bottom: 0;
292
- /* #ifndef APP-NVUE */
293
- display: flex;
294
- /* #endif */
295
- flex-direction: row;
296
- }
289
+ <style lang="scss">
290
+ .uni-indexed-list {
291
+ position: absolute;
292
+ left: 0;
293
+ top: 0;
294
+ right: 0;
295
+ bottom: 0;
296
+ /* #ifndef APP-NVUE */
297
+ display: flex;
298
+ /* #endif */
299
+ flex-direction: row;
300
+ }
297
301
 
298
- .uni-indexed-list__scroll {
299
- flex: 1;
300
- }
302
+ .uni-indexed-list__scroll {
303
+ flex: 1;
304
+ }
301
305
 
302
- .uni-indexed-list__menu {
303
- width: 24px;
304
- /* #ifndef APP-NVUE */
305
- display: flex;
306
- /* #endif */
307
- flex-direction: column;
308
- }
306
+ .uni-indexed-list__menu {
307
+ width: 24px;
308
+ /* #ifndef APP-NVUE */
309
+ display: flex;
310
+ /* #endif */
311
+ flex-direction: column;
312
+ }
309
313
 
310
- .uni-indexed-list__menu-item {
311
- /* #ifndef APP-NVUE */
312
- display: flex;
313
- /* #endif */
314
- flex: 1;
315
- align-items: center;
316
- justify-content: center;
317
- /* #ifdef H5 */
318
- cursor: pointer;
319
- /* #endif */
320
- }
314
+ .uni-indexed-list__menu-item {
315
+ /* #ifndef APP-NVUE */
316
+ display: flex;
317
+ /* #endif */
318
+ flex: 1;
319
+ align-items: center;
320
+ justify-content: center;
321
+ /* #ifdef H5 */
322
+ cursor: pointer;
323
+ /* #endif */
324
+ }
321
325
 
322
- .uni-indexed-list__menu-text {
323
- font-size: 12px;
324
- text-align: center;
325
- color: #aaa;
326
- }
326
+ .uni-indexed-list__menu-text {
327
+ font-size: 12px;
328
+ text-align: center;
329
+ color: #aaa;
330
+ }
327
331
 
328
- .uni-indexed-list__menu--active {
329
- // background-color: rgb(200, 200, 200);
330
- }
332
+ .uni-indexed-list__menu--active {
333
+ // background-color: rgb(200, 200, 200);
334
+ }
331
335
 
332
- .uni-indexed-list__menu--active {}
336
+ .uni-indexed-list__menu--active {
337
+ }
333
338
 
334
- .uni-indexed-list__menu-text--active {
335
- border-radius: 16px;
336
- width: 16px;
337
- height: 16px;
338
- line-height: 16px;
339
- background-color: #007aff;
340
- color: #fff;
341
- }
339
+ .uni-indexed-list__menu-text--active {
340
+ border-radius: 16px;
341
+ width: 16px;
342
+ height: 16px;
343
+ line-height: 16px;
344
+ background-color: #007aff;
345
+ color: #fff;
346
+ }
342
347
 
343
- .uni-indexed-list__alert-wrapper {
344
- position: absolute;
345
- left: 0;
346
- top: 0;
347
- right: 0;
348
- bottom: 0;
349
- /* #ifndef APP-NVUE */
350
- display: flex;
351
- /* #endif */
352
- flex-direction: row;
353
- align-items: center;
354
- justify-content: center;
355
- }
348
+ .uni-indexed-list__alert-wrapper {
349
+ position: absolute;
350
+ left: 0;
351
+ top: 0;
352
+ right: 0;
353
+ bottom: 0;
354
+ /* #ifndef APP-NVUE */
355
+ display: flex;
356
+ /* #endif */
357
+ flex-direction: row;
358
+ align-items: center;
359
+ justify-content: center;
360
+ }
356
361
 
357
- .uni-indexed-list__alert {
358
- width: 80px;
359
- height: 80px;
360
- border-radius: 80px;
361
- text-align: center;
362
- line-height: 80px;
363
- font-size: 35px;
364
- color: #fff;
365
- background-color: rgba(0, 0, 0, 0.5);
366
- }
362
+ .uni-indexed-list__alert {
363
+ width: 80px;
364
+ height: 80px;
365
+ border-radius: 80px;
366
+ text-align: center;
367
+ line-height: 80px;
368
+ font-size: 35px;
369
+ color: #fff;
370
+ background-color: rgba(0, 0, 0, 0.5);
371
+ }
367
372
  </style>