uview-plus 3.3.6 → 3.3.7
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/changelog.md +45 -0
- package/components/u-action-sheet/props.js +6 -1
- package/components/u-action-sheet/u-action-sheet.vue +4 -5
- package/components/u-cell/u-cell.vue +20 -1
- package/components/u-checkbox/u-checkbox.vue +28 -18
- package/components/u-code/u-code.vue +0 -5
- package/components/u-count-down/u-count-down.vue +0 -5
- package/components/u-form-item/u-form-item.vue +1 -1
- package/components/u-grid-item/u-grid-item.vue +0 -5
- package/components/u-index-list/props.js +6 -1
- package/components/u-index-list/u-index-list.vue +169 -42
- package/components/u-modal/u-modal.vue +3 -3
- package/components/u-notify/u-notify.vue +0 -5
- package/components/u-number-box/u-number-box.vue +1 -0
- package/components/u-parse/node/node.vue +1 -1
- package/components/u-parse/u-parse.vue +1 -7
- package/components/u-picker/u-picker.vue +1 -0
- package/components/u-popup/u-popup.vue +3 -1
- package/components/u-row-notice/u-row-notice.vue +1 -8
- package/components/u-scroll-list/nvue.js +1 -1
- package/components/u-scroll-list/u-scroll-list.vue +5 -2
- package/components/u-slider/props.js +45 -19
- package/components/u-slider/u-slider.vue +376 -7
- package/components/u-sticky/u-sticky.vue +0 -5
- package/components/u-swipe-action-item/nvue.js +0 -5
- package/components/u-tabs/u-tabs.vue +11 -3
- package/components/u-toast/u-toast.vue +10 -10
- package/components/u-upload/u-upload.vue +9 -4
- package/components/u-upload/utils.js +10 -4
- package/components/u-waterfall/u-waterfall.vue +1 -1
- package/libs/config/props/actionSheet.js +2 -1
- package/libs/config/props/indexList.js +2 -1
- package/libs/config/props/slider.js +3 -1
- package/libs/css/common.scss +1 -1
- package/libs/mixin/mixin.js +1 -7
- package/package.json +1 -1
- package/types/index.d.ts +155 -29
- package/components/u-slider/nvue - /345/211/257/346/234/254.js" +0 -180
package/changelog.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
## 3.3.7(2024-07-29)
|
|
2
|
+
feat: 支持IndexList组件支持在弹窗等场景下使用及联动优化
|
|
3
|
+
|
|
4
|
+
feat: popup组件支持v-model:show双向绑定
|
|
5
|
+
|
|
6
|
+
feat: 优化tabs的current双向绑定
|
|
7
|
+
|
|
8
|
+
fix: checkbox独立使用时checked赋初始值可以,但是手动切换时值没有做双向绑定! #455
|
|
9
|
+
|
|
10
|
+
feat: slider组件支持区间双滑块
|
|
11
|
+
|
|
12
|
+
fix: toast 支持自定义图标?可传入了决对路径的 icon也没有用 #409
|
|
13
|
+
|
|
14
|
+
feat: form-item校验失败时 增加class方便自定义显示错误的展示方式 #394
|
|
15
|
+
|
|
16
|
+
fix: up-cell的required配置不生效 #395
|
|
17
|
+
|
|
18
|
+
fix: 横向滚动组件,微信小程序编译后会有警告 #415
|
|
19
|
+
|
|
20
|
+
fix: u-picker内部对默认值defaultIndex的监听 #425
|
|
21
|
+
|
|
22
|
+
feat: toast 组件支持遮掩层穿透 #417
|
|
23
|
+
|
|
24
|
+
fix: 兼容vue的slot编译bug #423
|
|
25
|
+
|
|
26
|
+
fix: upload 微信小程序 点击预览视频报错 #424
|
|
27
|
+
|
|
28
|
+
fix: u-number-box 组件修改【integer, decimalLength, min, max 】props时没有触发绑定值更新 #429
|
|
29
|
+
|
|
30
|
+
feat: Tabs组件能否支持自定义插槽 #439
|
|
31
|
+
|
|
32
|
+
feat: ActionSheet 可以配置最大高度吗, 我当做select使用了。 #445
|
|
33
|
+
|
|
34
|
+
fix: cursor-pointer优化
|
|
35
|
+
|
|
36
|
+
feat: 新版slider组件兼容NVUE改造
|
|
37
|
+
|
|
38
|
+
feat: 新增slider组件手动实现以支持样式自定义
|
|
39
|
+
|
|
40
|
+
perf:补充TS声明提示信息
|
|
41
|
+
|
|
42
|
+
修复:ActionSheet 操作菜单cancelText属性为空DOM节点还存在并且可以点击问题
|
|
43
|
+
|
|
44
|
+
fix: 去除预留的beforeDestroy兼容容易在某些sdk下不识别条件编译
|
|
45
|
+
|
|
1
46
|
## 3.3.6(2024-07-23)
|
|
2
47
|
feat: u-album组件添加radius,shape参数,定义参考当前u-image参数
|
|
3
48
|
|
|
@@ -52,6 +52,11 @@ export const props = defineMixin({
|
|
|
52
52
|
round: {
|
|
53
53
|
type: [Boolean, String, Number],
|
|
54
54
|
default: () => defProps.actionSheet.round
|
|
55
|
-
}
|
|
55
|
+
},
|
|
56
|
+
// 选项区域最大高度
|
|
57
|
+
wrapMaxHeight: {
|
|
58
|
+
type: [String],
|
|
59
|
+
default: () => defProps.actionSheet.wrapMaxHeight
|
|
60
|
+
},
|
|
56
61
|
}
|
|
57
62
|
})
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
>{{description}}</text>
|
|
35
35
|
<slot>
|
|
36
36
|
<u-line v-if="description"></u-line>
|
|
37
|
-
<view class="u-action-sheet__item-wrap">
|
|
37
|
+
<scroll-view scroll-y class="u-action-sheet__item-wrap" :style="{maxHeight: wrapMaxHeight}">
|
|
38
38
|
<view :key="index" v-for="(item, index) in actions">
|
|
39
39
|
<!-- #ifdef MP -->
|
|
40
40
|
<button
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
<!-- #endif -->
|
|
86
86
|
<u-line v-if="index !== actions.length - 1"></u-line>
|
|
87
87
|
</view>
|
|
88
|
-
</view>
|
|
88
|
+
</scroll-view>
|
|
89
89
|
</slot>
|
|
90
90
|
<u-gap
|
|
91
91
|
bgColor="#eaeaec"
|
|
@@ -93,11 +93,10 @@
|
|
|
93
93
|
v-if="cancelText"
|
|
94
94
|
></u-gap>
|
|
95
95
|
<view class="u-action-sheet__item-wrap__item u-action-sheet__cancel"
|
|
96
|
-
hover-class="u-action-sheet--hover" @tap="cancel">
|
|
96
|
+
hover-class="u-action-sheet--hover" @tap="cancel" v-if="cancelText">
|
|
97
97
|
<text
|
|
98
98
|
@touchmove.stop.prevent
|
|
99
99
|
:hover-stay-time="150"
|
|
100
|
-
v-if="cancelText"
|
|
101
100
|
class="u-action-sheet__cancel-text"
|
|
102
101
|
>{{cancelText}}</text>
|
|
103
102
|
</view>
|
|
@@ -271,7 +270,7 @@
|
|
|
271
270
|
font-size: $u-action-sheet-cancel-text-font-size;
|
|
272
271
|
color: $u-action-sheet-cancel-text-color;
|
|
273
272
|
text-align: center;
|
|
274
|
-
padding: $u-action-sheet-cancel-text-font-size;
|
|
273
|
+
// padding: $u-action-sheet-cancel-text-font-size;
|
|
275
274
|
}
|
|
276
275
|
|
|
277
276
|
&--hover {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<slot name="title" v-if="$slots.title || !title">
|
|
17
17
|
</slot>
|
|
18
18
|
<text v-else class="u-cell__title-text" :style="[titleTextStyle]"
|
|
19
|
-
:class="[disabled && 'u-cell--disabled', size === 'large' && 'u-cell__title-text--large']">{{ title }}</text>
|
|
19
|
+
:class="[required && 'u-cell--required', disabled && 'u-cell--disabled', size === 'large' && 'u-cell__title-text--large']">{{ title }}</text>
|
|
20
20
|
<slot name="label">
|
|
21
21
|
<text class="u-cell__label" v-if="label"
|
|
22
22
|
:class="[disabled && 'u-cell--disabled', size === 'large' && 'u-cell__label--large']">{{ label }}</text>
|
|
@@ -231,6 +231,25 @@
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
&--required {
|
|
235
|
+
/* #ifndef APP-NVUE */
|
|
236
|
+
overflow: visible;
|
|
237
|
+
/* #endif */
|
|
238
|
+
@include flex;
|
|
239
|
+
align-items: center;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
&--required:before {
|
|
243
|
+
position: absolute;
|
|
244
|
+
/* #ifndef APP-NVUE */
|
|
245
|
+
content: '*';
|
|
246
|
+
/* #endif */
|
|
247
|
+
left: -8px;
|
|
248
|
+
margin-top: 4rpx;
|
|
249
|
+
font-size: 14px;
|
|
250
|
+
color: $u-error;
|
|
251
|
+
}
|
|
252
|
+
|
|
234
253
|
&--clickable {
|
|
235
254
|
background-color: $u-cell-clickable-color;
|
|
236
255
|
}
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
mounted() {
|
|
190
190
|
this.init()
|
|
191
191
|
},
|
|
192
|
-
emits: ["change"],
|
|
192
|
+
emits: ["change", "update:checked"],
|
|
193
193
|
methods: {
|
|
194
194
|
init() {
|
|
195
195
|
if (!this.usedAlone) {
|
|
@@ -198,21 +198,25 @@
|
|
|
198
198
|
if (!this.parent) {
|
|
199
199
|
error('u-checkbox必须搭配u-checkbox-group组件使用')
|
|
200
200
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
this.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
201
|
+
// #ifdef VUE2
|
|
202
|
+
const value = this.parentData.value
|
|
203
|
+
// #endif
|
|
204
|
+
// #ifdef VUE3
|
|
205
|
+
const value = this.parentData.modelValue
|
|
206
|
+
// #endif
|
|
207
|
+
// 设置初始化时,是否默认选中的状态,父组件u-checkbox-group的value可能是array,所以额外判断
|
|
208
|
+
if (this.checked) {
|
|
209
|
+
this.isChecked = true
|
|
210
|
+
} else if (!this.usedAlone && test.array(value)) {
|
|
211
|
+
// 查找数组是是否存在this.name元素值
|
|
212
|
+
this.isChecked = value.some(item => {
|
|
213
|
+
return item === this.name
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
if (this.checked) {
|
|
218
|
+
this.isChecked = true
|
|
219
|
+
}
|
|
216
220
|
}
|
|
217
221
|
},
|
|
218
222
|
updateParentData() {
|
|
@@ -244,6 +248,10 @@
|
|
|
244
248
|
},
|
|
245
249
|
emitEvent() {
|
|
246
250
|
this.$emit('change', this.isChecked)
|
|
251
|
+
// 双向绑定
|
|
252
|
+
if (this.usedAlone) {
|
|
253
|
+
this.$emit('update:checked', this.isChecked)
|
|
254
|
+
}
|
|
247
255
|
// 尝试调用u-form的验证方法,进行一定延迟,否则微信小程序更新可能会不及时
|
|
248
256
|
this.$nextTick(() => {
|
|
249
257
|
formValidate(this, 'change')
|
|
@@ -262,8 +270,10 @@
|
|
|
262
270
|
}
|
|
263
271
|
},
|
|
264
272
|
watch:{
|
|
265
|
-
checked(){
|
|
266
|
-
this.isChecked
|
|
273
|
+
checked(newValue, oldValue){
|
|
274
|
+
if (newValue !== this.isChecked) {
|
|
275
|
+
this.isChecked = newValue
|
|
276
|
+
}
|
|
267
277
|
}
|
|
268
278
|
}
|
|
269
279
|
}
|
|
@@ -119,12 +119,7 @@
|
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
// 组件销毁的时候,清除定时器,否则定时器会继续存在,系统不会自动清除
|
|
122
|
-
// #ifdef VUE2
|
|
123
|
-
beforeDestroy() {
|
|
124
|
-
// #endif
|
|
125
|
-
// #ifdef VUE3
|
|
126
122
|
beforeUnmount() {
|
|
127
|
-
// #endif
|
|
128
123
|
this.setTimeToStorage()
|
|
129
124
|
clearTimeout(this.timer)
|
|
130
125
|
this.timer = null
|
|
@@ -26,6 +26,11 @@ export const props = defineMixin({
|
|
|
26
26
|
customNavHeight: {
|
|
27
27
|
type: [String, Number],
|
|
28
28
|
default: () => defProps.indexList.customNavHeight
|
|
29
|
-
}
|
|
29
|
+
},
|
|
30
|
+
// 是否开启底部安全距离适配
|
|
31
|
+
safeBottomFix: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: () => defProps.indexList.safeBottomFix
|
|
34
|
+
},
|
|
30
35
|
}
|
|
31
36
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="u-index-list">
|
|
2
|
+
<view ref="u-index-list" class="u-index-list">
|
|
3
3
|
<!-- #ifdef APP-NVUE -->
|
|
4
4
|
<list
|
|
5
5
|
:scrollTop="scrollTop"
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
maxHeight: addUnit(scrollViewHeight)
|
|
10
10
|
}"
|
|
11
11
|
@scroll="scrollHandler"
|
|
12
|
-
ref="
|
|
12
|
+
ref="u-index-list__scroll-view"
|
|
13
|
+
class="u-index-list__scroll-view"
|
|
13
14
|
>
|
|
14
15
|
<cell
|
|
15
16
|
v-if="$slots.header"
|
|
@@ -33,13 +34,14 @@
|
|
|
33
34
|
}"
|
|
34
35
|
scroll-y
|
|
35
36
|
@scroll="scrollHandler"
|
|
36
|
-
ref="
|
|
37
|
+
ref="u-index-list__scroll-view"
|
|
38
|
+
class="u-index-list__scroll-view"
|
|
37
39
|
>
|
|
38
|
-
<view v-if="$slots.header">
|
|
40
|
+
<view class="u-index-list__header" v-if="$slots.header">
|
|
39
41
|
<slot name="header" />
|
|
40
42
|
</view>
|
|
41
43
|
<slot />
|
|
42
|
-
<view v-if="$slots.footer">
|
|
44
|
+
<view class="u-index-list__footer" v-if="$slots.footer">
|
|
43
45
|
<slot name="footer" />
|
|
44
46
|
</view>
|
|
45
47
|
</scroll-view>
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
<view
|
|
48
50
|
class="u-index-list__letter"
|
|
49
51
|
ref="u-index-list__letter"
|
|
50
|
-
:style="{
|
|
52
|
+
:style="{top: addUnit(letterInfo.top) , transform: 'translateY(-50%)'}"
|
|
51
53
|
@touchstart.prevent="touchStart"
|
|
52
54
|
@touchmove.prevent="touchMove"
|
|
53
55
|
@touchend.prevent="touchEnd"
|
|
@@ -71,10 +73,10 @@
|
|
|
71
73
|
mode="fade"
|
|
72
74
|
:show="touching"
|
|
73
75
|
:customStyle="{
|
|
74
|
-
position: '
|
|
76
|
+
position: 'absolute',
|
|
75
77
|
right: '50px',
|
|
76
|
-
top: addUnit(indicatorTop),
|
|
77
|
-
zIndex:
|
|
78
|
+
top: addUnit(indicatorTop, 'px'),
|
|
79
|
+
zIndex: 3
|
|
78
80
|
}"
|
|
79
81
|
>
|
|
80
82
|
<view
|
|
@@ -104,6 +106,7 @@
|
|
|
104
106
|
import { mpMixin } from '../../libs/mixin/mpMixin';
|
|
105
107
|
import { mixin } from '../../libs/mixin/mixin';
|
|
106
108
|
import { addUnit, sys, sleep, getPx } from '../../libs/function/index';
|
|
109
|
+
|
|
107
110
|
// #ifdef APP-NVUE
|
|
108
111
|
// 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度
|
|
109
112
|
const dom = uni.requireNativePlugin('dom')
|
|
@@ -152,6 +155,8 @@
|
|
|
152
155
|
sys: sys(),
|
|
153
156
|
scrolling: false,
|
|
154
157
|
scrollIntoView: '',
|
|
158
|
+
pageY: 0,
|
|
159
|
+
topOffset: 0
|
|
155
160
|
}
|
|
156
161
|
},
|
|
157
162
|
computed: {
|
|
@@ -163,17 +168,18 @@
|
|
|
163
168
|
indicatorTop() {
|
|
164
169
|
const {
|
|
165
170
|
top,
|
|
171
|
+
height,
|
|
166
172
|
itemHeight
|
|
167
173
|
} = this.letterInfo
|
|
168
|
-
return Math.floor(top + itemHeight * this.activeIndex + itemHeight
|
|
174
|
+
return Math.floor(top - (height / 2) + itemHeight * this.activeIndex + itemHeight - 70 / 2)
|
|
169
175
|
}
|
|
170
176
|
},
|
|
171
177
|
watch: {
|
|
172
178
|
// 监听字母索引的变化,重新设置尺寸
|
|
173
179
|
uIndexList: {
|
|
174
|
-
immediate:
|
|
180
|
+
immediate: false,
|
|
175
181
|
handler() {
|
|
176
|
-
sleep().then(() => {
|
|
182
|
+
sleep(30).then(() => {
|
|
177
183
|
this.setIndexListLetterInfo()
|
|
178
184
|
})
|
|
179
185
|
}
|
|
@@ -182,10 +188,12 @@
|
|
|
182
188
|
created() {
|
|
183
189
|
this.children = []
|
|
184
190
|
this.anchors = []
|
|
185
|
-
this.init()
|
|
186
191
|
},
|
|
187
192
|
mounted() {
|
|
188
|
-
this.
|
|
193
|
+
this.init()
|
|
194
|
+
sleep(50).then(() => {
|
|
195
|
+
this.setIndexListLetterInfo()
|
|
196
|
+
})
|
|
189
197
|
},
|
|
190
198
|
methods: {
|
|
191
199
|
addUnit,
|
|
@@ -194,19 +202,32 @@
|
|
|
194
202
|
//减去this.customNavHeight,并将this.scrollViewHeight设置为maxHeight
|
|
195
203
|
//解决当u-index-list组件放在tabbar页面时,scroll-view内容较少时,还能滚动
|
|
196
204
|
let customNavHeight = getPx(this.customNavHeight)
|
|
197
|
-
this.scrollViewHeight = this.sys.windowHeight - customNavHeight
|
|
205
|
+
// this.scrollViewHeight = this.sys.windowHeight - customNavHeight
|
|
206
|
+
this.getIndexListRect().then(async sizeScroll => {
|
|
207
|
+
this.scrollViewHeight = sizeScroll.height ? sizeScroll.height : this.sys.windowHeight - customNavHeight
|
|
208
|
+
this.topOffset = this.sys.windowHeight - this.scrollViewHeight
|
|
209
|
+
// console.log('scrollViewHeight', this.scrollViewHeight)
|
|
210
|
+
// console.log('topOffset', this.topOffset)
|
|
211
|
+
})
|
|
198
212
|
},
|
|
199
213
|
// 索引列表被触摸
|
|
200
214
|
touchStart(e) {
|
|
201
215
|
// 获取触摸点信息
|
|
202
|
-
const
|
|
203
|
-
if (!
|
|
216
|
+
const touchStartData = e.changedTouches[0]
|
|
217
|
+
if (!touchStartData) return
|
|
204
218
|
this.touching = true
|
|
205
219
|
const {
|
|
206
|
-
pageY
|
|
207
|
-
|
|
220
|
+
pageY,
|
|
221
|
+
screenY
|
|
222
|
+
} = touchStartData
|
|
208
223
|
// 根据当前触摸点的坐标,获取当前触摸的为第几个字母
|
|
224
|
+
// #ifdef APP-NVUE
|
|
225
|
+
// 使用screenY要减去导航栏44和状态栏24高度
|
|
226
|
+
const currentIndex = this.getIndexListLetter(screenY - 68)
|
|
227
|
+
// #endif
|
|
228
|
+
// #ifndef APP-NVUE
|
|
209
229
|
const currentIndex = this.getIndexListLetter(pageY)
|
|
230
|
+
// #endif
|
|
210
231
|
this.setValueForTouch(currentIndex)
|
|
211
232
|
},
|
|
212
233
|
// 索引字母列表被触摸滑动中
|
|
@@ -220,9 +241,17 @@
|
|
|
220
241
|
this.touching = true
|
|
221
242
|
}
|
|
222
243
|
const {
|
|
223
|
-
pageY
|
|
244
|
+
pageY,
|
|
245
|
+
screenY
|
|
224
246
|
} = touchMove
|
|
247
|
+
// #ifdef APP-NVUE
|
|
248
|
+
// 使用screenY要减去导航栏44和状态栏24高度
|
|
249
|
+
const currentIndex = this.getIndexListLetter(screenY - 68)
|
|
250
|
+
// #endif
|
|
251
|
+
// #ifndef APP-NVUE
|
|
225
252
|
const currentIndex = this.getIndexListLetter(pageY)
|
|
253
|
+
// #endif
|
|
254
|
+
|
|
226
255
|
this.setValueForTouch(currentIndex)
|
|
227
256
|
},
|
|
228
257
|
// 触摸结束
|
|
@@ -250,9 +279,44 @@
|
|
|
250
279
|
// #endif
|
|
251
280
|
})
|
|
252
281
|
},
|
|
282
|
+
getIndexListScrollViewRect() {
|
|
283
|
+
return new Promise(resolve => {
|
|
284
|
+
// 延时一定时间,以获取dom尺寸
|
|
285
|
+
// #ifndef APP-NVUE
|
|
286
|
+
this.$uGetRect('.u-index-list__scroll-view').then(size => {
|
|
287
|
+
resolve(size)
|
|
288
|
+
})
|
|
289
|
+
// #endif
|
|
290
|
+
|
|
291
|
+
// #ifdef APP-NVUE
|
|
292
|
+
const ref = this.$refs['u-index-list__scroll-view']
|
|
293
|
+
dom.getComponentRect(ref, res => {
|
|
294
|
+
resolve(res.size)
|
|
295
|
+
})
|
|
296
|
+
// #endif
|
|
297
|
+
})
|
|
298
|
+
},
|
|
299
|
+
getIndexListRect() {
|
|
300
|
+
return new Promise(resolve => {
|
|
301
|
+
// 延时一定时间,以获取dom尺寸
|
|
302
|
+
// #ifndef APP-NVUE
|
|
303
|
+
this.$uGetRect('.u-index-list').then(size => {
|
|
304
|
+
resolve(size)
|
|
305
|
+
})
|
|
306
|
+
// #endif
|
|
307
|
+
|
|
308
|
+
// #ifdef APP-NVUE
|
|
309
|
+
const ref = this.$refs['u-index-list']
|
|
310
|
+
dom.getComponentRect(ref, res => {
|
|
311
|
+
resolve(res.size)
|
|
312
|
+
})
|
|
313
|
+
// #endif
|
|
314
|
+
})
|
|
315
|
+
},
|
|
253
316
|
// 设置indexList索引的尺寸信息
|
|
254
317
|
setIndexListLetterInfo() {
|
|
255
318
|
this.getIndexListLetterRect().then(size => {
|
|
319
|
+
// console.log('getIndexListLetterRect', size)
|
|
256
320
|
const {
|
|
257
321
|
height
|
|
258
322
|
} = size
|
|
@@ -271,38 +335,56 @@
|
|
|
271
335
|
} else {
|
|
272
336
|
customNavHeight = getPx(this.customNavHeight)
|
|
273
337
|
}
|
|
274
|
-
this.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
338
|
+
this.getIndexListScrollViewRect().then(sizeScroll => {
|
|
339
|
+
// console.log('sizeScroll', sizeScroll)
|
|
340
|
+
this.letterInfo = {
|
|
341
|
+
height,
|
|
342
|
+
// 为了让字母列表对屏幕绝对居中,让其对导航栏进行修正,也即往上偏移导航栏的一半高度
|
|
343
|
+
top: sizeScroll.height / 2,
|
|
344
|
+
// top: (this.scrollViewHeight - height) / 2 + customNavHeight / 2,
|
|
345
|
+
itemHeight: Math.floor(height / this.uIndexList.length)
|
|
346
|
+
}
|
|
347
|
+
})
|
|
280
348
|
})
|
|
281
349
|
},
|
|
282
350
|
// 获取当前被触摸的索引字母
|
|
283
351
|
getIndexListLetter(pageY) {
|
|
284
|
-
|
|
352
|
+
this.pageY = pageY
|
|
353
|
+
let {
|
|
285
354
|
top,
|
|
286
355
|
height,
|
|
287
356
|
itemHeight
|
|
288
357
|
} = this.letterInfo
|
|
358
|
+
let index = this.currentIndex;
|
|
289
359
|
// 对H5的pageY进行修正,这是由于uni-app自作多情在H5中将触摸点的坐标跟H5的导航栏结合导致的问题
|
|
290
360
|
// #ifdef H5
|
|
291
|
-
pageY += sys().windowTop
|
|
361
|
+
// pageY += sys().windowTop
|
|
292
362
|
// #endif
|
|
293
363
|
// 对第一和最后一个字母做边界处理,因为用户可能在字母列表上触摸到两端的尽头后依然继续滑动
|
|
364
|
+
// console.log('top1', top)
|
|
365
|
+
// console.log('height', height)
|
|
366
|
+
top = top - (height / 2) // 减去transfrom的translateY值导致的高度
|
|
367
|
+
pageY = pageY - this.topOffset
|
|
368
|
+
// if (this.safeBottomFix) {
|
|
369
|
+
// pageY = pageY + 34
|
|
370
|
+
// }
|
|
371
|
+
// console.log('topOffset', this.topOffset)
|
|
372
|
+
// console.log('pageY', pageY)
|
|
373
|
+
// console.log('top2', top)
|
|
294
374
|
if (pageY < top) {
|
|
295
|
-
|
|
375
|
+
index = 0
|
|
296
376
|
} else if (pageY >= top + height) {
|
|
297
377
|
// 如果超出了,取最后一个字母
|
|
298
|
-
|
|
378
|
+
index = this.uIndexList.length - 1
|
|
299
379
|
} else {
|
|
300
380
|
// 将触摸点的Y轴偏移值,减去索引字母的top值,除以每个字母的高度,即可得到当前触摸点落在哪个字母上
|
|
301
|
-
|
|
381
|
+
index = Math.floor((pageY - top) / itemHeight)
|
|
302
382
|
}
|
|
383
|
+
// console.log(index)
|
|
384
|
+
return index
|
|
303
385
|
},
|
|
304
386
|
// 设置各项由触摸而导致变化的值
|
|
305
|
-
setValueForTouch(currentIndex) {
|
|
387
|
+
async setValueForTouch(currentIndex) {
|
|
306
388
|
// 如果偏移量太小,前后得出的会是同一个索引字母,为了防抖,进行返回
|
|
307
389
|
if (currentIndex === this.activeIndex) return
|
|
308
390
|
this.activeIndex = currentIndex
|
|
@@ -310,14 +392,39 @@
|
|
|
310
392
|
// 在非nvue中,由于anchor和item都在u-index-item中,所以需要对index-item进行偏移
|
|
311
393
|
this.scrollIntoView = `u-index-item-${this.uIndexList[currentIndex].charCodeAt(0)}`
|
|
312
394
|
// #endif
|
|
395
|
+
|
|
313
396
|
// #ifdef MP-WEIXIN
|
|
314
397
|
// 微信小程序下,scroll-view的scroll-into-view属性无法对slot中的内容的id生效,只能通过设置scrollTop的形式去移动滚动条
|
|
315
398
|
const customNavHeight = this.customNavHeight
|
|
316
|
-
|
|
399
|
+
|
|
400
|
+
// 获取header slot的尺寸信息
|
|
401
|
+
const header = await this.getHeaderRect()
|
|
402
|
+
// item的top值,在nvue下,模拟出的anchor的top,类似非nvue下的index-item的top
|
|
403
|
+
let top = header.height
|
|
404
|
+
console.log(top)
|
|
405
|
+
const anchors = this.anchors
|
|
406
|
+
// 由于list组件无法获取cell的top值,这里通过header slot和各个item之间的height,模拟出类似非nvue下的位置信息
|
|
407
|
+
let children = this.children.map((item, index) => {
|
|
408
|
+
const child = {
|
|
409
|
+
height: item.height,
|
|
410
|
+
top: top
|
|
411
|
+
}
|
|
412
|
+
// 进行累加,给下一个item提供计算依据
|
|
413
|
+
top = top + item.height
|
|
414
|
+
// #ifdef APP-NVUE
|
|
415
|
+
// 只有nvue下,需要将锚点的高度也累加,非nvue下锚点高度是包含在index-item中的。
|
|
416
|
+
top = top + anchors[index].height
|
|
417
|
+
// #endif
|
|
418
|
+
return child
|
|
419
|
+
})
|
|
420
|
+
// console.log('this.children[currentIndex].top', children[currentIndex].top)
|
|
421
|
+
this.scrollTop = children[currentIndex].top - getPx(customNavHeight)
|
|
317
422
|
// #endif
|
|
423
|
+
|
|
318
424
|
// #ifdef APP-NVUE
|
|
319
425
|
// 在nvue中,由于cell和header为同级元素,所以实际是需要对header(anchor)进行偏移
|
|
320
426
|
const anchor = `u-index-anchor-${this.uIndexList[currentIndex]}`
|
|
427
|
+
console.log(anchor)
|
|
321
428
|
dom.scrollToElement(this.anchors[currentIndex].$refs[anchor], {
|
|
322
429
|
offset: 0,
|
|
323
430
|
animated: false
|
|
@@ -327,9 +434,18 @@
|
|
|
327
434
|
getHeaderRect() {
|
|
328
435
|
// 获取header slot的高度,因为list组件中获取元素的尺寸是没有top值的
|
|
329
436
|
return new Promise(resolve => {
|
|
437
|
+
// #ifndef APP-NVUE
|
|
438
|
+
this.$uGetRect('.u-index-list__header').then(size => {
|
|
439
|
+
resolve(size)
|
|
440
|
+
})
|
|
441
|
+
// #endif
|
|
442
|
+
|
|
443
|
+
// #ifdef APP-NVUE
|
|
330
444
|
dom.getComponentRect(this.$refs.header, res => {
|
|
331
445
|
resolve(res.size)
|
|
332
446
|
})
|
|
447
|
+
// #endif
|
|
448
|
+
|
|
333
449
|
})
|
|
334
450
|
},
|
|
335
451
|
// scroll-view的滚动事件
|
|
@@ -343,36 +459,45 @@
|
|
|
343
459
|
let scrollTop = 0
|
|
344
460
|
const len = this.children.length
|
|
345
461
|
let children = this.children
|
|
346
|
-
const anchors = this.anchors
|
|
347
462
|
// #ifdef APP-NVUE
|
|
348
463
|
// nvue下获取的滚动条偏移为负数,需要转为正数
|
|
349
|
-
|
|
464
|
+
let sys = uni.getSystemInfoSync()
|
|
465
|
+
scrollTop = Math.abs(e.contentOffset.y) / 10
|
|
466
|
+
// console.log('native', e)
|
|
467
|
+
// #endif
|
|
468
|
+
|
|
350
469
|
// 获取header slot的尺寸信息
|
|
351
470
|
const header = await this.getHeaderRect()
|
|
352
471
|
// item的top值,在nvue下,模拟出的anchor的top,类似非nvue下的index-item的top
|
|
353
472
|
let top = header.height
|
|
473
|
+
const anchors = this.anchors
|
|
354
474
|
// 由于list组件无法获取cell的top值,这里通过header slot和各个item之间的height,模拟出类似非nvue下的位置信息
|
|
355
475
|
children = this.children.map((item, index) => {
|
|
356
476
|
const child = {
|
|
357
477
|
height: item.height,
|
|
358
|
-
top
|
|
478
|
+
top: top
|
|
359
479
|
}
|
|
360
480
|
// 进行累加,给下一个item提供计算依据
|
|
361
|
-
top
|
|
481
|
+
top = top + item.height
|
|
482
|
+
// #ifdef APP-NVUE
|
|
483
|
+
// 只有nvue下,需要将锚点的高度也累加,非nvue下锚点高度是包含在index-item中的。
|
|
484
|
+
top = top + anchors[index].height
|
|
485
|
+
// #endif
|
|
362
486
|
return child
|
|
363
487
|
})
|
|
364
|
-
|
|
488
|
+
|
|
365
489
|
// #ifndef APP-NVUE
|
|
366
490
|
// 非nvue通过detail获取滚动条位移
|
|
367
491
|
scrollTop = e.detail.scrollTop
|
|
492
|
+
// console.log('scrollTop', scrollTop, this.customNavHeight)
|
|
368
493
|
// #endif
|
|
369
|
-
|
|
494
|
+
// 在弹窗中需要加上弹窗距离顶部的高度topOffset
|
|
495
|
+
scrollTop = scrollTop + getPx(this.customNavHeight)
|
|
370
496
|
for (let i = 0; i < len; i++) {
|
|
371
497
|
const item = children[i],
|
|
372
498
|
nextItem = children[i + 1]
|
|
373
499
|
// 如果滚动条高度小于第一个item的top值,此时无需设置任意字母为高亮
|
|
374
|
-
if (scrollTop <= children[0].top || scrollTop >= children[len - 1].top + children[len -
|
|
375
|
-
1].height) {
|
|
500
|
+
if (scrollTop <= children[0].top || scrollTop >= children[len - 1].top + children[len - 1].height) {
|
|
376
501
|
this.activeIndex = -1
|
|
377
502
|
break
|
|
378
503
|
} else if (!nextItem) {
|
|
@@ -395,11 +520,13 @@
|
|
|
395
520
|
.u-index-list {
|
|
396
521
|
|
|
397
522
|
&__letter {
|
|
398
|
-
position:
|
|
523
|
+
position: absolute;
|
|
524
|
+
margin: auto;
|
|
399
525
|
right: 0;
|
|
400
526
|
text-align: center;
|
|
401
527
|
z-index: 3;
|
|
402
528
|
padding: 0 6px;
|
|
529
|
+
width: 30px;
|
|
403
530
|
|
|
404
531
|
&__item {
|
|
405
532
|
width: 16px;
|