@10yun/cv-mobile-ui 0.4.2 → 0.4.3
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/ui-uni/amap-wx/js/util.js +166 -158
- package/ui-uni/page-foot/page-foot.vue +38 -0
- package/ui-uni/page-head/page-head.vue +16 -0
- package/ui-uni/product.vue +52 -52
- package/ui-uni/u-charts/u-charts.js +743 -1092
- package/ui-uni/u-link/u-link.vue +59 -0
- package/ui-uni/uni-badge/uni-badge.vue +250 -0
- package/ui-uni/uni-calendar/calendar.js +546 -0
- package/ui-uni/uni-calendar/uni-calendar-item.vue +171 -0
- package/ui-uni/uni-calendar/uni-calendar.vue +504 -0
- package/{ui-cv/cv-calendar → ui-uni/uni-calendar}/util.js +0 -0
- package/ui-uni/uni-card/uni-card.vue +420 -0
- package/ui-uni/uni-col/uni-col.vue +2968 -0
- package/ui-uni/uni-collapse/uni-collapse.vue +146 -0
- package/ui-uni/uni-collapse-item/uni-collapse-item.vue +378 -0
- package/ui-uni/uni-combox/uni-combox.vue +237 -0
- package/ui-uni/uni-countdown/uni-countdown.vue +234 -0
- package/ui-uni/uni-data-checkbox/uni-data-checkbox.vue +792 -0
- package/{ui-cv/cv-data-indexed-list → ui-uni/uni-data-indexed-list}/clientdb.js +0 -0
- package/ui-uni/uni-data-indexed-list/uni-data-indexed-list-item.vue +142 -0
- package/ui-uni/uni-data-indexed-list/uni-data-indexed-list.vue +364 -0
- package/{ui-cv/cv-data-picker → ui-uni/uni-data-picker}/keypress.js +0 -0
- package/ui-uni/uni-data-picker/uni-data-picker.vue +468 -0
- package/{ui-cv/cv-data-pickerview/cv-data-picker.js → ui-uni/uni-data-pickerview/uni-data-picker.js} +0 -0
- package/ui-uni/uni-data-pickerview/uni-data-pickerview.vue +298 -0
- package/{ui-cv/cv-dateformat → ui-uni/uni-dateformat}/date-format.js +0 -0
- package/ui-uni/uni-dateformat/uni-dateformat.vue +88 -0
- package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar-item.vue +0 -0
- package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar.js +0 -0
- package/ui-uni/uni-datetime-picker/calendar.vue +747 -0
- package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/keypress.js +0 -0
- package/ui-uni/uni-datetime-picker/time-picker.vue +899 -0
- package/ui-uni/uni-datetime-picker/uni-datetime-picker.vue +874 -0
- package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/util.js +0 -0
- package/ui-uni/uni-drawer/keypress.js +45 -0
- package/ui-uni/uni-drawer/uni-drawer.vue +178 -0
- package/{ui-cv/cv-easyinput → ui-uni/uni-easyinput}/common.js +0 -0
- package/ui-uni/uni-easyinput/uni-easyinput.vue +438 -0
- package/ui-uni/uni-fab/uni-fab.vue +443 -0
- package/{ui-cv/cv-fab/cv-fab.vue.bak → ui-uni/uni-fab/uni-fab.vue.bak} +2 -2
- package/ui-uni/uni-fav/uni-fav.vue +136 -0
- package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/choose-and-upload-file.js +0 -0
- package/ui-uni/uni-file-picker/uni-file-picker.vue +614 -0
- package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-file.vue +0 -0
- package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-image.vue +0 -0
- package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/utils.js +0 -0
- package/ui-uni/uni-forms/uni-forms.vue +467 -0
- package/ui-uni/uni-forms/validate.js +486 -0
- package/ui-uni/uni-forms-item/uni-forms-item.vue +500 -0
- package/{ui-cv/cv-goods-nav/cv-goods-nav.vue → ui-uni/uni-goods-nav/uni-goods-nav.vue} +1 -1
- package/ui-uni/uni-grid/uni-grid.vue +141 -0
- package/ui-uni/uni-grid-item/uni-grid-item.vue +123 -0
- package/ui-uni/uni-group/uni-group.vue +123 -0
- package/ui-uni/uni-icons/icons.js +132 -0
- package/ui-uni/uni-icons/uni-icons.vue +72 -0
- package/{ui-cv/cv-icon2 → ui-uni/uni-icons}/uni.ttf +0 -0
- package/ui-uni/uni-indexed-list/uni-indexed-list-item.vue +142 -0
- package/ui-uni/uni-indexed-list/uni-indexed-list.vue +357 -0
- package/ui-uni/uni-link/uni-link.vue +117 -0
- package/ui-uni/uni-list/uni-list.vue +107 -0
- package/ui-uni/uni-list/uni-refresh.vue +65 -0
- package/{ui-cv/cv-list → ui-uni/uni-list}/uni-refresh.wxs +0 -0
- package/ui-uni/uni-list-ad/uni-list-ad.vue +106 -0
- package/{ui-cv/cv-list-chat/cv-list-chat.scss → ui-uni/uni-list-chat/uni-list-chat.scss} +0 -0
- package/{ui-cv/cv-list-chat/cv-list-chat.vue → ui-uni/uni-list-chat/uni-list-chat.vue} +0 -0
- package/ui-uni/uni-list-item/uni-list-item.vue +428 -0
- package/ui-uni/uni-load-more/uni-load-more.vue +366 -0
- package/ui-uni/uni-nav-bar/uni-nav-bar.vue +244 -0
- package/{ui-cv/cv-nav-bar/cv-status-bar.vue → ui-uni/uni-nav-bar/uni-status-bar.vue} +0 -0
- package/ui-uni/uni-notice-bar/uni-notice-bar.vue +394 -0
- package/ui-uni/uni-number-box/uni-number-box.vue +224 -0
- package/ui-uni/uni-pagination/uni-pagination.vue +376 -0
- package/{ui-cv/cv-popup → ui-uni/uni-popup}/keypress.js +0 -0
- package/{ui-cv/cv-popup → ui-uni/uni-popup}/popup.js +0 -0
- package/ui-uni/uni-popup/uni-popup.vue +412 -0
- package/{ui-cv/cv-popup-dialog → ui-uni/uni-popup-dialog}/keypress.js +0 -0
- package/{ui-cv/cv-popup-dialog/cv-popup-dialog.vue → ui-uni/uni-popup-dialog/uni-popup-dialog.vue} +0 -0
- package/ui-uni/uni-popup-message/uni-popup-message.vue +143 -0
- package/{ui-cv/cv-popup-share/cv-popup-share.vue → ui-uni/uni-popup-share/uni-popup-share.vue} +0 -0
- package/ui-uni/uni-rate/uni-rate.vue +357 -0
- package/ui-uni/uni-row/uni-row.vue +155 -0
- package/ui-uni/uni-search-bar/uni-search-bar.vue +262 -0
- package/{ui-cv/cv-section/cv-section.vue → ui-uni/uni-section/uni-section.vue} +0 -0
- package/{ui-cv/cv-segmented-control/cv-segmented-control.vue → ui-uni/uni-segmented-control/uni-segmented-control.vue} +0 -0
- package/{ui-cv/cv-status-bar/cv-status-bar.vue → ui-uni/uni-status-bar/uni-status-bar.vue} +0 -0
- package/ui-uni/uni-steps/uni-steps.vue +250 -0
- package/{ui-cv/cv-swipe-action/cv-swipe-action.vue → ui-uni/uni-swipe-action/uni-swipe-action.vue} +0 -0
- package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/bindingx.js +0 -0
- package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/index.wxs +0 -0
- package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/isPC.js +0 -0
- package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpalipay.js +0 -0
- package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpother.js +0 -0
- package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpwxs.js +0 -0
- package/{ui-cv/cv-swipe-action-item/cv-swipe-action-item.vue → ui-uni/uni-swipe-action-item/uni-swipe-action-item.vue} +0 -0
- package/ui-uni/uni-swiper-dot/uni-swiper-dot.vue +205 -0
- package/ui-uni/uni-table/uni-table.vue +455 -0
- package/ui-uni/uni-tag/uni-tag.vue +283 -0
- package/ui-uni/uni-tbody/uni-tbody.vue +30 -0
- package/ui-uni/uni-td/uni-td.vue +88 -0
- package/{ui-cv/cv-test/cv-test.vue → ui-uni/uni-test/uni-test.vue} +0 -0
- package/{ui-cv/cv-th → ui-uni/uni-th}/filter-dropdown.vue +0 -0
- package/ui-uni/uni-th/uni-th.vue +259 -0
- package/ui-uni/uni-thead/uni-thead.vue +114 -0
- package/ui-uni/uni-title/uni-title.vue +171 -0
- package/{ui-cv/cv-tr → ui-uni/uni-tr}/table-checkbox.vue +0 -0
- package/ui-uni/uni-tr/uni-tr.vue +156 -0
- package/{ui-cv/cv-transition → ui-uni/uni-transition}/createAnimation.js +0 -0
- package/ui-uni/uni-transition/uni-transition.vue +287 -0
- package/ui-cv/cv-badge/cv-badge.vue +0 -249
- package/ui-cv/cv-calendar/calendar.js +0 -963
- package/ui-cv/cv-calendar/cv-calendar-item.vue +0 -198
- package/ui-cv/cv-calendar/cv-calendar.vue +0 -508
- package/ui-cv/cv-card/cv-card.vue +0 -427
- package/ui-cv/cv-col/cv-col.vue +0 -2965
- package/ui-cv/cv-collapse/cv-collapse.vue +0 -146
- package/ui-cv/cv-collapse-item/cv-collapse-item.vue +0 -395
- package/ui-cv/cv-combox/cv-combox.vue +0 -250
- package/ui-cv/cv-countdown/cv-countdown.vue +0 -245
- package/ui-cv/cv-data-checkbox/cv-data-checkbox.vue +0 -841
- package/ui-cv/cv-data-indexed-list/cv-data-indexed-list-item.vue +0 -154
- package/ui-cv/cv-data-indexed-list/cv-data-indexed-list.vue +0 -376
- package/ui-cv/cv-data-picker/cv-data-picker.vue +0 -486
- package/ui-cv/cv-data-pickerview/cv-data-pickerview.vue +0 -304
- package/ui-cv/cv-dateformat/cv-dateformat.vue +0 -86
- package/ui-cv/cv-datetime-picker/calendar.vue +0 -761
- package/ui-cv/cv-datetime-picker/cv-datetime-picker.vue +0 -958
- package/ui-cv/cv-datetime-picker/time-picker.vue +0 -907
- package/ui-cv/cv-drawer/cv-drawer.vue +0 -185
- package/ui-cv/cv-drawer/keypress.js +0 -45
- package/ui-cv/cv-easyinput/cv-easyinput.vue +0 -514
- package/ui-cv/cv-fab/cv-fab.vue +0 -465
- package/ui-cv/cv-fav/cv-fav.vue +0 -150
- package/ui-cv/cv-file-picker/cv-file-picker.vue +0 -619
- package/ui-cv/cv-form-base/cv-form-base.vue +0 -470
- package/ui-cv/cv-form-base/validate.js +0 -477
- package/ui-cv/cv-grid-group/cv-grid-group.vue +0 -148
- package/ui-cv/cv-grid-item/cv-grid-item.vue +0 -132
- package/ui-cv/cv-icon2/cv-icon2.vue +0 -78
- package/ui-cv/cv-icon2/icons.js +0 -132
- package/ui-cv/cv-indexed-list/cv-indexed-list-item.vue +0 -154
- package/ui-cv/cv-indexed-list/cv-indexed-list.vue +0 -371
- package/ui-cv/cv-link2/cv-link2.vue +0 -130
- package/ui-cv/cv-list/cv-list.vue +0 -107
- package/ui-cv/cv-list/cv-refresh.vue +0 -65
- package/ui-cv/cv-list-ad/cv-list-ad.vue +0 -113
- package/ui-cv/cv-list-item/cv-list-item.vue +0 -449
- package/ui-cv/cv-nav-bar/cv-nav-bar.vue +0 -256
- package/ui-cv/cv-notice-bar/cv-notice-bar.vue +0 -453
- package/ui-cv/cv-number-box/cv-number-box.vue +0 -223
- package/ui-cv/cv-pagination/cv-pagination.vue +0 -397
- package/ui-cv/cv-popup/cv-popup.vue +0 -429
- package/ui-cv/cv-popup-message/cv-popup-message.vue +0 -143
- package/ui-cv/cv-row/cv-row.vue +0 -157
- package/ui-cv/cv-search-bar/cv-search-bar.vue +0 -280
- package/ui-cv/cv-steps/cv-steps.vue +0 -293
- package/ui-cv/cv-swiper-dot/cv-swiper-dot.vue +0 -255
- package/ui-cv/cv-table/cv-table.vue +0 -460
- package/ui-cv/cv-tag/cv-tag.vue +0 -276
- package/ui-cv/cv-tbody/cv-tbody.vue +0 -28
- package/ui-cv/cv-td/cv-td.vue +0 -93
- package/ui-cv/cv-th/cv-th.vue +0 -270
- package/ui-cv/cv-thead/cv-thead.vue +0 -114
- package/ui-cv/cv-title/cv-title.vue +0 -168
- package/ui-cv/cv-tr/cv-tr.vue +0 -166
- package/ui-cv/cv-transition/cv-transition.vue +0 -279
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-collapse">
|
|
3
|
+
<slot />
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
<script>
|
|
7
|
+
/**
|
|
8
|
+
* Collapse 折叠面板
|
|
9
|
+
* @description 展示可以折叠 / 展开的内容区域
|
|
10
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=23
|
|
11
|
+
* @property {String|Array} value 当前激活面板改变时触发(如果是手风琴模式,参数类型为string,否则为array)
|
|
12
|
+
* @property {Boolean} accordion = [true|false] 是否开启手风琴效果是否开启手风琴效果
|
|
13
|
+
* @event {Function} change 切换面板时触发,如果是手风琴模式,返回类型为string,否则为array
|
|
14
|
+
*/
|
|
15
|
+
export default {
|
|
16
|
+
name: 'uniCollapse',
|
|
17
|
+
emits: ['change', 'activeItem', 'input', 'update:modelValue'],
|
|
18
|
+
props: {
|
|
19
|
+
value: {
|
|
20
|
+
type: [String, Array],
|
|
21
|
+
default: ''
|
|
22
|
+
},
|
|
23
|
+
modelValue: {
|
|
24
|
+
type: [String, Array],
|
|
25
|
+
default: ''
|
|
26
|
+
},
|
|
27
|
+
accordion: {
|
|
28
|
+
// 是否开启手风琴效果
|
|
29
|
+
type: [Boolean, String],
|
|
30
|
+
default: false
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
data() {
|
|
34
|
+
return {}
|
|
35
|
+
},
|
|
36
|
+
computed: {
|
|
37
|
+
// TODO 兼容 vue2 和 vue3
|
|
38
|
+
dataValue() {
|
|
39
|
+
let value = (typeof this.value === 'string' && this.value === '') ||
|
|
40
|
+
(Array.isArray(this.value) && this.value.length === 0)
|
|
41
|
+
let modelValue = (typeof this.modelValue === 'string' && this.modelValue === '') ||
|
|
42
|
+
(Array.isArray(this.modelValue) && this.modelValue.length === 0)
|
|
43
|
+
if (value) {
|
|
44
|
+
return this.modelValue
|
|
45
|
+
}
|
|
46
|
+
if (modelValue) {
|
|
47
|
+
return this.value
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return this.value
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
watch: {
|
|
54
|
+
dataValue(val) {
|
|
55
|
+
this.setOpen(val)
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
created() {
|
|
59
|
+
this.childrens = []
|
|
60
|
+
this.names = []
|
|
61
|
+
},
|
|
62
|
+
mounted() {
|
|
63
|
+
this.setOpen(this.dataValue)
|
|
64
|
+
},
|
|
65
|
+
methods: {
|
|
66
|
+
setOpen(val) {
|
|
67
|
+
let str = typeof val === 'string'
|
|
68
|
+
let arr = Array.isArray(val)
|
|
69
|
+
|
|
70
|
+
this.childrens.forEach((vm, index) => {
|
|
71
|
+
if (str) {
|
|
72
|
+
if (val === vm.nameSync) {
|
|
73
|
+
if (!this.accordion) {
|
|
74
|
+
console.warn('accordion 属性为 false ,v-model 类型应该为 array')
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
vm.isOpen = true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (arr) {
|
|
81
|
+
val.forEach(v => {
|
|
82
|
+
if (v === vm.nameSync) {
|
|
83
|
+
if (this.accordion) {
|
|
84
|
+
console.warn('accordion 属性为 true ,v-model 类型应该为 string')
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
vm.isOpen = true
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
this.emit(val)
|
|
93
|
+
},
|
|
94
|
+
setAccordion(self) {
|
|
95
|
+
if (!this.accordion) return
|
|
96
|
+
this.childrens.forEach((vm, index) => {
|
|
97
|
+
if (self !== vm) {
|
|
98
|
+
vm.isOpen = false
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
},
|
|
102
|
+
resize() {
|
|
103
|
+
this.childrens.forEach((vm, index) => {
|
|
104
|
+
// #ifndef APP-NVUE
|
|
105
|
+
vm.getCollapseHeight()
|
|
106
|
+
// #endif
|
|
107
|
+
// #ifdef APP-NVUE
|
|
108
|
+
vm.getNvueHwight()
|
|
109
|
+
// #endif
|
|
110
|
+
})
|
|
111
|
+
},
|
|
112
|
+
onChange(isOpen, self) {
|
|
113
|
+
let activeItem = []
|
|
114
|
+
|
|
115
|
+
if (this.accordion) {
|
|
116
|
+
activeItem = isOpen ? self.nameSync : ''
|
|
117
|
+
} else {
|
|
118
|
+
this.childrens.forEach((vm, index) => {
|
|
119
|
+
if (vm.isOpen) {
|
|
120
|
+
activeItem.push(vm.nameSync)
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
this.$emit('change', activeItem)
|
|
125
|
+
this.emit(activeItem)
|
|
126
|
+
},
|
|
127
|
+
emit(val) {
|
|
128
|
+
this.$emit('input', val)
|
|
129
|
+
this.$emit('update:modelValue', val)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
</script>
|
|
134
|
+
<style scoped>
|
|
135
|
+
.uni-collapse {
|
|
136
|
+
/* #ifndef APP-NVUE */
|
|
137
|
+
width: 100%;
|
|
138
|
+
display: flex;
|
|
139
|
+
/* #endif */
|
|
140
|
+
/* #ifdef APP-NVUE */
|
|
141
|
+
flex: 1;
|
|
142
|
+
/* #endif */
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
background-color: #ffffff;
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-collapse-item">
|
|
3
|
+
<!-- onClick(!isOpen) -->
|
|
4
|
+
<view @click="onClick(!isOpen)" class="uni-collapse-item__title" :class="{'is-open':isOpen &&titleBorder === 'auto' ,'uni-collapse-item-border':titleBorder !== 'none'}">
|
|
5
|
+
<view class="uni-collapse-item__title-wrap">
|
|
6
|
+
<slot name="title">
|
|
7
|
+
<view class="uni-collapse-item__title-box" :class="{'is-disabled':disabled}">
|
|
8
|
+
<image v-if="thumb" :src="thumb" class="uni-collapse-item__title-img" />
|
|
9
|
+
<text class="uni-collapse-item__title-text">{{ title }}</text>
|
|
10
|
+
</view>
|
|
11
|
+
</slot>
|
|
12
|
+
</view>
|
|
13
|
+
<view :class="{ 'uni-collapse-item__title-arrow-active': isOpen, 'uni-collapse-item--animation': showAnimation === true }" class="uni-collapse-item__title-arrow">
|
|
14
|
+
<uni-icons :color="disabled?'#ddd':'#bbb'" size="14" type="arrowdown" />
|
|
15
|
+
</view>
|
|
16
|
+
</view>
|
|
17
|
+
<view class="uni-collapse-item__wrap" :class="{'is--transition':showAnimation}" :style="{height: (isOpen?height:0) +'px'}">
|
|
18
|
+
<view :id="elId" ref="collapse--hook" class="uni-collapse-item__wrap-content" :class="{open:isheight,'uni-collapse-item--border':border&&isOpen}">
|
|
19
|
+
<slot></slot>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
|
|
23
|
+
</view>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
// #ifdef APP-NVUE
|
|
28
|
+
const dom = weex.requireModule('dom')
|
|
29
|
+
// #endif
|
|
30
|
+
/**
|
|
31
|
+
* CollapseItem 折叠面板子组件
|
|
32
|
+
* @description 折叠面板子组件
|
|
33
|
+
* @property {String} title 标题文字
|
|
34
|
+
* @property {String} thumb 标题左侧缩略图
|
|
35
|
+
* @property {String} name 唯一标志符
|
|
36
|
+
* @property {Boolean} disabled = [true|false] 是否展开面板
|
|
37
|
+
* @property {Boolean} showAnimation = [true|false] 开启动画
|
|
38
|
+
*/
|
|
39
|
+
export default {
|
|
40
|
+
name: 'uniCollapseItem',
|
|
41
|
+
props: {
|
|
42
|
+
// 列表标题
|
|
43
|
+
title: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: ''
|
|
46
|
+
},
|
|
47
|
+
name: {
|
|
48
|
+
type: [Number, String],
|
|
49
|
+
default: ''
|
|
50
|
+
},
|
|
51
|
+
// 是否禁用
|
|
52
|
+
disabled: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
// #ifdef APP-PLUS
|
|
57
|
+
// 是否显示动画,app 端默认不开启动画,卡顿严重
|
|
58
|
+
showAnimation: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false
|
|
61
|
+
},
|
|
62
|
+
// #endif
|
|
63
|
+
// #ifndef APP-PLUS
|
|
64
|
+
// 是否显示动画
|
|
65
|
+
showAnimation: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true
|
|
68
|
+
},
|
|
69
|
+
// #endif
|
|
70
|
+
// 是否展开
|
|
71
|
+
open: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
// 缩略图
|
|
76
|
+
thumb: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: ''
|
|
79
|
+
},
|
|
80
|
+
// 标题分隔线显示类型
|
|
81
|
+
titleBorder: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: 'auto'
|
|
84
|
+
},
|
|
85
|
+
// 是否显示分隔线
|
|
86
|
+
border: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
data() {
|
|
92
|
+
// TODO 随机生生元素ID,解决百度小程序获取同一个元素位置信息的bug
|
|
93
|
+
const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`
|
|
94
|
+
return {
|
|
95
|
+
isOpen: false,
|
|
96
|
+
isheight: null,
|
|
97
|
+
height: 0,
|
|
98
|
+
elId,
|
|
99
|
+
nameSync: 0
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
watch: {
|
|
103
|
+
open(val) {
|
|
104
|
+
this.isOpen = val
|
|
105
|
+
this.onClick(val, 'init')
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
updated(e) {
|
|
109
|
+
this.$nextTick(() => {
|
|
110
|
+
this.init(true)
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
created() {
|
|
114
|
+
this.collapse = this.getCollapse()
|
|
115
|
+
this.oldHeight = 0
|
|
116
|
+
},
|
|
117
|
+
// #ifndef VUE3
|
|
118
|
+
// TODO vue2
|
|
119
|
+
destroyed() {
|
|
120
|
+
if (this.__isUnmounted) return
|
|
121
|
+
this.uninstall()
|
|
122
|
+
},
|
|
123
|
+
// #endif
|
|
124
|
+
// #ifdef VUE3
|
|
125
|
+
// TODO vue3
|
|
126
|
+
unmounted() {
|
|
127
|
+
this.__isUnmounted = true
|
|
128
|
+
this.uninstall()
|
|
129
|
+
},
|
|
130
|
+
// #endif
|
|
131
|
+
|
|
132
|
+
mounted() {
|
|
133
|
+
|
|
134
|
+
if (!this.collapse) return
|
|
135
|
+
if (this.name !== '') {
|
|
136
|
+
this.nameSync = this.name
|
|
137
|
+
} else {
|
|
138
|
+
this.nameSync = this.collapse.childrens.length + ''
|
|
139
|
+
}
|
|
140
|
+
if (this.collapse.names.indexOf(this.nameSync) === -1) {
|
|
141
|
+
this.collapse.names.push(this.nameSync)
|
|
142
|
+
} else {
|
|
143
|
+
console.warn(`name 值 ${this.nameSync} 重复`);
|
|
144
|
+
}
|
|
145
|
+
if (this.collapse.childrens.indexOf(this) === -1) {
|
|
146
|
+
this.collapse.childrens.push(this)
|
|
147
|
+
}
|
|
148
|
+
this.init()
|
|
149
|
+
},
|
|
150
|
+
methods: {
|
|
151
|
+
init(type) {
|
|
152
|
+
// #ifndef APP-NVUE
|
|
153
|
+
this.getCollapseHeight(type)
|
|
154
|
+
// #endif
|
|
155
|
+
// #ifdef APP-NVUE
|
|
156
|
+
this.getNvueHwight(type)
|
|
157
|
+
// #endif
|
|
158
|
+
},
|
|
159
|
+
uninstall() {
|
|
160
|
+
if (this.collapse) {
|
|
161
|
+
this.collapse.childrens.forEach((item, index) => {
|
|
162
|
+
if (item === this) {
|
|
163
|
+
this.collapse.childrens.splice(index, 1)
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
this.collapse.names.forEach((item, index) => {
|
|
167
|
+
if (item === this.nameSync) {
|
|
168
|
+
this.collapse.names.splice(index, 1)
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
onClick(isOpen, type) {
|
|
174
|
+
if (this.disabled) return
|
|
175
|
+
this.isOpen = isOpen
|
|
176
|
+
if (this.isOpen && this.collapse) {
|
|
177
|
+
this.collapse.setAccordion(this)
|
|
178
|
+
}
|
|
179
|
+
if (type !== 'init') {
|
|
180
|
+
this.collapse.onChange(isOpen, this)
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
getCollapseHeight(type, index = 0) {
|
|
184
|
+
const views = uni.createSelectorQuery().in(this)
|
|
185
|
+
views
|
|
186
|
+
.select(`#${this.elId}`)
|
|
187
|
+
.fields({
|
|
188
|
+
size: true
|
|
189
|
+
}, data => {
|
|
190
|
+
// TODO 百度中可能获取不到节点信息 ,需要循环获取
|
|
191
|
+
if (index >= 10) return
|
|
192
|
+
if (!data) {
|
|
193
|
+
index++
|
|
194
|
+
this.getCollapseHeight(false, index)
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
// #ifdef APP-NVUE
|
|
198
|
+
this.height = data.height + 1
|
|
199
|
+
// #endif
|
|
200
|
+
// #ifndef APP-NVUE
|
|
201
|
+
this.height = data.height
|
|
202
|
+
// #endif
|
|
203
|
+
this.isheight = true
|
|
204
|
+
if (type) return
|
|
205
|
+
this.onClick(this.open, 'init')
|
|
206
|
+
})
|
|
207
|
+
.exec()
|
|
208
|
+
},
|
|
209
|
+
getNvueHwight(type) {
|
|
210
|
+
const result = dom.getComponentRect(this.$refs['collapse--hook'], option => {
|
|
211
|
+
if (option && option.result && option.size) {
|
|
212
|
+
// #ifdef APP-NVUE
|
|
213
|
+
this.height = option.size.height + 1
|
|
214
|
+
// #endif
|
|
215
|
+
// #ifndef APP-NVUE
|
|
216
|
+
this.height = option.size.height
|
|
217
|
+
// #endif
|
|
218
|
+
this.isheight = true
|
|
219
|
+
if (type) return
|
|
220
|
+
this.onClick(this.open, 'init')
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
},
|
|
224
|
+
/**
|
|
225
|
+
* 获取父元素实例
|
|
226
|
+
*/
|
|
227
|
+
getCollapse(name = 'uniCollapse') {
|
|
228
|
+
let parent = this.$parent;
|
|
229
|
+
let parentName = parent.$options.name;
|
|
230
|
+
while (parentName !== name) {
|
|
231
|
+
parent = parent.$parent;
|
|
232
|
+
if (!parent) return false;
|
|
233
|
+
parentName = parent.$options.name;
|
|
234
|
+
}
|
|
235
|
+
return parent;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
</script>
|
|
240
|
+
|
|
241
|
+
<style scoped>
|
|
242
|
+
.uni-collapse-item {
|
|
243
|
+
/* #ifndef APP-NVUE */
|
|
244
|
+
box-sizing: border-box;
|
|
245
|
+
/* #endif */
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.uni-collapse-item__title {
|
|
249
|
+
/* #ifndef APP-NVUE */
|
|
250
|
+
display: flex;
|
|
251
|
+
width: 100%;
|
|
252
|
+
box-sizing: border-box;
|
|
253
|
+
/* #endif */
|
|
254
|
+
flex-direction: row;
|
|
255
|
+
align-items: center;
|
|
256
|
+
transition: border-bottom-color 0.3s;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.uni-collapse-item__title-wrap {
|
|
260
|
+
width: 100%;
|
|
261
|
+
flex: 1;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.uni-collapse-item__title-box {
|
|
265
|
+
padding: 0 15px;
|
|
266
|
+
/* #ifndef APP-NVUE */
|
|
267
|
+
display: flex;
|
|
268
|
+
width: 100%;
|
|
269
|
+
box-sizing: border-box;
|
|
270
|
+
/* #endif */
|
|
271
|
+
flex-direction: row;
|
|
272
|
+
justify-content: space-between;
|
|
273
|
+
align-items: center;
|
|
274
|
+
height: 48px;
|
|
275
|
+
line-height: 48px;
|
|
276
|
+
background-color: #fff;
|
|
277
|
+
color: #303133;
|
|
278
|
+
font-size: 13px;
|
|
279
|
+
font-weight: 500;
|
|
280
|
+
/* #ifdef H5 */
|
|
281
|
+
cursor: pointer;
|
|
282
|
+
outline: none;
|
|
283
|
+
/* #endif */
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.uni-collapse-item__title-box.is-disabled .uni-collapse-item__title-text {
|
|
287
|
+
color: #c0c0c0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.uni-collapse-item__title.uni-collapse-item-border {
|
|
291
|
+
border-bottom: 1px solid #ebeef5;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.uni-collapse-item__title.is-open {
|
|
295
|
+
border-bottom-color: transparent;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.uni-collapse-item__title-img {
|
|
299
|
+
height: 26px;
|
|
300
|
+
width: 26px;
|
|
301
|
+
margin-right: 10px;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.uni-collapse-item__title-text {
|
|
305
|
+
flex: 1;
|
|
306
|
+
font-size: 14px;
|
|
307
|
+
/* #ifndef APP-NVUE */
|
|
308
|
+
white-space: nowrap;
|
|
309
|
+
color: inherit;
|
|
310
|
+
/* #endif */
|
|
311
|
+
/* #ifdef APP-NVUE */
|
|
312
|
+
lines: 1;
|
|
313
|
+
/* #endif */
|
|
314
|
+
overflow: hidden;
|
|
315
|
+
text-overflow: ellipsis;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.uni-collapse-item__title-arrow {
|
|
319
|
+
/* #ifndef APP-NVUE */
|
|
320
|
+
display: flex;
|
|
321
|
+
box-sizing: border-box;
|
|
322
|
+
/* #endif */
|
|
323
|
+
align-items: center;
|
|
324
|
+
justify-content: center;
|
|
325
|
+
width: 20px;
|
|
326
|
+
height: 20px;
|
|
327
|
+
margin-right: 10px;
|
|
328
|
+
transform: rotate(0deg);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.uni-collapse-item__title-arrow-active {
|
|
332
|
+
transform: rotate(180deg);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.uni-collapse-item__wrap {
|
|
336
|
+
/* #ifndef APP-NVUE */
|
|
337
|
+
will-change: height;
|
|
338
|
+
box-sizing: border-box;
|
|
339
|
+
/* #endif */
|
|
340
|
+
background-color: #fff;
|
|
341
|
+
overflow: hidden;
|
|
342
|
+
position: relative;
|
|
343
|
+
height: 0;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.uni-collapse-item__wrap.is--transition {
|
|
347
|
+
transition-property: height, border-bottom-width;
|
|
348
|
+
transition-duration: 0.3s;
|
|
349
|
+
/* #ifndef APP-NVUE */
|
|
350
|
+
will-change: height;
|
|
351
|
+
/* #endif */
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.uni-collapse-item__wrap-content {
|
|
355
|
+
position: absolute;
|
|
356
|
+
font-size: 13px;
|
|
357
|
+
color: #303133;
|
|
358
|
+
border-bottom-color: transparent;
|
|
359
|
+
border-bottom-style: solid;
|
|
360
|
+
border-bottom-width: 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.uni-collapse-item__wrap-content.uni-collapse-item--border {
|
|
364
|
+
border-bottom-width: 1px;
|
|
365
|
+
border-bottom-color: red;
|
|
366
|
+
border-bottom-color: #ebeef5;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.uni-collapse-item__wrap-content.open {
|
|
370
|
+
position: relative;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.uni-collapse-item--animation {
|
|
374
|
+
transition-property: transform;
|
|
375
|
+
transition-duration: 0.3s;
|
|
376
|
+
transition-timing-function: ease;
|
|
377
|
+
}
|
|
378
|
+
</style>
|