@10yun/cv-mobile-ui 0.4.2 → 0.4.4

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.
Files changed (168) hide show
  1. package/package.json +1 -1
  2. package/ui-cv/cv-form-item/cv-form-item.vue +1 -1
  3. package/ui-cv/cv-input-password/cv-input-password.vue +2 -2
  4. package/ui-uni/amap-wx/js/util.js +166 -158
  5. package/ui-uni/page-foot/page-foot.vue +38 -0
  6. package/ui-uni/page-head/page-head.vue +16 -0
  7. package/ui-uni/product.vue +52 -52
  8. package/ui-uni/u-charts/u-charts.js +743 -1092
  9. package/ui-uni/u-link/u-link.vue +59 -0
  10. package/ui-uni/uni-badge/uni-badge.vue +250 -0
  11. package/ui-uni/uni-calendar/calendar.js +546 -0
  12. package/ui-uni/uni-calendar/uni-calendar-item.vue +171 -0
  13. package/ui-uni/uni-calendar/uni-calendar.vue +504 -0
  14. package/{ui-cv/cv-calendar → ui-uni/uni-calendar}/util.js +0 -0
  15. package/ui-uni/uni-card/uni-card.vue +420 -0
  16. package/ui-uni/uni-col/uni-col.vue +2968 -0
  17. package/ui-uni/uni-collapse/uni-collapse.vue +146 -0
  18. package/ui-uni/uni-collapse-item/uni-collapse-item.vue +378 -0
  19. package/ui-uni/uni-combox/uni-combox.vue +237 -0
  20. package/ui-uni/uni-countdown/uni-countdown.vue +234 -0
  21. package/ui-uni/uni-data-checkbox/uni-data-checkbox.vue +792 -0
  22. package/{ui-cv/cv-data-indexed-list → ui-uni/uni-data-indexed-list}/clientdb.js +0 -0
  23. package/ui-uni/uni-data-indexed-list/uni-data-indexed-list-item.vue +142 -0
  24. package/ui-uni/uni-data-indexed-list/uni-data-indexed-list.vue +364 -0
  25. package/{ui-cv/cv-data-picker → ui-uni/uni-data-picker}/keypress.js +0 -0
  26. package/ui-uni/uni-data-picker/uni-data-picker.vue +468 -0
  27. package/{ui-cv/cv-data-pickerview/cv-data-picker.js → ui-uni/uni-data-pickerview/uni-data-picker.js} +0 -0
  28. package/ui-uni/uni-data-pickerview/uni-data-pickerview.vue +298 -0
  29. package/{ui-cv/cv-dateformat → ui-uni/uni-dateformat}/date-format.js +0 -0
  30. package/ui-uni/uni-dateformat/uni-dateformat.vue +88 -0
  31. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar-item.vue +0 -0
  32. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar.js +0 -0
  33. package/ui-uni/uni-datetime-picker/calendar.vue +747 -0
  34. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/keypress.js +0 -0
  35. package/ui-uni/uni-datetime-picker/time-picker.vue +899 -0
  36. package/ui-uni/uni-datetime-picker/uni-datetime-picker.vue +874 -0
  37. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/util.js +0 -0
  38. package/ui-uni/uni-drawer/keypress.js +45 -0
  39. package/ui-uni/uni-drawer/uni-drawer.vue +178 -0
  40. package/{ui-cv/cv-easyinput → ui-uni/uni-easyinput}/common.js +0 -0
  41. package/ui-uni/uni-easyinput/uni-easyinput.vue +438 -0
  42. package/ui-uni/uni-fab/uni-fab.vue +443 -0
  43. package/{ui-cv/cv-fab/cv-fab.vue.bak → ui-uni/uni-fab/uni-fab.vue.bak} +2 -2
  44. package/ui-uni/uni-fav/uni-fav.vue +136 -0
  45. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/choose-and-upload-file.js +0 -0
  46. package/ui-uni/uni-file-picker/uni-file-picker.vue +614 -0
  47. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-file.vue +0 -0
  48. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-image.vue +0 -0
  49. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/utils.js +0 -0
  50. package/ui-uni/uni-forms/uni-forms.vue +467 -0
  51. package/ui-uni/uni-forms/validate.js +486 -0
  52. package/ui-uni/uni-forms-item/uni-forms-item.vue +500 -0
  53. package/{ui-cv/cv-goods-nav/cv-goods-nav.vue → ui-uni/uni-goods-nav/uni-goods-nav.vue} +1 -1
  54. package/ui-uni/uni-grid/uni-grid.vue +141 -0
  55. package/ui-uni/uni-grid-item/uni-grid-item.vue +123 -0
  56. package/ui-uni/uni-group/uni-group.vue +123 -0
  57. package/ui-uni/uni-icons/icons.js +132 -0
  58. package/ui-uni/uni-icons/uni-icons.vue +72 -0
  59. package/{ui-cv/cv-icon2 → ui-uni/uni-icons}/uni.ttf +0 -0
  60. package/ui-uni/uni-indexed-list/uni-indexed-list-item.vue +142 -0
  61. package/ui-uni/uni-indexed-list/uni-indexed-list.vue +357 -0
  62. package/ui-uni/uni-link/uni-link.vue +117 -0
  63. package/ui-uni/uni-list/uni-list.vue +107 -0
  64. package/ui-uni/uni-list/uni-refresh.vue +65 -0
  65. package/{ui-cv/cv-list → ui-uni/uni-list}/uni-refresh.wxs +0 -0
  66. package/ui-uni/uni-list-ad/uni-list-ad.vue +106 -0
  67. package/{ui-cv/cv-list-chat/cv-list-chat.scss → ui-uni/uni-list-chat/uni-list-chat.scss} +0 -0
  68. package/{ui-cv/cv-list-chat/cv-list-chat.vue → ui-uni/uni-list-chat/uni-list-chat.vue} +0 -0
  69. package/ui-uni/uni-list-item/uni-list-item.vue +428 -0
  70. package/ui-uni/uni-load-more/uni-load-more.vue +366 -0
  71. package/ui-uni/uni-nav-bar/uni-nav-bar.vue +244 -0
  72. package/{ui-cv/cv-nav-bar/cv-status-bar.vue → ui-uni/uni-nav-bar/uni-status-bar.vue} +0 -0
  73. package/ui-uni/uni-notice-bar/uni-notice-bar.vue +394 -0
  74. package/ui-uni/uni-number-box/uni-number-box.vue +224 -0
  75. package/ui-uni/uni-pagination/uni-pagination.vue +376 -0
  76. package/{ui-cv/cv-popup → ui-uni/uni-popup}/keypress.js +0 -0
  77. package/{ui-cv/cv-popup → ui-uni/uni-popup}/popup.js +0 -0
  78. package/ui-uni/uni-popup/uni-popup.vue +412 -0
  79. package/{ui-cv/cv-popup-dialog → ui-uni/uni-popup-dialog}/keypress.js +0 -0
  80. package/{ui-cv/cv-popup-dialog/cv-popup-dialog.vue → ui-uni/uni-popup-dialog/uni-popup-dialog.vue} +0 -0
  81. package/ui-uni/uni-popup-message/uni-popup-message.vue +143 -0
  82. package/{ui-cv/cv-popup-share/cv-popup-share.vue → ui-uni/uni-popup-share/uni-popup-share.vue} +0 -0
  83. package/ui-uni/uni-rate/uni-rate.vue +357 -0
  84. package/ui-uni/uni-row/uni-row.vue +155 -0
  85. package/ui-uni/uni-search-bar/uni-search-bar.vue +262 -0
  86. package/{ui-cv/cv-section/cv-section.vue → ui-uni/uni-section/uni-section.vue} +0 -0
  87. package/{ui-cv/cv-segmented-control/cv-segmented-control.vue → ui-uni/uni-segmented-control/uni-segmented-control.vue} +0 -0
  88. package/{ui-cv/cv-status-bar/cv-status-bar.vue → ui-uni/uni-status-bar/uni-status-bar.vue} +0 -0
  89. package/ui-uni/uni-steps/uni-steps.vue +250 -0
  90. package/{ui-cv/cv-swipe-action/cv-swipe-action.vue → ui-uni/uni-swipe-action/uni-swipe-action.vue} +0 -0
  91. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/bindingx.js +0 -0
  92. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/index.wxs +0 -0
  93. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/isPC.js +0 -0
  94. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpalipay.js +0 -0
  95. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpother.js +0 -0
  96. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpwxs.js +0 -0
  97. 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
  98. package/ui-uni/uni-swiper-dot/uni-swiper-dot.vue +205 -0
  99. package/ui-uni/uni-table/uni-table.vue +455 -0
  100. package/ui-uni/uni-tag/uni-tag.vue +283 -0
  101. package/ui-uni/uni-tbody/uni-tbody.vue +30 -0
  102. package/ui-uni/uni-td/uni-td.vue +88 -0
  103. package/{ui-cv/cv-test/cv-test.vue → ui-uni/uni-test/uni-test.vue} +0 -0
  104. package/{ui-cv/cv-th → ui-uni/uni-th}/filter-dropdown.vue +0 -0
  105. package/ui-uni/uni-th/uni-th.vue +259 -0
  106. package/ui-uni/uni-thead/uni-thead.vue +114 -0
  107. package/ui-uni/uni-title/uni-title.vue +171 -0
  108. package/{ui-cv/cv-tr → ui-uni/uni-tr}/table-checkbox.vue +0 -0
  109. package/ui-uni/uni-tr/uni-tr.vue +156 -0
  110. package/{ui-cv/cv-transition → ui-uni/uni-transition}/createAnimation.js +0 -0
  111. package/ui-uni/uni-transition/uni-transition.vue +287 -0
  112. package/ui-cv/cv-badge/cv-badge.vue +0 -249
  113. package/ui-cv/cv-calendar/calendar.js +0 -963
  114. package/ui-cv/cv-calendar/cv-calendar-item.vue +0 -198
  115. package/ui-cv/cv-calendar/cv-calendar.vue +0 -508
  116. package/ui-cv/cv-card/cv-card.vue +0 -427
  117. package/ui-cv/cv-col/cv-col.vue +0 -2965
  118. package/ui-cv/cv-collapse/cv-collapse.vue +0 -146
  119. package/ui-cv/cv-collapse-item/cv-collapse-item.vue +0 -395
  120. package/ui-cv/cv-combox/cv-combox.vue +0 -250
  121. package/ui-cv/cv-countdown/cv-countdown.vue +0 -245
  122. package/ui-cv/cv-data-checkbox/cv-data-checkbox.vue +0 -841
  123. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list-item.vue +0 -154
  124. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list.vue +0 -376
  125. package/ui-cv/cv-data-picker/cv-data-picker.vue +0 -486
  126. package/ui-cv/cv-data-pickerview/cv-data-pickerview.vue +0 -304
  127. package/ui-cv/cv-dateformat/cv-dateformat.vue +0 -86
  128. package/ui-cv/cv-datetime-picker/calendar.vue +0 -761
  129. package/ui-cv/cv-datetime-picker/cv-datetime-picker.vue +0 -958
  130. package/ui-cv/cv-datetime-picker/time-picker.vue +0 -907
  131. package/ui-cv/cv-drawer/cv-drawer.vue +0 -185
  132. package/ui-cv/cv-drawer/keypress.js +0 -45
  133. package/ui-cv/cv-easyinput/cv-easyinput.vue +0 -514
  134. package/ui-cv/cv-fab/cv-fab.vue +0 -465
  135. package/ui-cv/cv-fav/cv-fav.vue +0 -150
  136. package/ui-cv/cv-file-picker/cv-file-picker.vue +0 -619
  137. package/ui-cv/cv-form-base/cv-form-base.vue +0 -470
  138. package/ui-cv/cv-form-base/validate.js +0 -477
  139. package/ui-cv/cv-grid-group/cv-grid-group.vue +0 -148
  140. package/ui-cv/cv-grid-item/cv-grid-item.vue +0 -132
  141. package/ui-cv/cv-icon2/cv-icon2.vue +0 -78
  142. package/ui-cv/cv-icon2/icons.js +0 -132
  143. package/ui-cv/cv-indexed-list/cv-indexed-list-item.vue +0 -154
  144. package/ui-cv/cv-indexed-list/cv-indexed-list.vue +0 -371
  145. package/ui-cv/cv-link2/cv-link2.vue +0 -130
  146. package/ui-cv/cv-list/cv-list.vue +0 -107
  147. package/ui-cv/cv-list/cv-refresh.vue +0 -65
  148. package/ui-cv/cv-list-ad/cv-list-ad.vue +0 -113
  149. package/ui-cv/cv-list-item/cv-list-item.vue +0 -449
  150. package/ui-cv/cv-nav-bar/cv-nav-bar.vue +0 -256
  151. package/ui-cv/cv-notice-bar/cv-notice-bar.vue +0 -453
  152. package/ui-cv/cv-number-box/cv-number-box.vue +0 -223
  153. package/ui-cv/cv-pagination/cv-pagination.vue +0 -397
  154. package/ui-cv/cv-popup/cv-popup.vue +0 -429
  155. package/ui-cv/cv-popup-message/cv-popup-message.vue +0 -143
  156. package/ui-cv/cv-row/cv-row.vue +0 -157
  157. package/ui-cv/cv-search-bar/cv-search-bar.vue +0 -280
  158. package/ui-cv/cv-steps/cv-steps.vue +0 -293
  159. package/ui-cv/cv-swiper-dot/cv-swiper-dot.vue +0 -255
  160. package/ui-cv/cv-table/cv-table.vue +0 -460
  161. package/ui-cv/cv-tag/cv-tag.vue +0 -276
  162. package/ui-cv/cv-tbody/cv-tbody.vue +0 -28
  163. package/ui-cv/cv-td/cv-td.vue +0 -93
  164. package/ui-cv/cv-th/cv-th.vue +0 -270
  165. package/ui-cv/cv-thead/cv-thead.vue +0 -114
  166. package/ui-cv/cv-title/cv-title.vue +0 -168
  167. package/ui-cv/cv-tr/cv-tr.vue +0 -166
  168. package/ui-cv/cv-transition/cv-transition.vue +0 -279
