@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,266 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view class="uni-collapse-item">
|
|
3
2
|
<!-- onClick(!isOpen) -->
|
|
4
3
|
<view
|
|
5
4
|
@click="onClick(!isOpen)"
|
|
6
5
|
class="uni-collapse-item__title"
|
|
7
6
|
:class="{ 'is-open': isOpen && titleBorder === 'auto', 'uni-collapse-item-border': titleBorder !== 'none' }"
|
|
8
7
|
>
|
|
9
8
|
<view class="uni-collapse-item__title-wrap">
|
|
10
9
|
<slot name="title">
|
|
11
10
|
<view class="uni-collapse-item__title-box" :class="{ 'is-disabled': disabled }">
|
|
12
11
|
<image v-if="thumb" :src="thumb" class="uni-collapse-item__title-img" />
|
|
13
12
|
<text class="uni-collapse-item__title-text">{{ title }}</text>
|
|
14
13
|
</view>
|
|
15
14
|
</slot>
|
|
16
15
|
</view>
|
|
17
16
|
<view
|
|
18
17
|
v-if="showArrow"
|
|
19
18
|
:class="{ 'uni-collapse-item__title-arrow-active': isOpen, 'uni-collapse-item--animation': showAnimation === true }"
|
|
20
19
|
class="uni-collapse-item__title-arrow"
|
|
21
20
|
>
|
|
22
21
|
<uni-icons :color="disabled ? '#ddd' : '#bbb'" size="14" type="bottom" />
|
|
23
22
|
</view>
|
|
24
23
|
</view>
|
|
25
24
|
<view
|
|
26
25
|
class="uni-collapse-item__wrap"
|
|
27
26
|
:class="{ 'is--transition': showAnimation }"
|
|
28
27
|
:style="{ height: (isOpen ? height : 0) + 'px' }"
|
|
29
28
|
>
|
|
30
29
|
<view
|
|
31
30
|
:id="elId"
|
|
32
31
|
ref="collapse--hook"
|
|
33
32
|
class="uni-collapse-item__wrap-content"
|
|
34
33
|
:class="{ open: isheight, 'uni-collapse-item--border': border && isOpen }"
|
|
35
34
|
>
|
|
36
35
|
<slot></slot>
|
|
37
36
|
</view>
|
|
38
37
|
</view>
|
|
39
38
|
</view>
|
|
40
39
|
* CollapseItem 折叠面板子组件
|
|
41
40
|
* @description 折叠面板子组件
|
|
42
41
|
* @property {String} title 标题文字
|
|
43
42
|
* @property {String} thumb 标题左侧缩略图
|
|
44
43
|
* @property {String} name 唯一标志符
|
|
45
44
|
* @property {Boolean} open = [true|false] 是否展开组件
|
|
46
45
|
* @property {Boolean} titleBorder = [true|false] 是否显示标题分隔线
|
|
47
46
|
* @property {Boolean} border = [true|false] 是否显示分隔线
|
|
48
47
|
* @property {Boolean} disabled = [true|false] 是否展开面板
|
|
49
48
|
* @property {Boolean} showAnimation = [true|false] 开启动画
|
|
50
49
|
* @property {Boolean} showArrow = [true|false] 是否显示右侧箭头
|
|
51
50
|
*/
|
|
52
51
|
name: 'uniCollapseItem',
|
|
53
52
|
props: {
|
|
54
53
|
// 列表标题
|
|
55
54
|
title: {
|
|
56
55
|
type: String,
|
|
57
56
|
default: ''
|
|
58
57
|
},
|
|
59
58
|
name: {
|
|
60
59
|
type: [Number, String],
|
|
61
60
|
default: ''
|
|
62
61
|
},
|
|
63
62
|
// 是否禁用
|
|
64
63
|
disabled: {
|
|
65
64
|
type: Boolean,
|
|
66
65
|
default: false
|
|
67
66
|
},
|
|
68
67
|
// #ifdef APP-PLUS
|
|
69
68
|
// 是否显示动画,app 端默认不开启动画,卡顿严重
|
|
70
69
|
showAnimation: {
|
|
71
70
|
type: Boolean,
|
|
72
71
|
default: false
|
|
73
72
|
},
|
|
74
73
|
// #endif
|
|
75
74
|
// #ifndef APP-PLUS
|
|
76
75
|
// 是否显示动画
|
|
77
76
|
showAnimation: {
|
|
78
77
|
type: Boolean,
|
|
79
78
|
default: true
|
|
80
79
|
},
|
|
81
80
|
// #endif
|
|
82
81
|
// 是否展开
|
|
83
82
|
open: {
|
|
84
83
|
type: Boolean,
|
|
85
84
|
default: false
|
|
86
85
|
},
|
|
87
86
|
// 缩略图
|
|
88
87
|
thumb: {
|
|
89
88
|
type: String,
|
|
90
89
|
default: ''
|
|
91
90
|
},
|
|
92
91
|
// 标题分隔线显示类型
|
|
93
92
|
titleBorder: {
|
|
94
93
|
type: String,
|
|
95
94
|
default: 'auto'
|
|
96
95
|
},
|
|
97
96
|
border: {
|
|
98
97
|
type: Boolean,
|
|
99
98
|
default: true
|
|
100
99
|
},
|
|
101
100
|
showArrow: {
|
|
102
101
|
type: Boolean,
|
|
103
102
|
default: true
|
|
104
103
|
}
|
|
105
104
|
},
|
|
106
105
|
data() {
|
|
107
106
|
// TODO 随机生生元素ID,解决百度小程序获取同一个元素位置信息的bug
|
|
108
107
|
const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`;
|
|
109
108
|
return {
|
|
110
109
|
isOpen: false,
|
|
111
110
|
isheight: null,
|
|
112
111
|
height: 0,
|
|
113
112
|
elId,
|
|
114
113
|
nameSync: 0
|
|
115
114
|
};
|
|
116
115
|
},
|
|
117
116
|
watch: {
|
|
118
117
|
open(val) {
|
|
119
118
|
this.isOpen = val;
|
|
120
119
|
this.onClick(val, 'init');
|
|
121
120
|
}
|
|
122
121
|
},
|
|
123
122
|
updated(e) {
|
|
124
123
|
this.$nextTick(() => {
|
|
125
124
|
this.init(true);
|
|
126
125
|
});
|
|
127
126
|
},
|
|
128
127
|
created() {
|
|
129
128
|
this.collapse = this.getCollapse();
|
|
130
129
|
this.oldHeight = 0;
|
|
131
130
|
this.onClick(this.open, 'init');
|
|
132
131
|
},
|
|
133
132
|
// #ifndef VUE3
|
|
134
133
|
// TODO vue2
|
|
135
134
|
destroyed() {
|
|
136
135
|
if (this.__isUnmounted) return;
|
|
137
136
|
this.uninstall();
|
|
138
137
|
},
|
|
139
138
|
// #endif
|
|
140
139
|
// #ifdef VUE3
|
|
141
140
|
// TODO vue3
|
|
142
141
|
unmounted() {
|
|
143
142
|
this.__isUnmounted = true;
|
|
144
143
|
this.uninstall();
|
|
145
144
|
},
|
|
146
145
|
// #endif
|
|
147
146
|
mounted() {
|
|
148
147
|
if (!this.collapse) return;
|
|
149
148
|
if (this.name !== '') {
|
|
150
149
|
this.nameSync = this.name;
|
|
151
150
|
} else {
|
|
152
151
|
this.nameSync = this.collapse.childrens.length + '';
|
|
153
152
|
}
|
|
154
153
|
if (this.collapse.names.indexOf(this.nameSync) === -1) {
|
|
155
154
|
this.collapse.names.push(this.nameSync);
|
|
156
155
|
} else {
|
|
157
156
|
console.warn(`name 值 ${this.nameSync} 重复`);
|
|
158
157
|
}
|
|
159
158
|
if (this.collapse.childrens.indexOf(this) === -1) {
|
|
160
159
|
this.collapse.childrens.push(this);
|
|
161
160
|
}
|
|
162
161
|
this.init();
|
|
163
162
|
},
|
|
164
163
|
methods: {
|
|
165
164
|
init(type) {
|
|
166
165
|
// #ifndef APP-NVUE
|
|
167
166
|
this.getCollapseHeight(type);
|
|
168
167
|
// #endif
|
|
169
168
|
// #ifdef APP-NVUE
|
|
170
169
|
this.getNvueHwight(type);
|
|
171
170
|
// #endif
|
|
172
171
|
},
|
|
173
172
|
uninstall() {
|
|
174
173
|
if (this.collapse) {
|
|
175
174
|
this.collapse.childrens.forEach((item, index) => {
|
|
176
175
|
if (item === this) {
|
|
177
176
|
this.collapse.childrens.splice(index, 1);
|
|
178
177
|
}
|
|
179
178
|
});
|
|
180
179
|
this.collapse.names.forEach((item, index) => {
|
|
181
180
|
if (item === this.nameSync) {
|
|
182
181
|
this.collapse.names.splice(index, 1);
|
|
183
182
|
}
|
|
184
183
|
});
|
|
185
184
|
}
|
|
186
185
|
},
|
|
187
186
|
onClick(isOpen, type) {
|
|
188
187
|
if (this.disabled) return;
|
|
189
188
|
this.isOpen = isOpen;
|
|
190
189
|
if (this.isOpen && this.collapse) {
|
|
191
190
|
this.collapse.setAccordion(this);
|
|
192
191
|
}
|
|
193
192
|
if (type !== 'init') {
|
|
194
193
|
this.collapse.onChange(isOpen, this);
|
|
195
194
|
}
|
|
196
195
|
},
|
|
197
196
|
getCollapseHeight(type, index = 0) {
|
|
198
197
|
const views = uni.createSelectorQuery().in(this);
|
|
199
198
|
views
|
|
200
199
|
.select(`#${this.elId}`)
|
|
201
200
|
.fields(
|
|
202
201
|
{
|
|
203
202
|
size: true
|
|
204
203
|
},
|
|
205
204
|
(data) => {
|
|
206
205
|
// TODO 百度中可能获取不到节点信息 ,需要循环获取
|
|
207
206
|
if (index >= 10) return;
|
|
208
207
|
if (!data) {
|
|
209
208
|
index++;
|
|
210
209
|
this.getCollapseHeight(false, index);
|
|
211
210
|
return;
|
|
212
211
|
}
|
|
213
212
|
// #ifdef APP-NVUE
|
|
214
213
|
this.height = data.height + 1;
|
|
215
214
|
// #endif
|
|
216
215
|
// #ifndef APP-NVUE
|
|
217
216
|
this.height = data.height;
|
|
218
217
|
// #endif
|
|
219
218
|
this.isheight = true;
|
|
220
219
|
if (type) return;
|
|
221
220
|
this.onClick(this.isOpen, 'init');
|
|
222
221
|
}
|
|
223
222
|
)
|
|
224
223
|
.exec();
|
|
225
224
|
},
|
|
226
225
|
getNvueHwight(type) {
|
|
227
226
|
const result = dom.getComponentRect(this.$refs['collapse--hook'], (option) => {
|
|
228
227
|
if (option && option.result && option.size) {
|
|
229
228
|
// #ifdef APP-NVUE
|
|
230
229
|
this.height = option.size.height + 1;
|
|
231
230
|
// #endif
|
|
232
231
|
// #ifndef APP-NVUE
|
|
233
232
|
this.height = option.size.height;
|
|
234
233
|
// #endif
|
|
235
234
|
this.isheight = true;
|
|
236
235
|
if (type) return;
|
|
237
236
|
this.onClick(this.open, 'init');
|
|
238
237
|
}
|
|
239
238
|
});
|
|
240
239
|
},
|
|
241
240
|
/**
|
|
242
241
|
* 获取父元素实例
|
|
243
242
|
*/
|
|
244
243
|
getCollapse(name = 'uniCollapse') {
|
|
245
244
|
let parent = this.$parent;
|
|
246
245
|
let parentName = parent.$options.name;
|
|
247
246
|
while (parentName !== name) {
|
|
248
247
|
parent = parent.$parent;
|
|
249
248
|
if (!parent) return false;
|
|
250
249
|
parentName = parent.$options.name;
|
|
251
250
|
}
|
|
252
251
|
return parent;
|
|
253
252
|
}
|
|
254
253
|
}
|
|
254
|
+
<template>
|
|
255
|
+
<view class="uni-collapse-item">
|
|
256
|
+
<!-- onClick(!isOpen) -->
|
|
257
|
+
<view
|
|
258
|
+
@click="onClick(!isOpen)"
|
|
259
|
+
class="uni-collapse-item__title"
|
|
260
|
+
:class="{ 'is-open': isOpen && titleBorder === 'auto', 'uni-collapse-item-border': titleBorder !== 'none' }"
|
|
261
|
+
>
|
|
262
|
+
<view class="uni-collapse-item__title-wrap">
|
|
263
|
+
<slot name="title">
|
|
264
|
+
<view class="uni-collapse-item__title-box" :class="{ 'is-disabled': disabled }">
|
|
265
|
+
<image v-if="thumb" :src="thumb" class="uni-collapse-item__title-img" />
|
|
266
|
+
<text class="uni-collapse-item__title-text">{{ title }}</text>
|
|
267
|
+
</view>
|
|
268
|
+
</slot>
|
|
269
|
+
</view>
|
|
270
|
+
<view
|
|
271
|
+
v-if="showArrow"
|
|
272
|
+
:class="{ 'uni-collapse-item__title-arrow-active': isOpen, 'uni-collapse-item--animation': showAnimation === true }"
|
|
273
|
+
class="uni-collapse-item__title-arrow"
|
|
274
|
+
>
|
|
275
|
+
<uni-icons :color="disabled ? '#ddd' : '#bbb'" size="14" type="bottom" />
|
|
276
|
+
</view>
|
|
277
|
+
</view>
|
|
278
|
+
<view
|
|
279
|
+
class="uni-collapse-item__wrap"
|
|
280
|
+
:class="{ 'is--transition': showAnimation }"
|
|
281
|
+
:style="{ height: (isOpen ? height : 0) + 'px' }"
|
|
282
|
+
>
|
|
283
|
+
<view
|
|
284
|
+
:id="elId"
|
|
285
|
+
ref="collapse--hook"
|
|
286
|
+
class="uni-collapse-item__wrap-content"
|
|
287
|
+
:class="{ open: isheight, 'uni-collapse-item--border': border && isOpen }"
|
|
288
|
+
>
|
|
289
|
+
<slot></slot>
|
|
290
|
+
</view>
|
|
291
|
+
</view>
|
|
292
|
+
</view>
|
|
293
|
+
</template>
|
|
294
|
+
<script>
|
|
295
|
+
// #ifdef APP-NVUE
|
|
296
|
+
const dom = weex.requireModule('dom');
|
|
297
|
+
// #endif
|
|
298
|
+
/**
|
|
299
|
+
* CollapseItem 折叠面板子组件
|
|
300
|
+
* @description 折叠面板子组件
|
|
301
|
+
* @property {String} title 标题文字
|
|
302
|
+
* @property {String} thumb 标题左侧缩略图
|
|
303
|
+
* @property {String} name 唯一标志符
|
|
304
|
+
* @property {Boolean} open = [true|false] 是否展开组件
|
|
305
|
+
* @property {Boolean} titleBorder = [true|false] 是否显示标题分隔线
|
|
306
|
+
* @property {Boolean} border = [true|false] 是否显示分隔线
|
|
307
|
+
* @property {Boolean} disabled = [true|false] 是否展开面板
|
|
308
|
+
* @property {Boolean} showAnimation = [true|false] 开启动画
|
|
309
|
+
* @property {Boolean} showArrow = [true|false] 是否显示右侧箭头
|
|
310
|
+
*/
|
|
311
|
+
export default {
|
|
312
|
+
name: 'uniCollapseItem',
|
|
313
|
+
props: {
|
|
314
|
+
// 列表标题
|
|
315
|
+
title: {
|
|
316
|
+
type: String,
|
|
317
|
+
default: ''
|
|
318
|
+
},
|
|
319
|
+
name: {
|
|
320
|
+
type: [Number, String],
|
|
321
|
+
default: ''
|
|
322
|
+
},
|
|
323
|
+
// 是否禁用
|
|
324
|
+
disabled: {
|
|
325
|
+
type: Boolean,
|
|
326
|
+
default: false
|
|
327
|
+
},
|
|
328
|
+
// #ifdef APP-PLUS
|
|
329
|
+
// 是否显示动画,app 端默认不开启动画,卡顿严重
|
|
330
|
+
showAnimation: {
|
|
331
|
+
type: Boolean,
|
|
332
|
+
default: false
|
|
333
|
+
},
|
|
334
|
+
// #endif
|
|
335
|
+
// #ifndef APP-PLUS
|
|
336
|
+
// 是否显示动画
|
|
337
|
+
showAnimation: {
|
|
338
|
+
type: Boolean,
|
|
339
|
+
default: true
|
|
340
|
+
},
|
|
341
|
+
// #endif
|
|
342
|
+
// 是否展开
|
|
343
|
+
open: {
|
|
344
|
+
type: Boolean,
|
|
345
|
+
default: false
|
|
346
|
+
},
|
|
347
|
+
// 缩略图
|
|
348
|
+
thumb: {
|
|
349
|
+
type: String,
|
|
350
|
+
default: ''
|
|
351
|
+
},
|
|
352
|
+
// 标题分隔线显示类型
|
|
353
|
+
titleBorder: {
|
|
354
|
+
type: String,
|
|
355
|
+
default: 'auto'
|
|
356
|
+
},
|
|
357
|
+
border: {
|
|
358
|
+
type: Boolean,
|
|
359
|
+
default: true
|
|
360
|
+
},
|
|
361
|
+
showArrow: {
|
|
362
|
+
type: Boolean,
|
|
363
|
+
default: true
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
data() {
|
|
367
|
+
// TODO 随机生生元素ID,解决百度小程序获取同一个元素位置信息的bug
|
|
368
|
+
const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`;
|
|
369
|
+
return {
|
|
370
|
+
isOpen: false,
|
|
371
|
+
isheight: null,
|
|
372
|
+
height: 0,
|
|
373
|
+
elId,
|
|
374
|
+
nameSync: 0
|
|
375
|
+
};
|
|
376
|
+
},
|
|
377
|
+
watch: {
|
|
378
|
+
open(val) {
|
|
379
|
+
this.isOpen = val;
|
|
380
|
+
this.onClick(val, 'init');
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
updated(e) {
|
|
384
|
+
this.$nextTick(() => {
|
|
385
|
+
this.init(true);
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
created() {
|
|
389
|
+
this.collapse = this.getCollapse();
|
|
390
|
+
this.oldHeight = 0;
|
|
391
|
+
this.onClick(this.open, 'init');
|
|
392
|
+
},
|
|
393
|
+
// #ifndef VUE3
|
|
394
|
+
// TODO vue2
|
|
395
|
+
destroyed() {
|
|
396
|
+
if (this.__isUnmounted) return;
|
|
397
|
+
this.uninstall();
|
|
398
|
+
},
|
|
399
|
+
// #endif
|
|
400
|
+
// #ifdef VUE3
|
|
401
|
+
// TODO vue3
|
|
402
|
+
unmounted() {
|
|
403
|
+
this.__isUnmounted = true;
|
|
404
|
+
this.uninstall();
|
|
405
|
+
},
|
|
406
|
+
// #endif
|
|
407
|
+
mounted() {
|
|
408
|
+
if (!this.collapse) return;
|
|
409
|
+
if (this.name !== '') {
|
|
410
|
+
this.nameSync = this.name;
|
|
411
|
+
} else {
|
|
412
|
+
this.nameSync = this.collapse.childrens.length + '';
|
|
413
|
+
}
|
|
414
|
+
if (this.collapse.names.indexOf(this.nameSync) === -1) {
|
|
415
|
+
this.collapse.names.push(this.nameSync);
|
|
416
|
+
} else {
|
|
417
|
+
console.warn(`name 值 ${this.nameSync} 重复`);
|
|
418
|
+
}
|
|
419
|
+
if (this.collapse.childrens.indexOf(this) === -1) {
|
|
420
|
+
this.collapse.childrens.push(this);
|
|
421
|
+
}
|
|
422
|
+
this.init();
|
|
423
|
+
},
|
|
424
|
+
methods: {
|
|
425
|
+
init(type) {
|
|
426
|
+
// #ifndef APP-NVUE
|
|
427
|
+
this.getCollapseHeight(type);
|
|
428
|
+
// #endif
|
|
429
|
+
// #ifdef APP-NVUE
|
|
430
|
+
this.getNvueHwight(type);
|
|
431
|
+
// #endif
|
|
432
|
+
},
|
|
433
|
+
uninstall() {
|
|
434
|
+
if (this.collapse) {
|
|
435
|
+
this.collapse.childrens.forEach((item, index) => {
|
|
436
|
+
if (item === this) {
|
|
437
|
+
this.collapse.childrens.splice(index, 1);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
this.collapse.names.forEach((item, index) => {
|
|
441
|
+
if (item === this.nameSync) {
|
|
442
|
+
this.collapse.names.splice(index, 1);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
onClick(isOpen, type) {
|
|
448
|
+
if (this.disabled) return;
|
|
449
|
+
this.isOpen = isOpen;
|
|
450
|
+
if (this.isOpen && this.collapse) {
|
|
451
|
+
this.collapse.setAccordion(this);
|
|
452
|
+
}
|
|
453
|
+
if (type !== 'init') {
|
|
454
|
+
this.collapse.onChange(isOpen, this);
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
getCollapseHeight(type, index = 0) {
|
|
458
|
+
const views = uni.createSelectorQuery().in(this);
|
|
459
|
+
views
|
|
460
|
+
.select(`#${this.elId}`)
|
|
461
|
+
.fields(
|
|
462
|
+
{
|
|
463
|
+
size: true
|
|
464
|
+
},
|
|
465
|
+
(data) => {
|
|
466
|
+
// TODO 百度中可能获取不到节点信息 ,需要循环获取
|
|
467
|
+
if (index >= 10) return;
|
|
468
|
+
if (!data) {
|
|
469
|
+
index++;
|
|
470
|
+
this.getCollapseHeight(false, index);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
// #ifdef APP-NVUE
|
|
474
|
+
this.height = data.height + 1;
|
|
475
|
+
// #endif
|
|
476
|
+
// #ifndef APP-NVUE
|
|
477
|
+
this.height = data.height;
|
|
478
|
+
// #endif
|
|
479
|
+
this.isheight = true;
|
|
480
|
+
if (type) return;
|
|
481
|
+
this.onClick(this.isOpen, 'init');
|
|
482
|
+
}
|
|
483
|
+
)
|
|
484
|
+
.exec();
|
|
485
|
+
},
|
|
486
|
+
getNvueHwight(type) {
|
|
487
|
+
const result = dom.getComponentRect(this.$refs['collapse--hook'], (option) => {
|
|
488
|
+
if (option && option.result && option.size) {
|
|
489
|
+
// #ifdef APP-NVUE
|
|
490
|
+
this.height = option.size.height + 1;
|
|
491
|
+
// #endif
|
|
492
|
+
// #ifndef APP-NVUE
|
|
493
|
+
this.height = option.size.height;
|
|
494
|
+
// #endif
|
|
495
|
+
this.isheight = true;
|
|
496
|
+
if (type) return;
|
|
497
|
+
this.onClick(this.open, 'init');
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
},
|
|
501
|
+
/**
|
|
502
|
+
* 获取父元素实例
|
|
503
|
+
*/
|
|
504
|
+
getCollapse(name = 'uniCollapse') {
|
|
505
|
+
let parent = this.$parent;
|
|
506
|
+
let parentName = parent.$options.name;
|
|
507
|
+
while (parentName !== name) {
|
|
508
|
+
parent = parent.$parent;
|
|
509
|
+
if (!parent) return false;
|
|
510
|
+
parentName = parent.$options.name;
|
|
511
|
+
}
|
|
512
|
+
return parent;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
</script>
|
|
517
|
+
<style>
|
|
518
|
+
@import 'style.css';
|
|
519
|
+
</style>
|