@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,287 @@
1
+ <template>
2
+ <view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick">
3
+ <slot></slot>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import {
9
+ createAnimation
10
+ } from './createAnimation'
11
+
12
+ /**
13
+ * Transition 过渡动画
14
+ * @description 简单过渡动画组件
15
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=985
16
+ * @property {Boolean} show = [false|true] 控制组件显示或隐藏
17
+ * @property {Array|String} modeClass = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 过渡动画类型
18
+ * @value fade 渐隐渐出过渡
19
+ * @value slide-top 由上至下过渡
20
+ * @value slide-right 由右至左过渡
21
+ * @value slide-bottom 由下至上过渡
22
+ * @value slide-left 由左至右过渡
23
+ * @value zoom-in 由小到大过渡
24
+ * @value zoom-out 由大到小过渡
25
+ * @property {Number} duration 过渡动画持续时间
26
+ * @property {Object} styles 组件样式,同 css 样式,注意带’-‘连接符的属性需要使用小驼峰写法如:`backgroundColor:red`
27
+ */
28
+ export default {
29
+ name: 'uniTransition',
30
+ emits: ['click', 'change'],
31
+ props: {
32
+ show: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ modeClass: {
37
+ type: [Array, String],
38
+ default () {
39
+ return 'fade'
40
+ }
41
+ },
42
+ duration: {
43
+ type: Number,
44
+ default: 300
45
+ },
46
+ styles: {
47
+ type: Object,
48
+ default () {
49
+ return {}
50
+ }
51
+ },
52
+ customClass: {
53
+ type: String,
54
+ default: ''
55
+ }
56
+ },
57
+ data() {
58
+ return {
59
+ isShow: false,
60
+ transform: '',
61
+ opacity: 1,
62
+ animationData: {},
63
+ durationTime: 300,
64
+ config: {}
65
+ }
66
+ },
67
+ watch: {
68
+ show: {
69
+ handler(newVal) {
70
+ if (newVal) {
71
+ this.open()
72
+ } else {
73
+ // 避免上来就执行 close,导致动画错乱
74
+ if (this.isShow) {
75
+ this.close()
76
+ }
77
+ }
78
+ },
79
+ immediate: true
80
+ }
81
+ },
82
+ computed: {
83
+ // 生成样式数据
84
+ stylesObject() {
85
+ let styles = {
86
+ ...this.styles,
87
+ 'transition-duration': this.duration / 1000 + 's'
88
+ }
89
+ let transform = ''
90
+ for (let i in styles) {
91
+ let line = this.toLine(i)
92
+ transform += line + ':' + styles[i] + ';'
93
+ }
94
+ return transform
95
+ },
96
+ // 初始化动画条件
97
+ transformStyles() {
98
+ return 'transform:' + this.transform + ';' + 'opacity:' + this.opacity + ';' + this.stylesObject
99
+ }
100
+ },
101
+ created() {
102
+ // 动画默认配置
103
+ this.config = {
104
+ duration: this.duration,
105
+ timingFunction: 'ease',
106
+ transformOrigin: '50% 50%',
107
+ delay: 0
108
+ }
109
+ this.durationTime = this.duration
110
+ },
111
+ methods: {
112
+ /**
113
+ * ref 触发 初始化动画
114
+ */
115
+ init(obj = {}) {
116
+ if (obj.duration) {
117
+ this.durationTime = obj.duration
118
+ }
119
+ this.animation = createAnimation(Object.assign(this.config, obj))
120
+ },
121
+ /**
122
+ * 点击组件触发回调
123
+ */
124
+ onClick() {
125
+ this.$emit('click', {
126
+ detail: this.isShow
127
+ })
128
+ },
129
+ /**
130
+ * ref 触发 动画分组
131
+ * @param {Object} obj
132
+ */
133
+ step(obj, config = {}) {
134
+ if (!this.animation) return
135
+ for (let i in obj) {
136
+ try {
137
+ if (typeof obj[i] === 'object') {
138
+ this.animation[i](...obj[i])
139
+ } else {
140
+ this.animation[i](obj[i])
141
+ }
142
+ } catch (e) {
143
+ console.error(`方法 ${i} 不存在`)
144
+ }
145
+ }
146
+ this.animation.step(config)
147
+ return this
148
+ },
149
+ /**
150
+ * ref 触发 执行动画
151
+ */
152
+ run(fn) {
153
+ if (!this.animation) return
154
+ this.animation.run(fn)
155
+ },
156
+ // 开始过度动画
157
+ open() {
158
+ clearTimeout(this.timer)
159
+ this.transform = ''
160
+ this.isShow = true
161
+ let {
162
+ opacity,
163
+ transform
164
+ } = this.styleInit(false)
165
+ if (typeof opacity !== 'undefined') {
166
+ this.opacity = opacity
167
+ }
168
+ this.transform = transform
169
+ // 确保动态样式已经生效后,执行动画,如果不加 nextTick ,会导致 wx 动画执行异常
170
+ this.$nextTick(() => {
171
+ // TODO 定时器保证动画完全执行,目前有些问题,后面会取消定时器
172
+ this.timer = setTimeout(() => {
173
+ this.animation = createAnimation(this.config, this)
174
+ this.tranfromInit(false).step()
175
+ this.animation.run()
176
+ this.$emit('change', {
177
+ detail: this.isShow
178
+ })
179
+ }, 20)
180
+ })
181
+ },
182
+ // 关闭过度动画
183
+ close(type) {
184
+ if (!this.animation) return
185
+ this.tranfromInit(true)
186
+ .step()
187
+ .run(() => {
188
+ this.isShow = false
189
+ this.animationData = null
190
+ this.animation = null
191
+ let {
192
+ opacity,
193
+ transform
194
+ } = this.styleInit(false)
195
+ this.opacity = opacity || 1
196
+ this.transform = transform
197
+ this.$emit('change', {
198
+ detail: this.isShow
199
+ })
200
+ })
201
+ },
202
+ // 处理动画开始前的默认样式
203
+ styleInit(type) {
204
+ let styles = {
205
+ transform: ''
206
+ }
207
+ let buildStyle = (type, mode) => {
208
+ if (mode === 'fade') {
209
+ styles.opacity = this.animationType(type)[mode]
210
+ } else {
211
+ styles.transform += this.animationType(type)[mode] + ' '
212
+ }
213
+ }
214
+ if (typeof this.modeClass === 'string') {
215
+ buildStyle(type, this.modeClass)
216
+ } else {
217
+ this.modeClass.forEach(mode => {
218
+ buildStyle(type, mode)
219
+ })
220
+ }
221
+ return styles
222
+ },
223
+ // 处理内置组合动画
224
+ tranfromInit(type) {
225
+ let buildTranfrom = (type, mode) => {
226
+ let aniNum = null
227
+ if (mode === 'fade') {
228
+ aniNum = type ? 0 : 1
229
+ } else {
230
+ aniNum = type ? '-100%' : '0'
231
+ if (mode === 'zoom-in') {
232
+ aniNum = type ? 0.8 : 1
233
+ }
234
+ if (mode === 'zoom-out') {
235
+ aniNum = type ? 1.2 : 1
236
+ }
237
+ if (mode === 'slide-right') {
238
+ aniNum = type ? '100%' : '0'
239
+ }
240
+ if (mode === 'slide-bottom') {
241
+ aniNum = type ? '100%' : '0'
242
+ }
243
+ }
244
+ this.animation[this.animationMode()[mode]](aniNum)
245
+ }
246
+ if (typeof this.modeClass === 'string') {
247
+ buildTranfrom(type, this.modeClass)
248
+ } else {
249
+ this.modeClass.forEach(mode => {
250
+ buildTranfrom(type, mode)
251
+ })
252
+ }
253
+
254
+ return this.animation
255
+ },
256
+ animationType(type) {
257
+ return {
258
+ fade: type ? 1 : 0,
259
+ 'slide-top': `translateY(${type ? '0' : '-100%'})`,
260
+ 'slide-right': `translateX(${type ? '0' : '100%'})`,
261
+ 'slide-bottom': `translateY(${type ? '0' : '100%'})`,
262
+ 'slide-left': `translateX(${type ? '0' : '-100%'})`,
263
+ 'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
264
+ 'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`
265
+ }
266
+ },
267
+ // 内置动画类型与实际动画对应字典
268
+ animationMode() {
269
+ return {
270
+ fade: 'opacity',
271
+ 'slide-top': 'translateY',
272
+ 'slide-right': 'translateX',
273
+ 'slide-bottom': 'translateY',
274
+ 'slide-left': 'translateX',
275
+ 'zoom-in': 'scale',
276
+ 'zoom-out': 'scale'
277
+ }
278
+ },
279
+ // 驼峰转中横线
280
+ toLine(name) {
281
+ return name.replace(/([A-Z])/g, '-$1').toLowerCase()
282
+ }
283
+ }
284
+ }
285
+ </script>
286
+
287
+ <style scoped></style>
@@ -1,249 +0,0 @@
1
- <template>
2
- <view class="uni-badge--x">
3
- <slot />
4
- <text
5
- v-if="text"
6
- :class="classNames"
7
- :style="[badgeWidth, positionStyle, customStyle, dotStyle]"
8
- class="uni-badge"
9
- @click="onClick()"
10
- >
11
- {{ displayValue }}
12
- </text>
13
- </view>
14
- </template>
15
-
16
- <script>
17
- /**
18
- * Badge 数字角标
19
- * @description 数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景
20
- * @tutorial https://ext.dcloud.net.cn/plugin?id=21
21
- * @property {String} text 角标内容
22
- * @property {String} type = [default|primary|success|warning|error] 颜色类型
23
- * @value default 灰色
24
- * @value primary 蓝色
25
- * @value success 绿色
26
- * @value warning 黄色
27
- * @value error 红色
28
- * @property {String} size = [normal|small] Badge 大小
29
- * @value normal 一般尺寸
30
- * @value small 小尺寸
31
- * @property {String} inverted = [true|false] 是否无需背景颜色
32
- * @event {Function} click 点击 Badge 触发事件
33
- * @example <cv-badge text="1"></cv-badge>
34
- */
35
- export default {
36
- name: 'cvBadge',
37
- emits: ['click'],
38
- props: {
39
- type: {
40
- type: String,
41
- default: 'default'
42
- },
43
- inverted: {
44
- type: Boolean,
45
- default: false
46
- },
47
- isDot: {
48
- type: Boolean,
49
- default: false
50
- },
51
- maxNum: {
52
- type: Number,
53
- default: 99
54
- },
55
- absolute: {
56
- type: String,
57
- default: ''
58
- },
59
- offset: {
60
- type: Array,
61
- default() {
62
- return [0, 0];
63
- }
64
- },
65
- text: {
66
- type: [String, Number],
67
- default: ''
68
- },
69
- size: {
70
- type: String,
71
- default: 'normal'
72
- },
73
- customStyle: {
74
- type: Object,
75
- default() {
76
- return {};
77
- }
78
- }
79
- },
80
- data() {
81
- return {};
82
- },
83
- computed: {
84
- width() {
85
- return String(this.text).length * 8 + 12;
86
- },
87
- classNames() {
88
- const { inverted, type, size, absolute } = this;
89
- return [
90
- inverted ? 'uni-badge--' + type + '-inverted' : '',
91
- 'uni-badge--' + type,
92
- 'uni-badge--' + size,
93
- absolute ? 'uni-badge--absolute' : ''
94
- ];
95
- },
96
- positionStyle() {
97
- if (!this.absolute) return {};
98
- let w = this.width / 2,
99
- h = 10;
100
- if (this.isDot) {
101
- w = 5;
102
- h = 5;
103
- }
104
- const x = `${-w + this.offset[0]}px`;
105
- const y = `${-h + this.offset[1]}px`;
106
-
107
- const whiteList = {
108
- rightTop: {
109
- right: x,
110
- top: y
111
- },
112
- rightBottom: {
113
- right: x,
114
- bottom: y
115
- },
116
- leftBottom: {
117
- left: x,
118
- bottom: y
119
- },
120
- leftTop: {
121
- left: x,
122
- top: y
123
- }
124
- };
125
- const match = whiteList[this.absolute];
126
- return match ? match : whiteList['rightTop'];
127
- },
128
- badgeWidth() {
129
- return {
130
- width: `${this.width}px`
131
- };
132
- },
133
- dotStyle() {
134
- if (!this.isDot) return {};
135
- return {
136
- width: '10px',
137
- height: '10px',
138
- borderRadius: '10px'
139
- };
140
- },
141
- displayValue() {
142
- const { isDot, text, maxNum } = this;
143
- return isDot ? '' : Number(text) > maxNum ? `${maxNum}+` : text;
144
- }
145
- },
146
- methods: {
147
- onClick() {
148
- this.$emit('click');
149
- }
150
- }
151
- };
152
- </script>
153
-
154
- <style scoped>
155
- .uni-badge--x {
156
- /* #ifdef APP-NVUE */
157
- /* #endif */
158
- /* #ifndef APP-NVUE */
159
- display: inline-block;
160
- /* #endif */
161
- position: relative;
162
- }
163
-
164
- .uni-badge--absolute {
165
- position: absolute;
166
- }
167
-
168
- .uni-badge {
169
- /* #ifndef APP-NVUE */
170
- display: flex;
171
- overflow: hidden;
172
- box-sizing: border-box;
173
- /* #endif */
174
- justify-content: center;
175
- flex-direction: row;
176
- height: 20px;
177
- line-height: 20px;
178
- color: #333;
179
- border-radius: 100px;
180
- background-color: #f1f1f1;
181
- background-color: transparent;
182
- text-align: center;
183
- font-family: 'Helvetica Neue', Helvetica, sans-serif;
184
- font-size: 12px;
185
- /* #ifdef H5 */
186
- cursor: pointer;
187
- /* #endif */
188
- }
189
-
190
- .uni-badge--inverted {
191
- padding: 0 5px 0 0;
192
- color: #f1f1f1;
193
- }
194
-
195
- .uni-badge--default {
196
- color: #333;
197
- background-color: #f1f1f1;
198
- }
199
-
200
- .uni-badge--default-inverted {
201
- color: #999;
202
- background-color: transparent;
203
- }
204
-
205
- .uni-badge--primary {
206
- color: #fff;
207
- background-color: #007aff;
208
- }
209
-
210
- .uni-badge--primary-inverted {
211
- color: #007aff;
212
- background-color: transparent;
213
- }
214
-
215
- .uni-badge--success {
216
- color: #fff;
217
- background-color: #4cd964;
218
- }
219
-
220
- .uni-badge--success-inverted {
221
- color: #4cd964;
222
- background-color: transparent;
223
- }
224
-
225
- .uni-badge--warning {
226
- color: #fff;
227
- background-color: #f0ad4e;
228
- }
229
-
230
- .uni-badge--warning-inverted {
231
- color: #f0ad4e;
232
- background-color: transparent;
233
- }
234
-
235
- .uni-badge--error {
236
- color: #fff;
237
- background-color: #dd524d;
238
- }
239
-
240
- .uni-badge--error-inverted {
241
- color: #dd524d;
242
- background-color: transparent;
243
- }
244
-
245
- .uni-badge--small {
246
- transform: scale(0.8);
247
- transform-origin: center center;
248
- }
249
- </style>