@@ -0,0 +1,45 @@
1
+ // #ifdef H5
2
+ export default {
3
+ name: 'Keypress',
4
+ props: {
5
+ disable: {
6
+ type: Boolean,
7
+ default: false
8
+ }
9
+ },
10
+ mounted () {
11
+ const keyNames = {
12
+ esc: ['Esc', 'Escape'],
13
+ tab: 'Tab',
14
+ enter: 'Enter',
15
+ space: [' ', 'Spacebar'],
16
+ up: ['Up', 'ArrowUp'],
17
+ left: ['Left', 'ArrowLeft'],
18
+ right: ['Right', 'ArrowRight'],
19
+ down: ['Down', 'ArrowDown'],
20
+ delete: ['Backspace', 'Delete', 'Del']
21
+ }
22
+ const listener = ($event) => {
23
+ if (this.disable) {
24
+ return
25
+ }
26
+ const keyName = Object.keys(keyNames).find(key => {
27
+ const keyName = $event.key
28
+ const value = keyNames[key]
29
+ return value === keyName || (Array.isArray(value) && value.includes(keyName))
30
+ })
31
+ if (keyName) {
32
+ // 避免和其他按键事件冲突
33
+ setTimeout(() => {
34
+ this.$emit(keyName, {})
35
+ }, 0)
36
+ }
37
+ }
38
+ document.addEventListener('keyup', listener)
39
+ // this.$once('hook:beforeDestroy', () => {
40
+ // document.removeEventListener('keyup', listener)
41
+ // })
42
+ },
43
+ render: () => {}
44
+ }
45
+ // #endif
@@ -0,0 +1,178 @@
1
+ <template>
2
+ <view v-if="visibleSync" :class="{ 'uni-drawer--visible': showDrawer }" class="uni-drawer" @touchmove.stop.prevent="clear">
3
+ <view class="uni-drawer__mask" :class="{ 'uni-drawer__mask--visible': showDrawer && mask }" @tap="close('mask')" />
4
+ <view class="uni-drawer__content" :class="{'uni-drawer--right': rightMode,'uni-drawer--left': !rightMode, 'uni-drawer__content--visible': showDrawer}" :style="{width:drawerWidth+'px'}">
5
+ <slot />
6
+ </view>
7
+ <!-- #ifdef H5 -->
8
+ <keypress @esc="close('mask')" />
9
+ <!-- #endif -->
10
+ </view>
11
+ </template>
12
+
13
+ <script>
14
+ // #ifdef H5
15
+ import keypress from './keypress.js'
16
+ // #endif
17
+ /**
18
+ * Drawer 抽屉
19
+ * @description 抽屉侧滑菜单
20
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=26
21
+ * @property {Boolean} mask = [true | false] 是否显示遮罩
22
+ * @property {Boolean} maskClick = [true | false] 点击遮罩是否关闭
23
+ * @property {Boolean} mode = [left | right] Drawer 滑出位置
24
+ * @value left 从左侧滑出
25
+ * @value right 从右侧侧滑出
26
+ * @property {Number} width 抽屉的宽度 ,仅 vue 页面生效
27
+ * @event {Function} close 组件关闭时触发事件
28
+ */
29
+ export default {
30
+ name: 'UniDrawer',
31
+ components: {
32
+ // #ifdef H5
33
+ keypress
34
+ // #endif
35
+ },
36
+ emits: ['change'],
37
+ props: {
38
+ /**
39
+ * 显示模式(左、右),只在初始化生效
40
+ */
41
+ mode: {
42
+ type: String,
43
+ default: ''
44
+ },
45
+ /**
46
+ * 蒙层显示状态
47
+ */
48
+ mask: {
49
+ type: Boolean,
50
+ default: true
51
+ },
52
+ /**
53
+ * 遮罩是否可点击关闭
54
+ */
55
+ maskClick: {
56
+ type: Boolean,
57
+ default: true
58
+ },
59
+ /**
60
+ * 抽屉宽度
61
+ */
62
+ width: {
63
+ type: Number,
64
+ default: 220
65
+ }
66
+ },
67
+ data() {
68
+ return {
69
+ visibleSync: false,
70
+ showDrawer: false,
71
+ rightMode: false,
72
+ watchTimer: null,
73
+ drawerWidth: 220
74
+ }
75
+ },
76
+ created() {
77
+ // #ifndef APP-NVUE
78
+ this.drawerWidth = this.width
79
+ // #endif
80
+ this.rightMode = this.mode === 'right'
81
+ },
82
+ methods: {
83
+ clear() {},
84
+ close(type) {
85
+ // fixed by mehaotian 抽屉尚未完全关闭或遮罩禁止点击时不触发以下逻辑
86
+ if ((type === 'mask' && !this.maskClick) || !this.visibleSync) return
87
+ this._change('showDrawer', 'visibleSync', false)
88
+ },
89
+ open() {
90
+ // fixed by mehaotian 处理重复点击打开的事件
91
+ if (this.visibleSync) return
92
+ this._change('visibleSync', 'showDrawer', true)
93
+ },
94
+ _change(param1, param2, status) {
95
+ this[param1] = status
96
+ if (this.watchTimer) {
97
+ clearTimeout(this.watchTimer)
98
+ }
99
+ this.watchTimer = setTimeout(() => {
100
+ this[param2] = status
101
+ this.$emit('change', status)
102
+ }, status ? 50 : 300)
103
+ }
104
+ }
105
+ }
106
+ </script>
107
+
108
+ <style scoped>
109
+ .uni-drawer {
110
+ /* #ifndef APP-NVUE */
111
+ display: block;
112
+ /* #endif */
113
+ position: fixed;
114
+ top: 0;
115
+ left: 0;
116
+ right: 0;
117
+ bottom: 0;
118
+ overflow: hidden;
119
+ z-index: 999;
120
+ }
121
+
122
+ .uni-drawer__content {
123
+ /* #ifndef APP-NVUE */
124
+ display: block;
125
+ /* #endif */
126
+ position: absolute;
127
+ top: 0;
128
+ width: 220px;
129
+ bottom: 0;
130
+ background-color: #ffffff;
131
+ transition: transform 0.3s ease;
132
+ }
133
+
134
+ .uni-drawer--left {
135
+ left: 0;
136
+ /* #ifdef APP-NVUE */
137
+ transform: translateX(-220px);
138
+ /* #endif */
139
+ /* #ifndef APP-NVUE */
140
+ transform: translateX(-100%);
141
+ /* #endif */
142
+ }
143
+
144
+ .uni-drawer--right {
145
+ right: 0;
146
+ /* #ifdef APP-NVUE */
147
+ transform: translateX(220px);
148
+ /* #endif */
149
+ /* #ifndef APP-NVUE */
150
+ transform: translateX(100%);
151
+ /* #endif */
152
+ }
153
+
154
+ .uni-drawer__content--visible {
155
+ transform: translateX(0px);
156
+ }
157
+
158
+ .uni-drawer__mask {
159
+ /* #ifndef APP-NVUE */
160
+ display: block;
161
+ /* #endif */
162
+ opacity: 0;
163
+ position: absolute;
164
+ top: 0;
165
+ left: 0;
166
+ bottom: 0;
167
+ right: 0;
168
+ background-color: rgba(0, 0, 0, 0.4);
169
+ transition: opacity 0.3s;
170
+ }
171
+
172
+ .uni-drawer__mask--visible {
173
+ /* #ifndef APP-NVUE */
174
+ display: block;
175
+ /* #endif */
176
+ opacity: 1;
177
+ }
178
+ </style>
@@ -0,0 +1,438 @@
1
+ <template>
2
+ <view class="uni-easyinput" :class="{'uni-easyinput-error':msg}" :style="{color:inputBorder && msg?'#dd524d':styles.color}">
3
+ <view class="uni-easyinput__content" :class="{'is-input-border':inputBorder ,'is-input-error-border':inputBorder && msg,'is-textarea':type==='textarea','is-disabled':disabled}" :style="{'border-color':inputBorder && msg?'#dd524d':styles.borderColor,'background-color':disabled?styles.disableColor:''}">
4
+ <uni-icons v-if="prefixIcon" class="content-clear-icon" :type="prefixIcon" color="#c0c4cc" @click="onClickIcon('prefix')"></uni-icons>
5
+ <textarea v-if="type === 'textarea'" class="uni-easyinput__content-textarea" :class="{'input-padding':inputBorder}" :name="name" :value="val" :placeholder="placeholder" :placeholderStyle="placeholderStyle" :disabled="disabled" :maxlength="inputMaxlength" :focus="focused" :autoHeight="autoHeight" @input="onInput" @blur="onBlur" @focus="onFocus" @confirm="onConfirm"></textarea>
6
+ <input v-else :type="type === 'password'?'text':type" class="uni-easyinput__content-input" :style="{
7
+ 'padding-right':type === 'password' ||clearable || prefixIcon?'':'10px',
8
+ 'padding-left':prefixIcon?'':'10px'
9
+ }" :name="name" :value="val" :password="!showPassword && type === 'password'" :placeholder="placeholder" :placeholderStyle="placeholderStyle" :disabled="disabled" :maxlength="inputMaxlength" :focus="focused" :confirmType="confirmType" @focus="onFocus" @blur="onBlur" @input="onInput" @confirm="onConfirm" />
10
+ <template v-if="type === 'password' && passwordIcon">
11
+ <uni-icons v-if="val != '' " class="content-clear-icon" :class="{'is-textarea-icon':type==='textarea'}" :type="showPassword?'eye-slash-filled':'eye-filled'" :size="18" color="#c0c4cc" @click="onEyes"></uni-icons>
12
+ </template>
13
+ <template v-else-if="suffixIcon">
14
+ <uni-icons v-if="suffixIcon" class="content-clear-icon" :type="suffixIcon" color="#c0c4cc" @click="onClickIcon('suffix')"></uni-icons>
15
+ </template>
16
+ <template v-else>
17
+ <uni-icons class="content-clear-icon" :class="{'is-textarea-icon':type==='textarea'}" type="clear" :size="clearSize" v-if="clearable && val && !disabled" color="#c0c4cc" @click="onClear"></uni-icons>
18
+ </template>
19
+ <slot name="right"></slot>
20
+ </view>
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ // import {
26
+ // debounce,
27
+ // throttle
28
+ // } from './common.js'
29
+ /**
30
+ * Easyinput 输入框
31
+ * @description 此组件可以实现表单的输入与校验,包括 "text" 和 "textarea" 类型。
32
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=3455
33
+ * @property {String} value 输入内容
34
+ * @property {String } type 输入框的类型(默认text) password/text/textarea/..
35
+ * @value text 文本输入键盘
36
+ * @value textarea 多行文本输入键盘
37
+ * @value password 密码输入键盘
38
+ * @value number 数字输入键盘,注意iOS上app-vue弹出的数字键盘并非9宫格方式
39
+ * @value idcard 身份证输入键盘,信、支付宝、百度、QQ小程序
40
+ * @value digit 带小数点的数字键盘 ,App的nvue页面、微信、支付宝、百度、头条、QQ小程序支持
41
+ * @property {Boolean} clearable 是否显示右侧清空内容的图标控件,点击可清空输入框内容(默认true)
42
+ * @property {Boolean} autoHeight 是否自动增高输入区域,type为textarea时有效(默认true)
43
+ * @property {String } placeholder 输入框的提示文字
44
+ * @property {String } placeholderStyle placeholder的样式(内联样式,字符串),如"color: #ddd"
45
+ * @property {Boolean} focus 是否自动获得焦点(默认false)
46
+ * @property {Boolean} disabled 是否禁用(默认false)
47
+ * @property {Number } maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认140)
48
+ * @property {String } confirmType 设置键盘右下角按钮的文字,仅在type="text"时生效(默认done)
49
+ * @property {Number } clearSize 清除图标的大小,单位px(默认15)
50
+ * @property {String} prefixIcon 输入框头部图标
51
+ * @property {String} suffixIcon 输入框尾部图标
52
+ * @property {Boolean} trim 是否自动去除两端的空格
53
+ * @value both 去除两端空格
54
+ * @value left 去除左侧空格
55
+ * @value right 去除右侧空格
56
+ * @value start 去除左侧空格
57
+ * @value end 去除右侧空格
58
+ * @value all 去除全部空格
59
+ * @value none 不去除空格
60
+ * @property {Boolean} inputBorder 是否显示input输入框的边框(默认true)
61
+ * @property {Boolean} passwordIcon type=password时是否显示小眼睛图标
62
+ * @property {Object} styles 自定义颜色
63
+ * @event {Function} input 输入框内容发生变化时触发
64
+ * @event {Function} focus 输入框获得焦点时触发
65
+ * @event {Function} blur 输入框失去焦点时触发
66
+ * @event {Function} confirm 点击完成按钮时触发
67
+ * @event {Function} iconClick 点击图标时触发
68
+ * @example <uni-easyinput v-model="mobile"></uni-easyinput>
69
+ */
70
+
71
+ export default {
72
+ name: 'uni-easyinput',
73
+ emits: ['click', 'iconClick', 'update:modelValue', 'input', 'focus', 'blur', 'confirm'],
74
+ model: {
75
+ prop: 'modelValue',
76
+ event: 'update:modelValue'
77
+ },
78
+ props: {
79
+ name: String,
80
+ value: [Number, String],
81
+ modelValue: [Number, String],
82
+ type: {
83
+ type: String,
84
+ default: 'text'
85
+ },
86
+ clearable: {
87
+ type: Boolean,
88
+ default: true
89
+ },
90
+ autoHeight: {
91
+ type: Boolean,
92
+ default: false
93
+ },
94
+ placeholder: String,
95
+ placeholderStyle: String,
96
+ focus: {
97
+ type: Boolean,
98
+ default: false
99
+ },
100
+ disabled: {
101
+ type: Boolean,
102
+ default: false
103
+ },
104
+ maxlength: {
105
+ type: [Number, String],
106
+ default: 140
107
+ },
108
+ confirmType: {
109
+ type: String,
110
+ default: 'done'
111
+ },
112
+ clearSize: {
113
+ type: [Number, String],
114
+ default: 15
115
+ },
116
+ inputBorder: {
117
+ type: Boolean,
118
+ default: true
119
+ },
120
+ prefixIcon: {
121
+ type: String,
122
+ default: ''
123
+ },
124
+ suffixIcon: {
125
+ type: String,
126
+ default: ''
127
+ },
128
+ trim: {
129
+ type: [Boolean, String],
130
+ default: true
131
+ },
132
+ passwordIcon: {
133
+ type: Boolean,
134
+ default: true
135
+ },
136
+ styles: {
137
+ type: Object,
138
+ default () {
139
+ return {
140
+ color: '#333',
141
+ disableColor: '#eee',
142
+ borderColor: '#e5e5e5'
143
+ }
144
+ }
145
+ },
146
+ errorMessage: {
147
+ type: [String, Boolean],
148
+ default: ''
149
+ }
150
+ },
151
+ data() {
152
+ return {
153
+ focused: false,
154
+ errMsg: '',
155
+ val: '',
156
+ showMsg: '',
157
+ border: false,
158
+ isFirstBorder: false,
159
+ showClearIcon: false,
160
+ showPassword: false
161
+ };
162
+ },
163
+ computed: {
164
+ msg() {
165
+ return this.errorMessage || this.errMsg;
166
+ },
167
+ // 因为uniapp的input组件的maxlength组件必须要数值,这里转为数值,给用户可以传入字符串数值
168
+ inputMaxlength() {
169
+ return Number(this.maxlength);
170
+ },
171
+ },
172
+ watch: {
173
+ value(newVal) {
174
+ if (this.errMsg) this.errMsg = ''
175
+ this.val = newVal
176
+ if (this.form && this.formItem) {
177
+ this.formItem.setValue(newVal)
178
+ }
179
+ },
180
+ modelValue(newVal) {
181
+ if (this.errMsg) this.errMsg = ''
182
+ this.val = newVal
183
+ if (this.form && this.formItem) {
184
+ this.formItem.setValue(newVal)
185
+ }
186
+ },
187
+ focus(newVal) {
188
+ this.$nextTick(() => {
189
+ this.focused = this.focus
190
+ })
191
+ }
192
+ },
193
+ created() {
194
+ if (!this.value) {
195
+ this.val = this.modelValue
196
+ }
197
+ if (!this.modelValue) {
198
+ this.val = this.value
199
+ }
200
+ this.form = this.getForm('uniForms')
201
+ this.formItem = this.getForm('uniFormsItem')
202
+ if (this.form && this.formItem) {
203
+ if (this.formItem.name) {
204
+ this.rename = this.formItem.name
205
+ this.form.inputChildrens.push(this)
206
+ }
207
+ }
208
+ },
209
+ mounted() {
210
+ // this.onInput = throttle(this.input, 500)
211
+ this.$nextTick(() => {
212
+ // setTimeout(()=>{
213
+ // },1000)
214
+ this.focused = this.focus
215
+ })
216
+ },
217
+ methods: {
218
+ /**
219
+ * 初始化变量值
220
+ */
221
+ init() {
222
+
223
+ },
224
+ onClickIcon(type) {
225
+ this.$emit('iconClick', type)
226
+ },
227
+ /**
228
+ * 获取父元素实例
229
+ */
230
+ getForm(name = 'uniForms') {
231
+ let parent = this.$parent;
232
+ let parentName = parent.$options.name;
233
+ while (parentName !== name) {
234
+ parent = parent.$parent;
235
+ if (!parent) return false;
236
+ parentName = parent.$options.name;
237
+ }
238
+ return parent;
239
+ },
240
+
241
+ onEyes() {
242
+ this.showPassword = !this.showPassword
243
+ },
244
+ onInput(event) {
245
+ let value = event.detail.value;
246
+ // 判断是否去除空格
247
+ if (this.trim) {
248
+ if (typeof(this.trim) === 'boolean' && this.trim) {
249
+ value = this.trimStr(value)
250
+ }
251
+ if (typeof(this.trim) === 'string') {
252
+ value = this.trimStr(value, this.trim)
253
+ }
254
+ };
255
+ if (this.errMsg) this.errMsg = ''
256
+ this.val = value
257
+ // TODO 兼容 vue2
258
+ this.$emit('input', value);
259
+ // TODO 兼容 vue3
260
+ this.$emit('update:modelValue', value)
261
+ },
262
+
263
+ onFocus(event) {
264
+ // this.focused = true;
265
+ this.$emit('focus', event);
266
+ },
267
+ onBlur(event) {
268
+ let value = event.detail.value;
269
+ // setTimeout(() => {
270
+ // this.focused = false;
271
+ // }, 100);
272
+ this.$emit('blur', event);
273
+ },
274
+ onConfirm(e) {
275
+ this.$emit('confirm', e.detail.value);
276
+ },
277
+ onClear(event) {
278
+ this.val = '';
279
+ // TODO 兼容 vue2
280
+ this.$emit('input', '');
281
+ // TODO 兼容 vue2
282
+ // TODO 兼容 vue3
283
+ this.$emit('update:modelValue', '')
284
+ },
285
+ fieldClick() {
286
+ this.$emit('click');
287
+ },
288
+ trimStr(str, pos = 'both') {
289
+ if (pos === 'both') {
290
+ return str.trim();
291
+ } else if (pos === 'left') {
292
+ return str.trimLeft();
293
+ } else if (pos === 'right') {
294
+ return str.trimRight();
295
+ } else if (pos === 'start') {
296
+ return str.trimStart()
297
+ } else if (pos === 'end') {
298
+ return str.trimEnd()
299
+ } else if (pos === 'all') {
300
+ return str.replace(/\s+/g, '');
301
+ } else if (pos === 'none') {
302
+ return str;
303
+ }
304
+ return str;
305
+ }
306
+ }
307
+ };
308
+ </script>
309
+
310
+ <style scoped>
311
+ .uni-easyinput {
312
+ /* #ifndef APP-NVUE */
313
+ width: 100%;
314
+ /* #endif */
315
+ flex: 1;
316
+ position: relative;
317
+ text-align: left;
318
+ color: #333;
319
+ font-size: 14px;
320
+ }
321
+
322
+ .uni-easyinput__content {
323
+ flex: 1;
324
+ /* #ifndef APP-NVUE */
325
+ width: 100%;
326
+ display: flex;
327
+ box-sizing: border-box;
328
+ min-height: 36px;
329
+ /* #endif */
330
+ flex-direction: row;
331
+ align-items: center;
332
+ }
333
+
334
+ .uni-easyinput__content-input {
335
+ /* #ifndef APP-NVUE */
336
+ width: auto;
337
+ /* #endif */
338
+ position: relative;
339
+ overflow: hidden;
340
+ flex: 1;
341
+ line-height: 1;
342
+ font-size: 14px;
343
+ }
344
+
345
+ .is-textarea {
346
+ align-items: flex-start;
347
+ }
348
+
349
+ .is-textarea-icon {
350
+ margin-top: 5px;
351
+ }
352
+
353
+ .uni-easyinput__content-textarea {
354
+ position: relative;
355
+ overflow: hidden;
356
+ flex: 1;
357
+ line-height: 1.5;
358
+ font-size: 14px;
359
+ padding-top: 6px;
360
+ padding-bottom: 10px;
361
+ height: 80px;
362
+ /* #ifndef APP-NVUE */
363
+ min-height: 80px;
364
+ width: auto;
365
+ /* #endif */
366
+ }
367
+
368
+ .input-padding {
369
+ padding-left: 10px;
370
+ }
371
+
372
+ .content-clear-icon {
373
+ padding: 0 5px;
374
+ }
375
+
376
+ .label-icon {
377
+ margin-right: 5px;
378
+ margin-top: -1px;
379
+ }
380
+
381
+ .is-input-border {
382
+ /* #ifndef APP-NVUE */
383
+ display: flex;
384
+ box-sizing: border-box;
385
+ /* #endif */
386
+ flex-direction: row;
387
+ align-items: center;
388
+ border: 1px solid #e5e5e5;
389
+ border-radius: 4px;
390
+ }
391
+
392
+ .is-required {
393
+ color: #dd524d;
394
+ }
395
+
396
+ .uni-error-message {
397
+ position: absolute;
398
+ bottom: -17px;
399
+ left: 0;
400
+ line-height: 12px;
401
+ color: #dd524d;
402
+ font-size: 12px;
403
+ text-align: left;
404
+ }
405
+
406
+ .uni-error-msg--boeder {
407
+ position: relative;
408
+ bottom: 0;
409
+ line-height: 22px;
410
+ }
411
+
412
+ .is-input-error-border {
413
+ border-color: #dd524d;
414
+ }
415
+
416
+ .uni-easyinput--border {
417
+ margin-bottom: 0;
418
+ padding: 10px 15px;
419
+ border-top: 1px #eee solid;
420
+ }
421
+
422
+ .uni-easyinput-error {
423
+ padding-bottom: 0;
424
+ }
425
+
426
+ .is-first-border {
427
+ /* #ifndef APP-NVUE */
428
+ border: none;
429
+ /* #endif */
430
+ /* #ifdef APP-NVUE */
431
+ border-width: 0;
432
+ /* #endif */
433
+ }
434
+
435
+ .is-disabled {
436
+ background-color: #eee;
437
+ }
438
+ </style>