@kaiyinchem/ky-uniui 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,10 @@
1
+ ## 介绍
2
+ ````
3
+ 凯茵内部uniapp组件库,以ky-开头
4
+ ````
5
+
6
+ ## 使用
7
+ ````
8
+ npm i ky-uniui
9
+ App.vue引入var.css
10
+ ````
@@ -0,0 +1,453 @@
1
+ <template>
2
+ <view class="btn-comp">
3
+ <view
4
+ :class="{
5
+ fixed,
6
+ slotContent: $slots.content,
7
+ noContent: !$slots.content,
8
+ iphoneX: safeBottom > 0,
9
+ noPadding,
10
+ hasLeft: $slots.left
11
+ }"
12
+ :style="{height}"
13
+ class="btn-wrap"
14
+ >
15
+ <view v-if="$slots.left" class="btn-left">
16
+ <slot name="left"></slot>
17
+ </view>
18
+ <button
19
+ v-if="!$slots.content"
20
+ :style="{
21
+ width,
22
+ height,
23
+ background,
24
+ border,
25
+ 'border-radius': radius + 'rpx',
26
+ 'font-size': fontSize ? (fontSize + 'rpx') : ''
27
+ }"
28
+ :class="{
29
+ small: size === 'small',
30
+ mini: size === 'mini',
31
+ disabled: loading || disabled,
32
+ primary: type === 'primary',
33
+ success: type === 'success',
34
+ info: type === 'info',
35
+ warning: type === 'warning',
36
+ danger: type === 'danger',
37
+ text: type === 'text',
38
+ default: type === 'default',
39
+ plain,
40
+ round,
41
+ reverse,
42
+ circle
43
+ }"
44
+ :open-type="openType"
45
+ :disabled="loading || disabled"
46
+ class="btn-main"
47
+ @click.stop="onClick"
48
+ @getuserinfo="getuserinfo"
49
+ @getphonenumber="getphonenumber"
50
+ >
51
+ <image v-if="loading && !circle" class="btn-loading" src="/static/img/load.gif"></image>
52
+ <text v-if="icon && icon.indexOf('icon') > -1" :class="icon" class="btn-icon iconfont"></text>
53
+ <text v-if="icon && icon.indexOf('icon') < 0" class="btn-icon iconfont">{{ icon }}</text>
54
+ <slot v-if="!circle"></slot>
55
+ </button>
56
+ <slot v-else name="content"></slot>
57
+ </view>
58
+ <!--位置占位-->
59
+ <view
60
+ v-if="fixed"
61
+ :class="{ iphoneX: safeBottom > 0, noPadding }"
62
+ class="btn-space">
63
+ </view>
64
+ </view>
65
+ </template>
66
+
67
+ <script>
68
+ export default {
69
+ emits:['click', 'getphonenumber', 'getuserinfo'],
70
+ props: {
71
+ // 是否固定在下方
72
+ fixed: {
73
+ type: Boolean,
74
+ default: false
75
+ },
76
+ width: {
77
+ type: String,
78
+ default: ''
79
+ },
80
+ height: {
81
+ type: String,
82
+ default: ''
83
+ },
84
+ background: {
85
+ type: String,
86
+ default: ''
87
+ },
88
+ radius: {
89
+ type: String,
90
+ default: '12'
91
+ },
92
+ size: {
93
+ type: String,
94
+ default: 'normal'
95
+ },
96
+ disabled: {
97
+ type: Boolean,
98
+ default: false
99
+ },
100
+ loading: {
101
+ type: Boolean,
102
+ default: false
103
+ },
104
+ border: {
105
+ type: String,
106
+ default: ''
107
+ },
108
+ // 按钮类型 primary, success, info, warning, danger, text,
109
+ type: {
110
+ type: String,
111
+ default: 'primary'
112
+ },
113
+ // 朴素按钮
114
+ plain: {
115
+ type: Boolean,
116
+ default: false
117
+ },
118
+ // 圆角
119
+ round: {
120
+ type: Boolean,
121
+ default: false
122
+ },
123
+ // 圆形
124
+ circle: {
125
+ type: Boolean,
126
+ default: false
127
+ },
128
+ // 图标
129
+ icon: {
130
+ type: String,
131
+ default: ''
132
+ },
133
+ // 背景色左右调换
134
+ reverse: {
135
+ type: Boolean,
136
+ default: false
137
+ },
138
+ // fixed的时候是否有边距
139
+ noPadding: {
140
+ type: Boolean,
141
+ default: true
142
+ },
143
+ // 微信小程序按钮类型
144
+ openType: {
145
+ type: String,
146
+ default: ''
147
+ },
148
+
149
+ fontSize: {
150
+ type: String,
151
+ default: ''
152
+ }
153
+
154
+ },
155
+ computed: {
156
+ hasSlots() {
157
+ return Object.keys(this.$slots).length
158
+ },
159
+ safeBottom() {
160
+ return uni.getSystemInfoSync().safeAreaInsets.bottom
161
+ }
162
+ },
163
+ methods: {
164
+ onClick(e) {
165
+ this.$emit('click', e)
166
+ },
167
+ getphonenumber(res) {
168
+ this.$emit('getphonenumber', res)
169
+ },
170
+ getuserinfo(res) {
171
+ this.$emit('getuserinfo', res)
172
+ }
173
+ },
174
+ }
175
+ </script>
176
+
177
+ <style scoped lang="scss">
178
+ @mixin linear-gradient($direction, $color1, $color2) {
179
+ background: linear-gradient(to $direction, $color1, $color2);
180
+ }
181
+ .btn-main {
182
+ font-size: 28rpx;
183
+ height: 85rpx;
184
+ line-height: 28rpx;
185
+ border-radius: 12rpx;
186
+ border: none;
187
+ color: #ffffff;
188
+ text-align: center;
189
+ display: flex;
190
+ align-items: center;
191
+ justify-content: center;
192
+ padding: 0;
193
+ margin: 0;
194
+ min-width: 150rpx;
195
+ &:after {
196
+ display: none
197
+ }
198
+ &:active {
199
+ box-shadow: none;
200
+ filter: brightness(0.8);
201
+ opacity: 0.8;
202
+ }
203
+ &.nobg {
204
+ background: none!important;
205
+ &.disabled {
206
+ background: none!important;
207
+ }
208
+ }
209
+ &.small {
210
+ height: 65rpx;
211
+ line-height: 65rpx;
212
+ font-size: 26rpx;
213
+ width: auto;
214
+ }
215
+ &.mini {
216
+ height: 50rpx;
217
+ line-height: 50rpx;
218
+ font-size: 22rpx;
219
+ }
220
+ &.round {
221
+ border-radius: 45rpx!important;
222
+ &.small {
223
+ border-radius: 35rpx!important;
224
+ }
225
+ &.mini {
226
+ border-radius: 25rpx!important;
227
+ }
228
+ }
229
+ &.primary {
230
+ $color2: #b3d8ff;
231
+ $color3: var(--color-light-primary);
232
+ $color4: #dbf6f5;
233
+ background: var(--color-primary);
234
+ @include linear-gradient(right, $color3, var(--color-primary));
235
+ &.reverse {
236
+ @include linear-gradient(left, $color3, var(--color-primary));
237
+ }
238
+ &.plain {
239
+ border: 1px solid var(--color-primary);
240
+ background: $color4;
241
+ color: var(--color-primary)!important;
242
+ }
243
+ }
244
+ &.success {
245
+ $color1: #34e064;
246
+ $color2: #2fbe54;
247
+ $color3: #def9e5;
248
+ background: $color1;
249
+ @include linear-gradient(right, $color1, $color2);
250
+ &.reverse {
251
+ @include linear-gradient(left, $color1, $color2);
252
+ }
253
+ &.plain {
254
+ border: 1px solid $color1;
255
+ background: $color3;
256
+ color: $color2!important;
257
+ }
258
+ }
259
+ &.info {
260
+ $color1: #d3d4d6;
261
+ $color2: #909399;
262
+ $color3: #f4f4f5;
263
+ background: $color1;
264
+ @include linear-gradient(right, $color1, $color2);
265
+ &.reverse {
266
+ @include linear-gradient(left, $color1, $color2);
267
+ }
268
+ &.plain {
269
+ border: 1px solid $color1;
270
+ background: $color3;
271
+ color: $color2!important;
272
+ }
273
+ }
274
+ &.warning {
275
+ $color1: #ffcb00;
276
+ $color2: #ff9402;
277
+ $color3: #fdf6ec;
278
+ background: $color1;
279
+ @include linear-gradient(right, $color1, $color2);
280
+ &.reverse {
281
+ @include linear-gradient(left, $color1, $color2);
282
+ }
283
+ &.plain {
284
+ border: 1px solid $color1;
285
+ background: $color3;
286
+ color: $color2!important;
287
+ }
288
+ }
289
+ &.danger {
290
+ $color1: #ff7700;
291
+ $color2: #ff4900;
292
+ $color3: #ffefef;
293
+ background: $color1;
294
+ @include linear-gradient(right, $color1, $color2);
295
+ &.reverse {
296
+ @include linear-gradient(left, $color1, $color2);
297
+ }
298
+ &.plain {
299
+ border: 1px solid $color1;
300
+ background: $color3;
301
+ color: $color2!important;
302
+ }
303
+ }
304
+ &.default {
305
+ $color1: var(--bg-white);
306
+ $color2: var(--bg-white);
307
+ $color3: var(--bg-white);
308
+ background: $color1;
309
+ color: var(--color-dark)!important;
310
+ border: 1px solid var(--border-1);
311
+ }
312
+ &.circle {
313
+ width: 90rpx!important;
314
+ border-radius: 50%!important;
315
+ padding: 0;
316
+ .btn-icon {
317
+ margin-right: 0;
318
+ }
319
+ &.small {
320
+ width: 65rpx!important;
321
+ }
322
+ &.mini {
323
+ width: 50rpx!important;
324
+ }
325
+ }
326
+ &.disabled {
327
+ background: linear-gradient(to right, var(--border-1), var(--border-2))!important;
328
+ cursor: not-allowed!important;
329
+ color: var(--color-gray)!important;
330
+ &:active {
331
+ filter: brightness(1);
332
+ opacity: 1;
333
+ }
334
+ }
335
+ &.text {
336
+ background: none!important;
337
+ width: auto!important;
338
+ color: var(--color-primary)!important;
339
+ height: auto!important;
340
+ line-height: initial!important;
341
+ &.disabled {
342
+ color: var(--color-gray)!important;
343
+ }
344
+ }
345
+ .btn-loading {
346
+ width: 40rpx;
347
+ height: 40rpx;
348
+ display: inline-block;
349
+ margin-right: 12rpx;
350
+ }
351
+ .btn-icon {
352
+ display: inline-block;
353
+ margin-right: 12rpx;
354
+ }
355
+ }
356
+ .btn-wrap {
357
+ background: none;
358
+ &.fixed {
359
+ position: fixed;
360
+ height: 120rpx;
361
+ background: var(--bg-white);
362
+ z-index: 1;
363
+ left: 0;
364
+ bottom: 0;
365
+ right: 0;
366
+ display: flex;
367
+ align-items: center;
368
+ justify-content: space-between;
369
+ &.hasLeft {
370
+ height: 90rpx;
371
+ .btn-main {
372
+ width: 200rpx;
373
+ margin: 0;
374
+ padding: 0;
375
+ }
376
+ .btn-left {
377
+ flex: 1;
378
+ padding-left: 24rpx;
379
+ }
380
+ }
381
+ .btn-main {
382
+ width: 690rpx;
383
+ }
384
+ &.iphoneX {
385
+ height: 150rpx;
386
+ }
387
+ }
388
+ &.slotContent {
389
+ &.fixed {
390
+ height:auto;
391
+ .btn-wrap {
392
+ width: auto;
393
+ flex: 1;
394
+ }
395
+ }
396
+ }
397
+ &.noPadding {
398
+ &.fixed {
399
+ height: auto;
400
+ .btn-wrap {
401
+ margin: 0;
402
+ }
403
+ .btn-main {
404
+ width: 100%;
405
+ border-radius: 0!important;
406
+ }
407
+ &.iphoneX {
408
+ .btn-main {
409
+ height: 120rpx;
410
+ }
411
+ }
412
+ }
413
+ }
414
+ }
415
+ .btn-space {
416
+ height: 120rpx;
417
+ &.iphoneX {
418
+ height: 150rpx;
419
+ }
420
+ &.noPadding {
421
+ height: 90rpx;
422
+ &.iphoneX {
423
+ height: 120rpx;
424
+ }
425
+ }
426
+ }
427
+
428
+ @media (prefers-color-scheme: dark) {
429
+ .btn-main {
430
+ color: #bbbbbb;
431
+ &.primary {
432
+ &.plain {
433
+ background: #233838;
434
+ }
435
+ }
436
+ &.warning {
437
+ &.plain {
438
+ background: #434530;
439
+ }
440
+ }
441
+ &.danger {
442
+ &.plain {
443
+ background: #532222;
444
+ }
445
+ }
446
+ &.success {
447
+ &.plain {
448
+ background: #1a3d24;
449
+ }
450
+ }
451
+ }
452
+ }
453
+ </style>