123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <template>
- <button
- :class="[
- 'k-btn',
- { 'k-btn--disabled': disabled || loading },
- { 'k-btn--outline': type === 'outline' },
- { 'k-btn--text': type === 'plain' || type === 'text' || type === 'icon' },
- ]"
- :open-type="openType"
- :style="[
- {
- borderColor: borderColor
- ? borderColor
- : type === 'default'
- ? bgColor
- : type === 'plain' || type === 'text' || type === 'icon'
- ? 'transparent'
- : '',
- color: color
- ? color
- : type !== 'text' && type !== 'outline'
- ? '#ffffff'
- : '',
- backgroundColor: bgColor
- ? bgColor
- : type === 'outline' ||
- type === 'plain' ||
- type === 'text' ||
- type === 'icon'
- ? 'transparent'
- : '',
- height:
- height ||
- (size === 'auto' || type === 'text' || type === 'icon'
- ? 'auto'
- : '90px'),
- fontSize: fontSize ? fontSize : type === 'text' ? '30px' : '34px',
- width:
- width ||
- (size === 'auto' || type === 'text' || type === 'icon'
- ? 'auto'
- : size === 'large'
- ? '420px'
- : size === 'middle'
- ? '380px'
- : size === 'small'
- ? '330px'
- : '690px'),
- padding: padding ? padding : 'auto',
- },
- activeColor ? { '--k-color-primary-active': activeColor } : {},
- disabledColor ? { '--k-color-primary-disabled': disabledColor } : {},
- ]"
- :disabled="disabled || loading"
- @click.stop="onClick"
- :loading="loading"
- @getuserinfo="onGetuserinfo"
- @getphonenumber="onGetphonenumber"
- >
- <slot name="left"/>
- <k-icon
- v-if="type == 'icon'"
- :name="icon"
- :size="31"
- :color="color"
- style="margin-right: 8px;"
- />
- {{ title }}
- <slot />
- </button>
- </template>
- <script>
- export default {
- name: 'k-button',
- props: {
- title: String,
- openType: String,
- icon: String,
- opacity: String,
- disabled: {
- type: Boolean,
- default: false,
- },
- loading: Boolean,
- type: {
- type: String,
- default: 'default', // 'default' | 'outline' | 'plain' | 'text'
- },
- size: {
- type: String,
- default: 'normal', // 'normal' | 'large' | 'middle' | 'small' | 'auto'
- },
- width: {
- type: String,
- default: '', // 'auto' | '100px'
- },
- height: {
- type: String,
- default: '',
- },
- color: {
- type: String,
- default: '',
- },
- fontSize: {
- type: String,
- default: '',
- },
- bgColor: {
- type: String,
- default: '',
- },
- borderColor: {
- type: String,
- default: '',
- },
- padding: String,
- status: String, // active | disabled | loading
- activeColor: String,
- disabledColor: String,
- },
- methods: {
- onClick() {
- this.$emit('click');
- },
- onGetuserinfo(e) {
- this.$emit('getuserinfo', e);
- },
- onGetphonenumber(e) {
- this.$emit('getphonenumber', e);
- },
- },
- };
- </script>
- <style scoped lang="less">
- /* stylelint-disable selector-class-pattern */
- /* stylelint-disable declaration-no-important */
- /* stylelint-disable comment-empty-line-before */
- .k-btn {
- width: 200px;
- height: 50px;
- border-radius: 60px;
- border: 1px solid var(--k-color-primary, #000);
- outline: none;
- line-height: 1.5;
- display: inline-flex;
- justify-content: center;
- align-items: center;
- margin: auto;
- background: var(--k-color-primary, #000);
- color: var(--k-color-primary, #000);
- &::after {
- display: none;
- }
- &:not(.k-btn--disabled):not(.k-btn--outline):not(.k-btn--text):active {
- background: var(--k-color-primary-active, #000) !important;
- border: 1px solid var(--k-color-primary-active, #000) !important;
- }
- }
- .k-btn--disabled {
- background: var(--k-color-primary-disabled, #000) !important;
- border: 1px solid var(--k-color-primary-disabled, #000) !important;
- }
- .k-btn--text {
- background: transparent !important;
- border: none !important;
- &:active {
- color: var(--k-color-primary-active, #000) !important;
- }
- }
- .k-btn--outline {
- &:active {
- background: transparent;
- border: 1px solid var(--k-color-primary-active, #000) !important;
- color: var(--k-color-primary-active, #000) !important;
- }
- }
- </style>
|