k-button.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <button
  3. :class="[
  4. 'k-btn',
  5. { 'k-btn--disabled': disabled || loading },
  6. { 'k-btn--outline': type === 'outline' },
  7. { 'k-btn--text': type === 'plain' || type === 'text' || type === 'icon' },
  8. ]"
  9. :open-type="openType"
  10. :style="[
  11. {
  12. borderColor: borderColor
  13. ? borderColor
  14. : type === 'default'
  15. ? bgColor
  16. : type === 'plain' || type === 'text' || type === 'icon'
  17. ? 'transparent'
  18. : '',
  19. color: color
  20. ? color
  21. : type !== 'text' && type !== 'outline'
  22. ? '#ffffff'
  23. : '',
  24. backgroundColor: bgColor
  25. ? bgColor
  26. : type === 'outline' ||
  27. type === 'plain' ||
  28. type === 'text' ||
  29. type === 'icon'
  30. ? 'transparent'
  31. : '',
  32. height:
  33. height ||
  34. (size === 'auto' || type === 'text' || type === 'icon'
  35. ? 'auto'
  36. : '90px'),
  37. fontSize: fontSize ? fontSize : type === 'text' ? '30px' : '34px',
  38. width:
  39. width ||
  40. (size === 'auto' || type === 'text' || type === 'icon'
  41. ? 'auto'
  42. : size === 'large'
  43. ? '420px'
  44. : size === 'middle'
  45. ? '380px'
  46. : size === 'small'
  47. ? '330px'
  48. : '690px'),
  49. padding: padding ? padding : 'auto',
  50. },
  51. activeColor ? { '--k-color-primary-active': activeColor } : {},
  52. disabledColor ? { '--k-color-primary-disabled': disabledColor } : {},
  53. ]"
  54. :disabled="disabled || loading"
  55. @click.stop="onClick"
  56. :loading="loading"
  57. @getuserinfo="onGetuserinfo"
  58. @getphonenumber="onGetphonenumber"
  59. >
  60. <slot name="left"/>
  61. <k-icon
  62. v-if="type == 'icon'"
  63. :name="icon"
  64. :size="31"
  65. :color="color"
  66. style="margin-right: 8px;"
  67. />
  68. {{ title }}
  69. <slot />
  70. </button>
  71. </template>
  72. <script>
  73. export default {
  74. name: 'k-button',
  75. props: {
  76. title: String,
  77. openType: String,
  78. icon: String,
  79. opacity: String,
  80. disabled: {
  81. type: Boolean,
  82. default: false,
  83. },
  84. loading: Boolean,
  85. type: {
  86. type: String,
  87. default: 'default', // 'default' | 'outline' | 'plain' | 'text'
  88. },
  89. size: {
  90. type: String,
  91. default: 'normal', // 'normal' | 'large' | 'middle' | 'small' | 'auto'
  92. },
  93. width: {
  94. type: String,
  95. default: '', // 'auto' | '100px'
  96. },
  97. height: {
  98. type: String,
  99. default: '',
  100. },
  101. color: {
  102. type: String,
  103. default: '',
  104. },
  105. fontSize: {
  106. type: String,
  107. default: '',
  108. },
  109. bgColor: {
  110. type: String,
  111. default: '',
  112. },
  113. borderColor: {
  114. type: String,
  115. default: '',
  116. },
  117. padding: String,
  118. status: String, // active | disabled | loading
  119. activeColor: String,
  120. disabledColor: String,
  121. },
  122. methods: {
  123. onClick() {
  124. this.$emit('click');
  125. },
  126. onGetuserinfo(e) {
  127. this.$emit('getuserinfo', e);
  128. },
  129. onGetphonenumber(e) {
  130. this.$emit('getphonenumber', e);
  131. },
  132. },
  133. };
  134. </script>
  135. <style scoped lang="less">
  136. /* stylelint-disable selector-class-pattern */
  137. /* stylelint-disable declaration-no-important */
  138. /* stylelint-disable comment-empty-line-before */
  139. .k-btn {
  140. width: 200px;
  141. height: 50px;
  142. border-radius: 60px;
  143. border: 1px solid var(--k-color-primary, #000);
  144. outline: none;
  145. line-height: 1.5;
  146. display: inline-flex;
  147. justify-content: center;
  148. align-items: center;
  149. margin: auto;
  150. background: var(--k-color-primary, #000);
  151. color: var(--k-color-primary, #000);
  152. &::after {
  153. display: none;
  154. }
  155. &:not(.k-btn--disabled):not(.k-btn--outline):not(.k-btn--text):active {
  156. background: var(--k-color-primary-active, #000) !important;
  157. border: 1px solid var(--k-color-primary-active, #000) !important;
  158. }
  159. }
  160. .k-btn--disabled {
  161. background: var(--k-color-primary-disabled, #000) !important;
  162. border: 1px solid var(--k-color-primary-disabled, #000) !important;
  163. }
  164. .k-btn--text {
  165. background: transparent !important;
  166. border: none !important;
  167. &:active {
  168. color: var(--k-color-primary-active, #000) !important;
  169. }
  170. }
  171. .k-btn--outline {
  172. &:active {
  173. background: transparent;
  174. border: 1px solid var(--k-color-primary-active, #000) !important;
  175. color: var(--k-color-primary-active, #000) !important;
  176. }
  177. }
  178. </style>