@kengic/uni 0.3.2-beta.10
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/README.md +1 -0
- package/dist/index.css +1 -0
- package/dist/kengic-uni.js +5 -0
- package/dist/src/consts/i18n/en.d.ts +45 -0
- package/dist/src/consts/i18n/index.d.ts +90 -0
- package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
- package/dist/src/consts/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/kg.util.d.ts +5 -0
- package/dist/uni-ui/index.ts +11 -0
- package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
- package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
- package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
- package/dist/uni-ui/uni-calendar/calendar.js +546 -0
- package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
- package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
- package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
- package/dist/uni-ui/uni-calendar/util.js +360 -0
- package/dist/uni-ui/uni-card/uni-card.vue +281 -0
- package/dist/uni-ui/uni-col/uni-col.vue +317 -0
- package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
- package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
- package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
- package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
- package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
- package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
- package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
- package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
- package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
- package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
- package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
- package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
- package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
- package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
- package/dist/uni-ui/uni-drawer/keypress.js +45 -0
- package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
- package/dist/uni-ui/uni-easyinput/common.js +56 -0
- package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
- package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
- package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
- package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
- package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
- package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
- package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
- package/dist/uni-ui/uni-file-picker/utils.js +109 -0
- package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
- package/dist/uni-ui/uni-forms/utils.js +293 -0
- package/dist/uni-ui/uni-forms/validate.js +486 -0
- package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
- package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
- package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
- package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
- package/dist/uni-ui/uni-group/uni-group.vue +134 -0
- package/dist/uni-ui/uni-icons/icons.js +1169 -0
- package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
- package/dist/uni-ui/uni-icons/uniicons.css +663 -0
- package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
- package/dist/uni-ui/uni-link/uni-link.vue +128 -0
- package/dist/uni-ui/uni-list/uni-list.vue +123 -0
- package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
- package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
- package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
- package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
- package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
- package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
- package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
- package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
- package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
- package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
- package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
- package/dist/uni-ui/uni-popup/keypress.js +45 -0
- package/dist/uni-ui/uni-popup/popup.js +23 -0
- package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
- package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
- package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
- package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
- package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
- package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
- package/dist/uni-ui/uni-row/uni-row.vue +190 -0
- package/dist/uni-ui/uni-scss/changelog.md +8 -0
- package/dist/uni-ui/uni-scss/index.scss +1 -0
- package/dist/uni-ui/uni-scss/package.json +82 -0
- package/dist/uni-ui/uni-scss/readme.md +4 -0
- package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
- package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
- package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
- package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
- package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
- package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
- package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
- package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
- package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
- package/dist/uni-ui/uni-scss/theme.scss +31 -0
- package/dist/uni-ui/uni-scss/variables.scss +62 -0
- package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
- package/dist/uni-ui/uni-section/uni-section.vue +167 -0
- package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
- package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
- package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
- package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
- package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
- package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
- package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
- package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
- package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
- package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
- package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
- package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
- package/dist/uni-ui/uni-table/uni-table.vue +455 -0
- package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
- package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
- package/dist/uni-ui/uni-td/uni-td.vue +90 -0
- package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
- package/dist/uni-ui/uni-th/uni-th.vue +285 -0
- package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
- package/dist/uni-ui/uni-title/uni-title.vue +171 -0
- package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
- package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
- package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
- package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
- package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
- package/package.json +90 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-collapse-item">
|
|
3
|
+
<!-- onClick(!isOpen) -->
|
|
4
|
+
<view @click="onClick(!isOpen)" class="uni-collapse-item__title"
|
|
5
|
+
:class="{'is-open':isOpen &&titleBorder === 'auto' ,'uni-collapse-item-border':titleBorder !== 'none'}">
|
|
6
|
+
<view class="uni-collapse-item__title-wrap">
|
|
7
|
+
<slot name="title">
|
|
8
|
+
<view class="uni-collapse-item__title-box" :class="{'is-disabled':disabled}">
|
|
9
|
+
<image v-if="thumb" :src="thumb" class="uni-collapse-item__title-img" />
|
|
10
|
+
<text class="uni-collapse-item__title-text">{{ title }}</text>
|
|
11
|
+
</view>
|
|
12
|
+
</slot>
|
|
13
|
+
</view>
|
|
14
|
+
<view v-if="showArrow"
|
|
15
|
+
:class="{ 'uni-collapse-item__title-arrow-active': isOpen, 'uni-collapse-item--animation': showAnimation === true }"
|
|
16
|
+
class="uni-collapse-item__title-arrow">
|
|
17
|
+
<uni-icons :color="disabled?'#ddd':'#bbb'" size="14" type="bottom" />
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
<view class="uni-collapse-item__wrap" :class="{'is--transition':showAnimation}"
|
|
21
|
+
:style="{height: (isOpen?height:0) +'px'}">
|
|
22
|
+
<view :id="elId" ref="collapse--hook" class="uni-collapse-item__wrap-content"
|
|
23
|
+
:class="{open:isheight,'uni-collapse-item--border':border&&isOpen}">
|
|
24
|
+
<slot></slot>
|
|
25
|
+
</view>
|
|
26
|
+
</view>
|
|
27
|
+
|
|
28
|
+
</view>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
// #ifdef APP-NVUE
|
|
33
|
+
const dom = weex.requireModule('dom')
|
|
34
|
+
// #endif
|
|
35
|
+
/**
|
|
36
|
+
* CollapseItem 折叠面板子组件
|
|
37
|
+
* @description 折叠面板子组件
|
|
38
|
+
* @property {String} title 标题文字
|
|
39
|
+
* @property {String} thumb 标题左侧缩略图
|
|
40
|
+
* @property {String} name 唯一标志符
|
|
41
|
+
* @property {Boolean} open = [true|false] 是否展开组件
|
|
42
|
+
* @property {Boolean} titleBorder = [true|false] 是否显示标题分隔线
|
|
43
|
+
* @property {Boolean} border = [true|false] 是否显示分隔线
|
|
44
|
+
* @property {Boolean} disabled = [true|false] 是否展开面板
|
|
45
|
+
* @property {Boolean} showAnimation = [true|false] 开启动画
|
|
46
|
+
* @property {Boolean} showArrow = [true|false] 是否显示右侧箭头
|
|
47
|
+
*/
|
|
48
|
+
export default {
|
|
49
|
+
name: 'uniCollapseItem',
|
|
50
|
+
props: {
|
|
51
|
+
// 列表标题
|
|
52
|
+
title: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: ''
|
|
55
|
+
},
|
|
56
|
+
name: {
|
|
57
|
+
type: [Number, String],
|
|
58
|
+
default: ''
|
|
59
|
+
},
|
|
60
|
+
// 是否禁用
|
|
61
|
+
disabled: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
// #ifdef APP-PLUS
|
|
66
|
+
// 是否显示动画,app 端默认不开启动画,卡顿严重
|
|
67
|
+
showAnimation: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
// #endif
|
|
72
|
+
// #ifndef APP-PLUS
|
|
73
|
+
// 是否显示动画
|
|
74
|
+
showAnimation: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: true
|
|
77
|
+
},
|
|
78
|
+
// #endif
|
|
79
|
+
// 是否展开
|
|
80
|
+
open: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
// 缩略图
|
|
85
|
+
thumb: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: ''
|
|
88
|
+
},
|
|
89
|
+
// 标题分隔线显示类型
|
|
90
|
+
titleBorder: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: 'auto'
|
|
93
|
+
},
|
|
94
|
+
border: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: true
|
|
97
|
+
},
|
|
98
|
+
showArrow: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: true
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
data() {
|
|
104
|
+
// TODO 随机生生元素ID,解决百度小程序获取同一个元素位置信息的bug
|
|
105
|
+
const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`
|
|
106
|
+
return {
|
|
107
|
+
isOpen: false,
|
|
108
|
+
isheight: null,
|
|
109
|
+
height: 0,
|
|
110
|
+
elId,
|
|
111
|
+
nameSync: 0
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
watch: {
|
|
115
|
+
open(val) {
|
|
116
|
+
this.isOpen = val
|
|
117
|
+
this.onClick(val, 'init')
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
updated(e) {
|
|
121
|
+
this.$nextTick(() => {
|
|
122
|
+
this.init(true)
|
|
123
|
+
})
|
|
124
|
+
},
|
|
125
|
+
created() {
|
|
126
|
+
this.collapse = this.getCollapse()
|
|
127
|
+
this.oldHeight = 0
|
|
128
|
+
this.onClick(this.open, 'init')
|
|
129
|
+
},
|
|
130
|
+
// #ifndef VUE3
|
|
131
|
+
// TODO vue2
|
|
132
|
+
destroyed() {
|
|
133
|
+
if (this.__isUnmounted) return
|
|
134
|
+
this.uninstall()
|
|
135
|
+
},
|
|
136
|
+
// #endif
|
|
137
|
+
// #ifdef VUE3
|
|
138
|
+
// TODO vue3
|
|
139
|
+
unmounted() {
|
|
140
|
+
this.__isUnmounted = true
|
|
141
|
+
this.uninstall()
|
|
142
|
+
},
|
|
143
|
+
// #endif
|
|
144
|
+
mounted() {
|
|
145
|
+
if (!this.collapse) return
|
|
146
|
+
if (this.name !== '') {
|
|
147
|
+
this.nameSync = this.name
|
|
148
|
+
} else {
|
|
149
|
+
this.nameSync = this.collapse.childrens.length + ''
|
|
150
|
+
}
|
|
151
|
+
if (this.collapse.names.indexOf(this.nameSync) === -1) {
|
|
152
|
+
this.collapse.names.push(this.nameSync)
|
|
153
|
+
} else {
|
|
154
|
+
console.warn(`name 值 ${this.nameSync} 重复`);
|
|
155
|
+
}
|
|
156
|
+
if (this.collapse.childrens.indexOf(this) === -1) {
|
|
157
|
+
this.collapse.childrens.push(this)
|
|
158
|
+
}
|
|
159
|
+
this.init()
|
|
160
|
+
},
|
|
161
|
+
methods: {
|
|
162
|
+
init(type) {
|
|
163
|
+
// #ifndef APP-NVUE
|
|
164
|
+
this.getCollapseHeight(type)
|
|
165
|
+
// #endif
|
|
166
|
+
// #ifdef APP-NVUE
|
|
167
|
+
this.getNvueHwight(type)
|
|
168
|
+
// #endif
|
|
169
|
+
},
|
|
170
|
+
uninstall() {
|
|
171
|
+
if (this.collapse) {
|
|
172
|
+
this.collapse.childrens.forEach((item, index) => {
|
|
173
|
+
if (item === this) {
|
|
174
|
+
this.collapse.childrens.splice(index, 1)
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
this.collapse.names.forEach((item, index) => {
|
|
178
|
+
if (item === this.nameSync) {
|
|
179
|
+
this.collapse.names.splice(index, 1)
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
onClick(isOpen, type) {
|
|
185
|
+
if (this.disabled) return
|
|
186
|
+
this.isOpen = isOpen
|
|
187
|
+
if (this.isOpen && this.collapse) {
|
|
188
|
+
this.collapse.setAccordion(this)
|
|
189
|
+
}
|
|
190
|
+
if (type !== 'init') {
|
|
191
|
+
this.collapse.onChange(isOpen, this)
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
getCollapseHeight(type, index = 0) {
|
|
195
|
+
const views = uni.createSelectorQuery().in(this)
|
|
196
|
+
views
|
|
197
|
+
.select(`#${this.elId}`)
|
|
198
|
+
.fields({
|
|
199
|
+
size: true
|
|
200
|
+
}, data => {
|
|
201
|
+
// TODO 百度中可能获取不到节点信息 ,需要循环获取
|
|
202
|
+
if (index >= 10) return
|
|
203
|
+
if (!data) {
|
|
204
|
+
index++
|
|
205
|
+
this.getCollapseHeight(false, index)
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
// #ifdef APP-NVUE
|
|
209
|
+
this.height = data.height + 1
|
|
210
|
+
// #endif
|
|
211
|
+
// #ifndef APP-NVUE
|
|
212
|
+
this.height = data.height
|
|
213
|
+
// #endif
|
|
214
|
+
this.isheight = true
|
|
215
|
+
if (type) return
|
|
216
|
+
this.onClick(this.isOpen, 'init')
|
|
217
|
+
})
|
|
218
|
+
.exec()
|
|
219
|
+
},
|
|
220
|
+
getNvueHwight(type) {
|
|
221
|
+
const result = dom.getComponentRect(this.$refs['collapse--hook'], option => {
|
|
222
|
+
if (option && option.result && option.size) {
|
|
223
|
+
// #ifdef APP-NVUE
|
|
224
|
+
this.height = option.size.height + 1
|
|
225
|
+
// #endif
|
|
226
|
+
// #ifndef APP-NVUE
|
|
227
|
+
this.height = option.size.height
|
|
228
|
+
// #endif
|
|
229
|
+
this.isheight = true
|
|
230
|
+
if (type) return
|
|
231
|
+
this.onClick(this.open, 'init')
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
},
|
|
235
|
+
/**
|
|
236
|
+
* 获取父元素实例
|
|
237
|
+
*/
|
|
238
|
+
getCollapse(name = 'uniCollapse') {
|
|
239
|
+
let parent = this.$parent;
|
|
240
|
+
let parentName = parent.$options.name;
|
|
241
|
+
while (parentName !== name) {
|
|
242
|
+
parent = parent.$parent;
|
|
243
|
+
if (!parent) return false;
|
|
244
|
+
parentName = parent.$options.name;
|
|
245
|
+
}
|
|
246
|
+
return parent;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
</script>
|
|
251
|
+
|
|
252
|
+
<style lang="scss">
|
|
253
|
+
.uni-collapse-item {
|
|
254
|
+
/* #ifndef APP-NVUE */
|
|
255
|
+
box-sizing: border-box;
|
|
256
|
+
|
|
257
|
+
/* #endif */
|
|
258
|
+
&__title {
|
|
259
|
+
/* #ifndef APP-NVUE */
|
|
260
|
+
display: flex;
|
|
261
|
+
width: 100%;
|
|
262
|
+
box-sizing: border-box;
|
|
263
|
+
/* #endif */
|
|
264
|
+
flex-direction: row;
|
|
265
|
+
align-items: center;
|
|
266
|
+
transition: border-bottom-color .3s;
|
|
267
|
+
|
|
268
|
+
// transition-property: border-bottom-color;
|
|
269
|
+
// transition-duration: 5s;
|
|
270
|
+
&-wrap {
|
|
271
|
+
width: 100%;
|
|
272
|
+
flex: 1;
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
&-box {
|
|
277
|
+
padding: 0 15px;
|
|
278
|
+
/* #ifndef APP-NVUE */
|
|
279
|
+
display: flex;
|
|
280
|
+
width: 100%;
|
|
281
|
+
box-sizing: border-box;
|
|
282
|
+
/* #endif */
|
|
283
|
+
flex-direction: row;
|
|
284
|
+
justify-content: space-between;
|
|
285
|
+
align-items: center;
|
|
286
|
+
height: 48px;
|
|
287
|
+
line-height: 48px;
|
|
288
|
+
background-color: #fff;
|
|
289
|
+
color: #303133;
|
|
290
|
+
font-size: 13px;
|
|
291
|
+
font-weight: 500;
|
|
292
|
+
/* #ifdef H5 */
|
|
293
|
+
cursor: pointer;
|
|
294
|
+
outline: none;
|
|
295
|
+
|
|
296
|
+
/* #endif */
|
|
297
|
+
&.is-disabled {
|
|
298
|
+
.uni-collapse-item__title-text {
|
|
299
|
+
color: #999;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
&.uni-collapse-item-border {
|
|
306
|
+
border-bottom: 1px solid #ebeef5;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
&.is-open {
|
|
310
|
+
border-bottom-color: transparent;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
&-img {
|
|
314
|
+
height: 22px;
|
|
315
|
+
width: 22px;
|
|
316
|
+
margin-right: 10px;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
&-text {
|
|
320
|
+
flex: 1;
|
|
321
|
+
font-size: 14px;
|
|
322
|
+
/* #ifndef APP-NVUE */
|
|
323
|
+
white-space: nowrap;
|
|
324
|
+
color: inherit;
|
|
325
|
+
/* #endif */
|
|
326
|
+
/* #ifdef APP-NVUE */
|
|
327
|
+
lines: 1;
|
|
328
|
+
/* #endif */
|
|
329
|
+
overflow: hidden;
|
|
330
|
+
text-overflow: ellipsis;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
&-arrow {
|
|
334
|
+
/* #ifndef APP-NVUE */
|
|
335
|
+
display: flex;
|
|
336
|
+
box-sizing: border-box;
|
|
337
|
+
/* #endif */
|
|
338
|
+
align-items: center;
|
|
339
|
+
justify-content: center;
|
|
340
|
+
width: 20px;
|
|
341
|
+
height: 20px;
|
|
342
|
+
margin-right: 10px;
|
|
343
|
+
transform: rotate(0deg);
|
|
344
|
+
|
|
345
|
+
&-active {
|
|
346
|
+
transform: rotate(-180deg);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
&__wrap {
|
|
354
|
+
/* #ifndef APP-NVUE */
|
|
355
|
+
will-change: height;
|
|
356
|
+
box-sizing: border-box;
|
|
357
|
+
/* #endif */
|
|
358
|
+
background-color: #fff;
|
|
359
|
+
overflow: hidden;
|
|
360
|
+
position: relative;
|
|
361
|
+
height: 0;
|
|
362
|
+
|
|
363
|
+
&.is--transition {
|
|
364
|
+
// transition: all 0.3s;
|
|
365
|
+
transition-property: height, border-bottom-width;
|
|
366
|
+
transition-duration: 0.3s;
|
|
367
|
+
/* #ifndef APP-NVUE */
|
|
368
|
+
will-change: height;
|
|
369
|
+
/* #endif */
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
&-content {
|
|
375
|
+
position: absolute;
|
|
376
|
+
font-size: 13px;
|
|
377
|
+
color: #303133;
|
|
378
|
+
// transition: height 0.3s;
|
|
379
|
+
border-bottom-color: transparent;
|
|
380
|
+
border-bottom-style: solid;
|
|
381
|
+
border-bottom-width: 0;
|
|
382
|
+
|
|
383
|
+
&.uni-collapse-item--border {
|
|
384
|
+
border-bottom-width: 1px;
|
|
385
|
+
border-bottom-color: red;
|
|
386
|
+
border-bottom-color: #ebeef5;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
&.open {
|
|
390
|
+
position: relative;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
&--animation {
|
|
396
|
+
transition-property: transform;
|
|
397
|
+
transition-duration: 0.3s;
|
|
398
|
+
transition-timing-function: ease;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
}
|
|
402
|
+
</style>
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-combox" :class="border ? '' : 'uni-combox__no-border'">
|
|
3
|
+
<view v-if="label" class="uni-combox__label" :style="labelStyle">
|
|
4
|
+
<text>{{label}}</text>
|
|
5
|
+
</view>
|
|
6
|
+
<view class="uni-combox__input-box">
|
|
7
|
+
<input class="uni-combox__input" type="text" :placeholder="placeholder"
|
|
8
|
+
placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus" @blur="onBlur" />
|
|
9
|
+
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector">
|
|
10
|
+
</uni-icons>
|
|
11
|
+
</view>
|
|
12
|
+
<view class="uni-combox__selector" v-if="showSelector">
|
|
13
|
+
<view class="uni-popper__arrow"></view>
|
|
14
|
+
<scroll-view scroll-y="true" class="uni-combox__selector-scroll" @scroll="onScroll">
|
|
15
|
+
<view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0">
|
|
16
|
+
<text>{{emptyTips}}</text>
|
|
17
|
+
</view>
|
|
18
|
+
<view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index" @click="onSelectorClick(index)">
|
|
19
|
+
<text>{{item}}</text>
|
|
20
|
+
</view>
|
|
21
|
+
</scroll-view>
|
|
22
|
+
</view>
|
|
23
|
+
<!-- 新增蒙层,点击蒙层时关闭选项显示 -->
|
|
24
|
+
<view class="uni-combox__mask" v-show="showSelector" @click="showSelector = false"></view>
|
|
25
|
+
</view>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
/**
|
|
30
|
+
* Combox 组合输入框
|
|
31
|
+
* @description 组合输入框一般用于既可以输入也可以选择的场景
|
|
32
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=1261
|
|
33
|
+
* @property {String} label 左侧文字
|
|
34
|
+
* @property {String} labelWidth 左侧内容宽度
|
|
35
|
+
* @property {String} placeholder 输入框占位符
|
|
36
|
+
* @property {Array} candidates 候选项列表
|
|
37
|
+
* @property {String} emptyTips 筛选结果为空时显示的文字
|
|
38
|
+
* @property {String} value 组合框的值
|
|
39
|
+
*/
|
|
40
|
+
export default {
|
|
41
|
+
name: 'uniCombox',
|
|
42
|
+
emits: ['input', 'update:modelValue'],
|
|
43
|
+
props: {
|
|
44
|
+
border: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: true
|
|
47
|
+
},
|
|
48
|
+
label: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: ''
|
|
51
|
+
},
|
|
52
|
+
labelWidth: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: 'auto'
|
|
55
|
+
},
|
|
56
|
+
placeholder: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: ''
|
|
59
|
+
},
|
|
60
|
+
candidates: {
|
|
61
|
+
type: Array,
|
|
62
|
+
default () {
|
|
63
|
+
return []
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
emptyTips: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: '无匹配项'
|
|
69
|
+
},
|
|
70
|
+
// #ifndef VUE3
|
|
71
|
+
value: {
|
|
72
|
+
type: [String, Number],
|
|
73
|
+
default: ''
|
|
74
|
+
},
|
|
75
|
+
// #endif
|
|
76
|
+
// #ifdef VUE3
|
|
77
|
+
modelValue: {
|
|
78
|
+
type: [String, Number],
|
|
79
|
+
default: ''
|
|
80
|
+
},
|
|
81
|
+
// #endif
|
|
82
|
+
},
|
|
83
|
+
data() {
|
|
84
|
+
return {
|
|
85
|
+
showSelector: false,
|
|
86
|
+
inputVal: '',
|
|
87
|
+
blurTimer:null,
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
computed: {
|
|
91
|
+
labelStyle() {
|
|
92
|
+
if (this.labelWidth === 'auto') {
|
|
93
|
+
return ""
|
|
94
|
+
}
|
|
95
|
+
return `width: ${this.labelWidth}`
|
|
96
|
+
},
|
|
97
|
+
filterCandidates() {
|
|
98
|
+
if (this.inputVal !== 0 && !this.inputVal) {
|
|
99
|
+
return this.candidates
|
|
100
|
+
}
|
|
101
|
+
return this.candidates.filter((item) => {
|
|
102
|
+
return item.toString().indexOf(this.inputVal) > -1
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
filterCandidatesLength() {
|
|
106
|
+
return this.filterCandidates.length
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
watch: {
|
|
110
|
+
// #ifndef VUE3
|
|
111
|
+
value: {
|
|
112
|
+
handler(newVal) {
|
|
113
|
+
this.inputVal = newVal
|
|
114
|
+
},
|
|
115
|
+
immediate: true
|
|
116
|
+
},
|
|
117
|
+
// #endif
|
|
118
|
+
// #ifdef VUE3
|
|
119
|
+
modelValue: {
|
|
120
|
+
handler(newVal) {
|
|
121
|
+
this.inputVal = newVal
|
|
122
|
+
},
|
|
123
|
+
immediate: true
|
|
124
|
+
},
|
|
125
|
+
// #endif
|
|
126
|
+
},
|
|
127
|
+
methods: {
|
|
128
|
+
toggleSelector() {
|
|
129
|
+
this.showSelector = !this.showSelector
|
|
130
|
+
},
|
|
131
|
+
onFocus() {
|
|
132
|
+
this.showSelector = true
|
|
133
|
+
},
|
|
134
|
+
onBlur() {
|
|
135
|
+
this.blurTimer = setTimeout(() => {
|
|
136
|
+
this.showSelector = false
|
|
137
|
+
}, 153)
|
|
138
|
+
},
|
|
139
|
+
onScroll(){ // 滚动时将blur的定时器关掉
|
|
140
|
+
if(this.blurTimer) {
|
|
141
|
+
clearTimeout(this.blurTimer)
|
|
142
|
+
this.blurTimer = null
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
onSelectorClick(index) {
|
|
146
|
+
this.inputVal = this.filterCandidates[index]
|
|
147
|
+
this.showSelector = false
|
|
148
|
+
this.$emit('input', this.inputVal)
|
|
149
|
+
this.$emit('update:modelValue', this.inputVal)
|
|
150
|
+
},
|
|
151
|
+
onInput() {
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
this.$emit('input', this.inputVal)
|
|
154
|
+
this.$emit('update:modelValue', this.inputVal)
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
</script>
|
|
160
|
+
|
|
161
|
+
<style lang="scss">
|
|
162
|
+
.uni-combox {
|
|
163
|
+
font-size: 14px;
|
|
164
|
+
border: 1px solid #DCDFE6;
|
|
165
|
+
border-radius: 4px;
|
|
166
|
+
padding: 6px 10px;
|
|
167
|
+
position: relative;
|
|
168
|
+
/* #ifndef APP-NVUE */
|
|
169
|
+
display: flex;
|
|
170
|
+
/* #endif */
|
|
171
|
+
// height: 40px;
|
|
172
|
+
flex-direction: row;
|
|
173
|
+
align-items: center;
|
|
174
|
+
// border-bottom: solid 1px #DDDDDD;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.uni-combox__label {
|
|
178
|
+
font-size: 16px;
|
|
179
|
+
line-height: 22px;
|
|
180
|
+
padding-right: 10px;
|
|
181
|
+
color: #999999;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.uni-combox__input-box {
|
|
185
|
+
position: relative;
|
|
186
|
+
/* #ifndef APP-NVUE */
|
|
187
|
+
display: flex;
|
|
188
|
+
/* #endif */
|
|
189
|
+
flex: 1;
|
|
190
|
+
flex-direction: row;
|
|
191
|
+
align-items: center;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.uni-combox__input {
|
|
195
|
+
flex: 1;
|
|
196
|
+
font-size: 14px;
|
|
197
|
+
height: 22px;
|
|
198
|
+
line-height: 22px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.uni-combox__input-plac {
|
|
202
|
+
font-size: 14px;
|
|
203
|
+
color: #999;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.uni-combox__selector {
|
|
207
|
+
/* #ifndef APP-NVUE */
|
|
208
|
+
box-sizing: border-box;
|
|
209
|
+
/* #endif */
|
|
210
|
+
position: absolute;
|
|
211
|
+
top: calc(100% + 12px);
|
|
212
|
+
left: 0;
|
|
213
|
+
width: 100%;
|
|
214
|
+
background-color: #FFFFFF;
|
|
215
|
+
border: 1px solid #EBEEF5;
|
|
216
|
+
border-radius: 6px;
|
|
217
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
218
|
+
z-index: 3;
|
|
219
|
+
padding: 4px 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.uni-combox__selector-scroll {
|
|
223
|
+
/* #ifndef APP-NVUE */
|
|
224
|
+
max-height: 200px;
|
|
225
|
+
box-sizing: border-box;
|
|
226
|
+
/* #endif */
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.uni-combox__selector-empty,
|
|
230
|
+
.uni-combox__selector-item {
|
|
231
|
+
/* #ifndef APP-NVUE */
|
|
232
|
+
display: flex;
|
|
233
|
+
cursor: pointer;
|
|
234
|
+
/* #endif */
|
|
235
|
+
line-height: 36px;
|
|
236
|
+
font-size: 14px;
|
|
237
|
+
text-align: center;
|
|
238
|
+
// border-bottom: solid 1px #DDDDDD;
|
|
239
|
+
padding: 0px 10px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.uni-combox__selector-item:hover {
|
|
243
|
+
background-color: #f9f9f9;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.uni-combox__selector-empty:last-child,
|
|
247
|
+
.uni-combox__selector-item:last-child {
|
|
248
|
+
/* #ifndef APP-NVUE */
|
|
249
|
+
border-bottom: none;
|
|
250
|
+
/* #endif */
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// picker 弹出层通用的指示小三角
|
|
254
|
+
.uni-popper__arrow,
|
|
255
|
+
.uni-popper__arrow::after {
|
|
256
|
+
position: absolute;
|
|
257
|
+
display: block;
|
|
258
|
+
width: 0;
|
|
259
|
+
height: 0;
|
|
260
|
+
border-color: transparent;
|
|
261
|
+
border-style: solid;
|
|
262
|
+
border-width: 6px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.uni-popper__arrow {
|
|
266
|
+
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
|
|
267
|
+
top: -6px;
|
|
268
|
+
left: 10%;
|
|
269
|
+
margin-right: 3px;
|
|
270
|
+
border-top-width: 0;
|
|
271
|
+
border-bottom-color: #EBEEF5;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.uni-popper__arrow::after {
|
|
275
|
+
content: " ";
|
|
276
|
+
top: 1px;
|
|
277
|
+
margin-left: -6px;
|
|
278
|
+
border-top-width: 0;
|
|
279
|
+
border-bottom-color: #fff;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.uni-combox__no-border {
|
|
283
|
+
border: none;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.uni-combox__mask {
|
|
287
|
+
width:100%;
|
|
288
|
+
height:100%;
|
|
289
|
+
position: fixed;
|
|
290
|
+
top: 0;
|
|
291
|
+
left: 0;
|
|
292
|
+
z-index: 1;
|
|
293
|
+
}
|
|
294
|
+
</style>
|