@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,660 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-easyinput" :class="{ 'uni-easyinput-error': msg }" :style="boxStyle">
|
|
3
|
+
<view class="uni-easyinput__content" :class="inputContentClass" :style="inputContentStyle">
|
|
4
|
+
<uni-icons v-if="prefixIcon" class="content-clear-icon" :type="prefixIcon" color="#c0c4cc" @click="onClickIcon('prefix')" size="22"></uni-icons>
|
|
5
|
+
<textarea
|
|
6
|
+
v-if="type === 'textarea'"
|
|
7
|
+
class="uni-easyinput__content-textarea"
|
|
8
|
+
:class="{ 'input-padding': inputBorder }"
|
|
9
|
+
:name="name"
|
|
10
|
+
:value="val"
|
|
11
|
+
:placeholder="placeholder"
|
|
12
|
+
:placeholderStyle="placeholderStyle"
|
|
13
|
+
:disabled="disabled"
|
|
14
|
+
placeholder-class="uni-easyinput__placeholder-class"
|
|
15
|
+
:maxlength="inputMaxlength"
|
|
16
|
+
:focus="focused"
|
|
17
|
+
:autoHeight="autoHeight"
|
|
18
|
+
:cursor-spacing="cursorSpacing"
|
|
19
|
+
@input="onInput"
|
|
20
|
+
@blur="_Blur"
|
|
21
|
+
@focus="_Focus"
|
|
22
|
+
@confirm="onConfirm"
|
|
23
|
+
@keyboardheightchange="onkeyboardheightchange"
|
|
24
|
+
></textarea>
|
|
25
|
+
<input
|
|
26
|
+
v-else
|
|
27
|
+
:type="type === 'password' ? 'text' : type"
|
|
28
|
+
class="uni-easyinput__content-input"
|
|
29
|
+
:style="inputStyle"
|
|
30
|
+
:name="name"
|
|
31
|
+
:value="val"
|
|
32
|
+
:password="!showPassword && type === 'password'"
|
|
33
|
+
:placeholder="placeholder"
|
|
34
|
+
:placeholderStyle="placeholderStyle"
|
|
35
|
+
placeholder-class="uni-easyinput__placeholder-class"
|
|
36
|
+
:disabled="disabled"
|
|
37
|
+
:maxlength="inputMaxlength"
|
|
38
|
+
:focus="focused"
|
|
39
|
+
:confirmType="confirmType"
|
|
40
|
+
:cursor-spacing="cursorSpacing"
|
|
41
|
+
@focus="_Focus"
|
|
42
|
+
@blur="_Blur"
|
|
43
|
+
@input="onInput"
|
|
44
|
+
@confirm="onConfirm"
|
|
45
|
+
@keyboardheightchange="onkeyboardheightchange"
|
|
46
|
+
/>
|
|
47
|
+
<template v-if="type === 'password' && passwordIcon">
|
|
48
|
+
<!-- 开启密码时显示小眼睛 -->
|
|
49
|
+
<uni-icons
|
|
50
|
+
v-if="isVal"
|
|
51
|
+
class="content-clear-icon"
|
|
52
|
+
:class="{ 'is-textarea-icon': type === 'textarea' }"
|
|
53
|
+
:type="showPassword ? 'eye-slash-filled' : 'eye-filled'"
|
|
54
|
+
:size="22"
|
|
55
|
+
:color="focusShow ? primaryColor : '#c0c4cc'"
|
|
56
|
+
@click="onEyes"
|
|
57
|
+
></uni-icons>
|
|
58
|
+
</template>
|
|
59
|
+
<template v-else-if="suffixIcon">
|
|
60
|
+
<uni-icons v-if="suffixIcon" class="content-clear-icon" :type="suffixIcon" color="#c0c4cc" @click="onClickIcon('suffix')" size="22"></uni-icons>
|
|
61
|
+
</template>
|
|
62
|
+
<template v-else>
|
|
63
|
+
<uni-icons
|
|
64
|
+
v-if="clearable && isVal && !disabled && type !== 'textarea'"
|
|
65
|
+
class="content-clear-icon"
|
|
66
|
+
:class="{ 'is-textarea-icon': type === 'textarea' }"
|
|
67
|
+
type="clear"
|
|
68
|
+
:size="clearSize"
|
|
69
|
+
:color="msg ? '#dd524d' : focusShow ? primaryColor : '#c0c4cc'"
|
|
70
|
+
@click="onClear"
|
|
71
|
+
></uni-icons>
|
|
72
|
+
</template>
|
|
73
|
+
<slot name="right"></slot>
|
|
74
|
+
</view>
|
|
75
|
+
</view>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script>
|
|
79
|
+
import { defineComponent } from 'vue';
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Easyinput 输入框
|
|
83
|
+
* @description 此组件可以实现表单的输入与校验,包括 "text" 和 "textarea" 类型。
|
|
84
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=3455
|
|
85
|
+
* @property {String} value 输入内容
|
|
86
|
+
* @property {String } type 输入框的类型(默认text) password/text/textarea/..
|
|
87
|
+
* @value text 文本输入键盘
|
|
88
|
+
* @value textarea 多行文本输入键盘
|
|
89
|
+
* @value password 密码输入键盘
|
|
90
|
+
* @value number 数字输入键盘,注意iOS上app-vue弹出的数字键盘并非9宫格方式
|
|
91
|
+
* @value idcard 身份证输入键盘,信、支付宝、百度、QQ小程序
|
|
92
|
+
* @value digit 带小数点的数字键盘 ,App的nvue页面、微信、支付宝、百度、头条、QQ小程序支持
|
|
93
|
+
* @property {Boolean} clearable 是否显示右侧清空内容的图标控件,点击可清空输入框内容(默认true)
|
|
94
|
+
* @property {Boolean} autoHeight 是否自动增高输入区域,type为textarea时有效(默认true)
|
|
95
|
+
* @property {String } placeholder 输入框的提示文字
|
|
96
|
+
* @property {String } placeholderStyle placeholder的样式(内联样式,字符串),如"color: #ddd"
|
|
97
|
+
* @property {Boolean} focus 是否自动获得焦点(默认false)
|
|
98
|
+
* @property {Boolean} disabled 是否禁用(默认false)
|
|
99
|
+
* @property {Number } maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认140)
|
|
100
|
+
* @property {String } confirmType 设置键盘右下角按钮的文字,仅在type="text"时生效(默认done)
|
|
101
|
+
* @property {Number } clearSize 清除图标的大小,单位px(默认15)
|
|
102
|
+
* @property {String} prefixIcon 输入框头部图标
|
|
103
|
+
* @property {String} suffixIcon 输入框尾部图标
|
|
104
|
+
* @property {String} primaryColor 设置主题色(默认#2979ff)
|
|
105
|
+
* @property {Boolean} trim 是否自动去除两端的空格
|
|
106
|
+
* @property {Boolean} cursorSpacing 指定光标与键盘的距离,单位 px
|
|
107
|
+
* @value both 去除两端空格
|
|
108
|
+
* @value left 去除左侧空格
|
|
109
|
+
* @value right 去除右侧空格
|
|
110
|
+
* @value start 去除左侧空格
|
|
111
|
+
* @value end 去除右侧空格
|
|
112
|
+
* @value all 去除全部空格
|
|
113
|
+
* @value none 不去除空格
|
|
114
|
+
* @property {Boolean} inputBorder 是否显示input输入框的边框(默认true)
|
|
115
|
+
* @property {Boolean} passwordIcon type=password时是否显示小眼睛图标
|
|
116
|
+
* @property {Object} styles 自定义颜色
|
|
117
|
+
* @event {Function} input 输入框内容发生变化时触发
|
|
118
|
+
* @event {Function} focus 输入框获得焦点时触发
|
|
119
|
+
* @event {Function} blur 输入框失去焦点时触发
|
|
120
|
+
* @event {Function} confirm 点击完成按钮时触发
|
|
121
|
+
* @event {Function} iconClick 点击图标时触发
|
|
122
|
+
* @example <uni-easyinput v-model="mobile"></uni-easyinput>
|
|
123
|
+
*/
|
|
124
|
+
function obj2strClass(obj) {
|
|
125
|
+
let classess = '';
|
|
126
|
+
for (let key in obj) {
|
|
127
|
+
const val = obj[key];
|
|
128
|
+
if (val) {
|
|
129
|
+
classess += `${key} `;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return classess;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function obj2strStyle(obj) {
|
|
136
|
+
let style = '';
|
|
137
|
+
for (let key in obj) {
|
|
138
|
+
const val = obj[key];
|
|
139
|
+
style += `${key}:${val};`;
|
|
140
|
+
}
|
|
141
|
+
return style;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export default defineComponent({
|
|
145
|
+
name: 'UniEasyinput',
|
|
146
|
+
emits: ['click', 'iconClick', 'update:modelValue', 'input', 'focus', 'blur', 'confirm', 'clear', 'eyes', 'change', 'keyboardheightchange'],
|
|
147
|
+
model: {
|
|
148
|
+
prop: 'modelValue',
|
|
149
|
+
event: 'update:modelValue',
|
|
150
|
+
},
|
|
151
|
+
options: {
|
|
152
|
+
virtualHost: true,
|
|
153
|
+
},
|
|
154
|
+
inject: {
|
|
155
|
+
form: {
|
|
156
|
+
from: 'uniForm',
|
|
157
|
+
default: null,
|
|
158
|
+
},
|
|
159
|
+
formItem: {
|
|
160
|
+
from: 'uniFormItem',
|
|
161
|
+
default: null,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
props: {
|
|
165
|
+
name: String,
|
|
166
|
+
value: [Number, String],
|
|
167
|
+
modelValue: [Number, String],
|
|
168
|
+
type: {
|
|
169
|
+
type: String,
|
|
170
|
+
default: 'text',
|
|
171
|
+
},
|
|
172
|
+
clearable: {
|
|
173
|
+
type: Boolean,
|
|
174
|
+
default: true,
|
|
175
|
+
},
|
|
176
|
+
autoHeight: {
|
|
177
|
+
type: Boolean,
|
|
178
|
+
default: false,
|
|
179
|
+
},
|
|
180
|
+
placeholder: {
|
|
181
|
+
type: String,
|
|
182
|
+
default: ' ',
|
|
183
|
+
},
|
|
184
|
+
placeholderStyle: String,
|
|
185
|
+
focus: {
|
|
186
|
+
type: Boolean,
|
|
187
|
+
default: false,
|
|
188
|
+
},
|
|
189
|
+
disabled: {
|
|
190
|
+
type: Boolean,
|
|
191
|
+
default: false,
|
|
192
|
+
},
|
|
193
|
+
maxlength: {
|
|
194
|
+
type: [Number, String],
|
|
195
|
+
default: 140,
|
|
196
|
+
},
|
|
197
|
+
confirmType: {
|
|
198
|
+
type: String,
|
|
199
|
+
default: 'done',
|
|
200
|
+
},
|
|
201
|
+
clearSize: {
|
|
202
|
+
type: [Number, String],
|
|
203
|
+
default: 24,
|
|
204
|
+
},
|
|
205
|
+
inputBorder: {
|
|
206
|
+
type: Boolean,
|
|
207
|
+
default: true,
|
|
208
|
+
},
|
|
209
|
+
prefixIcon: {
|
|
210
|
+
type: String,
|
|
211
|
+
default: '',
|
|
212
|
+
},
|
|
213
|
+
suffixIcon: {
|
|
214
|
+
type: String,
|
|
215
|
+
default: '',
|
|
216
|
+
},
|
|
217
|
+
trim: {
|
|
218
|
+
type: [Boolean, String],
|
|
219
|
+
default: false,
|
|
220
|
+
},
|
|
221
|
+
cursorSpacing: {
|
|
222
|
+
type: Number,
|
|
223
|
+
default: 0,
|
|
224
|
+
},
|
|
225
|
+
passwordIcon: {
|
|
226
|
+
type: Boolean,
|
|
227
|
+
default: true,
|
|
228
|
+
},
|
|
229
|
+
primaryColor: {
|
|
230
|
+
type: String,
|
|
231
|
+
default: '#2979ff',
|
|
232
|
+
},
|
|
233
|
+
styles: {
|
|
234
|
+
type: Object,
|
|
235
|
+
default() {
|
|
236
|
+
return {
|
|
237
|
+
color: '#333',
|
|
238
|
+
backgroundColor: '#fff',
|
|
239
|
+
disableColor: '#F7F6F6',
|
|
240
|
+
borderColor: '#e5e5e5',
|
|
241
|
+
};
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
errorMessage: {
|
|
245
|
+
type: [String, Boolean],
|
|
246
|
+
default: '',
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
data() {
|
|
250
|
+
return {
|
|
251
|
+
focused: false,
|
|
252
|
+
val: '',
|
|
253
|
+
showMsg: '',
|
|
254
|
+
border: false,
|
|
255
|
+
isFirstBorder: false,
|
|
256
|
+
showClearIcon: false,
|
|
257
|
+
showPassword: false,
|
|
258
|
+
focusShow: false,
|
|
259
|
+
localMsg: '',
|
|
260
|
+
isEnter: false, // 用于判断当前是否是使用回车操作
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
computed: {
|
|
264
|
+
// 输入框内是否有值
|
|
265
|
+
isVal() {
|
|
266
|
+
const val = this.val;
|
|
267
|
+
// fixed by mehaotian 处理值为0的情况,字符串0不在处理范围
|
|
268
|
+
if (val || val === 0) {
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
return false;
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
msg() {
|
|
275
|
+
// console.log('computed', this.form, this.formItem);
|
|
276
|
+
// if (this.form) {
|
|
277
|
+
// return this.errorMessage || this.formItem.errMsg;
|
|
278
|
+
// }
|
|
279
|
+
// TODO 处理头条 formItem 中 errMsg 不更新的问题
|
|
280
|
+
return this.localMsg || this.errorMessage;
|
|
281
|
+
},
|
|
282
|
+
// 因为uniapp的input组件的maxlength组件必须要数值,这里转为数值,用户可以传入字符串数值
|
|
283
|
+
inputMaxlength() {
|
|
284
|
+
return Number(this.maxlength);
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
// 处理外层样式的style
|
|
288
|
+
boxStyle() {
|
|
289
|
+
return `color:${this.inputBorder && this.msg ? '#e43d33' : this.styles.color};`;
|
|
290
|
+
},
|
|
291
|
+
// input 内容的类和样式处理
|
|
292
|
+
inputContentClass() {
|
|
293
|
+
return obj2strClass({
|
|
294
|
+
'is-input-border': this.inputBorder,
|
|
295
|
+
'is-input-error-border': this.inputBorder && this.msg,
|
|
296
|
+
'is-textarea': this.type === 'textarea',
|
|
297
|
+
'is-disabled': this.disabled,
|
|
298
|
+
'is-focused': this.focusShow,
|
|
299
|
+
});
|
|
300
|
+
},
|
|
301
|
+
inputContentStyle() {
|
|
302
|
+
const focusColor = this.focusShow ? this.primaryColor : this.styles.borderColor;
|
|
303
|
+
const borderColor = this.inputBorder && this.msg ? '#dd524d' : focusColor;
|
|
304
|
+
return obj2strStyle({
|
|
305
|
+
'border-color': borderColor || '#e5e5e5',
|
|
306
|
+
'background-color': this.disabled ? this.styles.disableColor : this.styles.backgroundColor,
|
|
307
|
+
});
|
|
308
|
+
},
|
|
309
|
+
// input右侧样式
|
|
310
|
+
inputStyle() {
|
|
311
|
+
const paddingRight = this.type === 'password' || this.clearable || this.prefixIcon ? '' : '10px';
|
|
312
|
+
return obj2strStyle({
|
|
313
|
+
'padding-right': paddingRight,
|
|
314
|
+
'padding-left': this.prefixIcon ? '' : '10px',
|
|
315
|
+
});
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
watch: {
|
|
319
|
+
value(newVal) {
|
|
320
|
+
this.val = newVal;
|
|
321
|
+
},
|
|
322
|
+
modelValue(newVal) {
|
|
323
|
+
this.val = newVal;
|
|
324
|
+
},
|
|
325
|
+
focus(newVal) {
|
|
326
|
+
this.$nextTick(() => {
|
|
327
|
+
this.focused = this.focus;
|
|
328
|
+
this.focusShow = this.focus;
|
|
329
|
+
});
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
created() {
|
|
333
|
+
this.init();
|
|
334
|
+
// TODO 处理头条vue3 computed 不监听 inject 更改的问题(formItem.errMsg)
|
|
335
|
+
if (this.form && this.formItem) {
|
|
336
|
+
this.$watch('formItem.errMsg', (newVal) => {
|
|
337
|
+
this.localMsg = newVal;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
mounted() {
|
|
342
|
+
this.$nextTick(() => {
|
|
343
|
+
this.focused = this.focus;
|
|
344
|
+
this.focusShow = this.focus;
|
|
345
|
+
});
|
|
346
|
+
},
|
|
347
|
+
methods: {
|
|
348
|
+
/**
|
|
349
|
+
* 初始化变量值
|
|
350
|
+
*/
|
|
351
|
+
init() {
|
|
352
|
+
if (this.value || this.value === 0) {
|
|
353
|
+
this.val = this.value;
|
|
354
|
+
} else if (this.modelValue || this.modelValue === 0 || this.modelValue === '') {
|
|
355
|
+
this.val = this.modelValue;
|
|
356
|
+
} else {
|
|
357
|
+
this.val = null;
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* 点击图标时触发
|
|
363
|
+
* @param {Object} type
|
|
364
|
+
*/
|
|
365
|
+
onClickIcon(type) {
|
|
366
|
+
this.$emit('iconClick', type);
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* 显示隐藏内容,密码框时生效
|
|
371
|
+
*/
|
|
372
|
+
onEyes() {
|
|
373
|
+
this.showPassword = !this.showPassword;
|
|
374
|
+
this.$emit('eyes', this.showPassword);
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* 输入时触发
|
|
379
|
+
* @param {Object} event
|
|
380
|
+
*/
|
|
381
|
+
onInput(event) {
|
|
382
|
+
let value = event.detail.value;
|
|
383
|
+
// 判断是否去除空格
|
|
384
|
+
if (this.trim) {
|
|
385
|
+
if (typeof this.trim === 'boolean' && this.trim) {
|
|
386
|
+
value = this.trimStr(value);
|
|
387
|
+
}
|
|
388
|
+
if (typeof this.trim === 'string') {
|
|
389
|
+
value = this.trimStr(value, this.trim);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (this.errMsg) this.errMsg = '';
|
|
393
|
+
this.val = value;
|
|
394
|
+
// TODO 兼容 vue2
|
|
395
|
+
this.$emit('input', value);
|
|
396
|
+
// TODO 兼容 vue3
|
|
397
|
+
this.$emit('update:modelValue', value);
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* 外部调用方法
|
|
402
|
+
* 获取焦点时触发
|
|
403
|
+
* @param {Object} event
|
|
404
|
+
*/
|
|
405
|
+
onFocus() {
|
|
406
|
+
this.$nextTick(() => {
|
|
407
|
+
this.focused = true;
|
|
408
|
+
});
|
|
409
|
+
this.$emit('focus', null);
|
|
410
|
+
},
|
|
411
|
+
|
|
412
|
+
_Focus(event) {
|
|
413
|
+
this.focusShow = true;
|
|
414
|
+
this.$emit('focus', event);
|
|
415
|
+
},
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* 外部调用方法
|
|
419
|
+
* 失去焦点时触发
|
|
420
|
+
* @param {Object} event
|
|
421
|
+
*/
|
|
422
|
+
onBlur() {
|
|
423
|
+
this.focused = false;
|
|
424
|
+
this.$emit('focus', null);
|
|
425
|
+
},
|
|
426
|
+
_Blur(event) {
|
|
427
|
+
let value = event.detail.value;
|
|
428
|
+
this.focusShow = false;
|
|
429
|
+
this.$emit('blur', event);
|
|
430
|
+
// 根据类型返回值,在event中获取的值理论上讲都是string
|
|
431
|
+
if (this.isEnter === false) {
|
|
432
|
+
this.$emit('change', this.val);
|
|
433
|
+
}
|
|
434
|
+
// 失去焦点时参与表单校验
|
|
435
|
+
if (this.form && this.formItem) {
|
|
436
|
+
const { validateTrigger } = this.form;
|
|
437
|
+
if (validateTrigger === 'blur') {
|
|
438
|
+
this.formItem.onFieldChange();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* 按下键盘的发送键
|
|
445
|
+
* @param {Object} e
|
|
446
|
+
*/
|
|
447
|
+
onConfirm(e) {
|
|
448
|
+
this.$emit('confirm', this.val);
|
|
449
|
+
this.isEnter = true;
|
|
450
|
+
this.$emit('change', this.val);
|
|
451
|
+
this.$nextTick(() => {
|
|
452
|
+
this.isEnter = false;
|
|
453
|
+
});
|
|
454
|
+
},
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* 清理内容
|
|
458
|
+
* @param {Object} event
|
|
459
|
+
*/
|
|
460
|
+
onClear(event) {
|
|
461
|
+
this.val = '';
|
|
462
|
+
// TODO 兼容 vue2
|
|
463
|
+
this.$emit('input', '');
|
|
464
|
+
// TODO 兼容 vue2
|
|
465
|
+
// TODO 兼容 vue3
|
|
466
|
+
this.$emit('update:modelValue', '');
|
|
467
|
+
// 点击叉号触发
|
|
468
|
+
this.$emit('clear');
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* 键盘高度发生变化的时候触发此事件
|
|
473
|
+
* 兼容性:微信小程序2.7.0+、App 3.1.0+
|
|
474
|
+
* @param {Object} event
|
|
475
|
+
*/
|
|
476
|
+
onkeyboardheightchange(event) {
|
|
477
|
+
this.$emit('keyboardheightchange', event);
|
|
478
|
+
},
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* 去除空格
|
|
482
|
+
*/
|
|
483
|
+
trimStr(str, pos = 'both') {
|
|
484
|
+
if (pos === 'both') {
|
|
485
|
+
return str.trim();
|
|
486
|
+
} else if (pos === 'left') {
|
|
487
|
+
return str.trimLeft();
|
|
488
|
+
} else if (pos === 'right') {
|
|
489
|
+
return str.trimRight();
|
|
490
|
+
} else if (pos === 'start') {
|
|
491
|
+
return str.trimStart();
|
|
492
|
+
} else if (pos === 'end') {
|
|
493
|
+
return str.trimEnd();
|
|
494
|
+
} else if (pos === 'all') {
|
|
495
|
+
return str.replace(/\s+/g, '');
|
|
496
|
+
} else if (pos === 'none') {
|
|
497
|
+
return str;
|
|
498
|
+
}
|
|
499
|
+
return str;
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
});
|
|
503
|
+
</script>
|
|
504
|
+
|
|
505
|
+
<style lang="scss">
|
|
506
|
+
$uni-error: #e43d33;
|
|
507
|
+
$uni-border-1: #dcdfe6 !default;
|
|
508
|
+
|
|
509
|
+
.uni-easyinput {
|
|
510
|
+
/* #ifndef APP-NVUE */
|
|
511
|
+
width: 100%;
|
|
512
|
+
/* #endif */
|
|
513
|
+
flex: 1;
|
|
514
|
+
position: relative;
|
|
515
|
+
text-align: left;
|
|
516
|
+
color: #333;
|
|
517
|
+
font-size: 14px;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.uni-easyinput__content {
|
|
521
|
+
flex: 1;
|
|
522
|
+
/* #ifndef APP-NVUE */
|
|
523
|
+
width: 100%;
|
|
524
|
+
display: flex;
|
|
525
|
+
box-sizing: border-box;
|
|
526
|
+
// min-height: 36px;
|
|
527
|
+
/* #endif */
|
|
528
|
+
flex-direction: row;
|
|
529
|
+
align-items: center;
|
|
530
|
+
// 处理border动画刚开始显示黑色的问题
|
|
531
|
+
border-color: #fff;
|
|
532
|
+
transition-property: border-color;
|
|
533
|
+
transition-duration: 0.3s;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.uni-easyinput__content-input {
|
|
537
|
+
/* #ifndef APP-NVUE */
|
|
538
|
+
width: auto;
|
|
539
|
+
/* #endif */
|
|
540
|
+
position: relative;
|
|
541
|
+
overflow: hidden;
|
|
542
|
+
flex: 1;
|
|
543
|
+
line-height: 1;
|
|
544
|
+
font-size: 14px;
|
|
545
|
+
height: 35px;
|
|
546
|
+
// min-height: 36px;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.uni-easyinput__placeholder-class {
|
|
550
|
+
color: #999;
|
|
551
|
+
font-size: 12px;
|
|
552
|
+
// font-weight: 200;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
.is-textarea {
|
|
556
|
+
align-items: flex-start;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
.is-textarea-icon {
|
|
560
|
+
margin-top: 5px;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.uni-easyinput__content-textarea {
|
|
564
|
+
position: relative;
|
|
565
|
+
overflow: hidden;
|
|
566
|
+
flex: 1;
|
|
567
|
+
line-height: 1.5;
|
|
568
|
+
font-size: 14px;
|
|
569
|
+
margin: 6px;
|
|
570
|
+
margin-left: 0;
|
|
571
|
+
height: 80px;
|
|
572
|
+
min-height: 80px;
|
|
573
|
+
/* #ifndef APP-NVUE */
|
|
574
|
+
min-height: 80px;
|
|
575
|
+
width: auto;
|
|
576
|
+
/* #endif */
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
.input-padding {
|
|
580
|
+
padding-left: 10px;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.content-clear-icon {
|
|
584
|
+
padding: 0 5px;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.label-icon {
|
|
588
|
+
margin-right: 5px;
|
|
589
|
+
margin-top: -1px;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// 显示边框
|
|
593
|
+
.is-input-border {
|
|
594
|
+
/* #ifndef APP-NVUE */
|
|
595
|
+
display: flex;
|
|
596
|
+
box-sizing: border-box;
|
|
597
|
+
/* #endif */
|
|
598
|
+
flex-direction: row;
|
|
599
|
+
align-items: center;
|
|
600
|
+
border: 1px solid $uni-border-1;
|
|
601
|
+
border-radius: 4px;
|
|
602
|
+
/* #ifdef MP-ALIPAY */
|
|
603
|
+
overflow: hidden;
|
|
604
|
+
/* #endif */
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.uni-error-message {
|
|
608
|
+
position: absolute;
|
|
609
|
+
bottom: -17px;
|
|
610
|
+
left: 0;
|
|
611
|
+
line-height: 12px;
|
|
612
|
+
color: $uni-error;
|
|
613
|
+
font-size: 12px;
|
|
614
|
+
text-align: left;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
.uni-error-msg--boeder {
|
|
618
|
+
position: relative;
|
|
619
|
+
bottom: 0;
|
|
620
|
+
line-height: 22px;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.is-input-error-border {
|
|
624
|
+
border-color: $uni-error;
|
|
625
|
+
|
|
626
|
+
.uni-easyinput__placeholder-class {
|
|
627
|
+
color: mix(#fff, $uni-error, 50%);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.uni-easyinput--border {
|
|
632
|
+
margin-bottom: 0;
|
|
633
|
+
padding: 10px 15px;
|
|
634
|
+
// padding-bottom: 0;
|
|
635
|
+
border-top: 1px #eee solid;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.uni-easyinput-error {
|
|
639
|
+
padding-bottom: 0;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.is-first-border {
|
|
643
|
+
/* #ifndef APP-NVUE */
|
|
644
|
+
border: none;
|
|
645
|
+
/* #endif */
|
|
646
|
+
/* #ifdef APP-NVUE */
|
|
647
|
+
border-width: 0;
|
|
648
|
+
/* #endif */
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
.is-disabled {
|
|
652
|
+
background-color: #f7f6f6;
|
|
653
|
+
color: #d5d5d5;
|
|
654
|
+
|
|
655
|
+
.uni-easyinput__placeholder-class {
|
|
656
|
+
color: #d5d5d5;
|
|
657
|
+
font-size: 12px;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
</style>
|