button.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <button class="tui-btn-class tui-btn" :class="['tui-btn-'+size,plain?'tui-'+type+'-outline':'tui-'+(type || 'gradual'),getDisabledClass(disabled,type),getShapeClass(shape,plain)]"
  3. :hover-class="getHoverClass(disabled,type,plain)" :loading="loading" :disabled="disabled" :open-type="openType" @tap="handleClick"
  4. @getuserinfo="bindgetuserinfo" :form-type="formType" v-if="!hidden">
  5. <slot></slot>
  6. </button>
  7. </template>
  8. <script>
  9. export default {
  10. name: "tuiButton",
  11. props: {
  12. // primary, white, danger, warning, green, gray,gradual
  13. type: {
  14. type: String,
  15. default: 'gradual'
  16. },
  17. // block, mini, small
  18. size: {
  19. type: String,
  20. default: 'block'
  21. },
  22. // circle, square,rightAngle
  23. shape: {
  24. type: String,
  25. default: 'square'
  26. },
  27. plain: {
  28. type: Boolean,
  29. default: false
  30. },
  31. disabled: {
  32. type: Boolean,
  33. default: false
  34. },
  35. loading: {
  36. type: Boolean,
  37. default: false
  38. },
  39. openType: {
  40. type: String,
  41. default: ''
  42. },
  43. formType: {
  44. type: String,
  45. default: ''
  46. },
  47. hidden: {
  48. type: Boolean,
  49. default: false
  50. },
  51. bottom: {
  52. type: Boolean,
  53. default: false
  54. }
  55. },
  56. methods: {
  57. handleClick() {
  58. if (this.disabled) {
  59. return false;
  60. }
  61. this.$emit('click', {})
  62. },
  63. bindgetuserinfo({
  64. detail = {}
  65. } = {}) {
  66. this.$emit('getuserinfo', detail);
  67. },
  68. getDisabledClass: function(disabled, type) {
  69. let className = '';
  70. if (disabled && type != 'white' && type != 'gray') {
  71. className = type == 'gradual' ? 'btn-gradual-disabled' : 'tui-dark-disabled';
  72. }
  73. return className;
  74. },
  75. getShapeClass: function(shape, plain) {
  76. let className = '';
  77. if (shape == 'circle') {
  78. className = plain ? 'tui-outline-fillet' : 'tui-fillet';
  79. } else if (shape == "rightAngle") {
  80. className = plain ? 'tui-outline-rightAngle' : 'tui-rightAngle';
  81. }
  82. return className;
  83. },
  84. getHoverClass: function(disabled, type, plain) {
  85. let className = '';
  86. if (!disabled) {
  87. className = plain ? 'tui-outline-hover' : ('tui-' + (type || 'gradual') + '-hover');
  88. }
  89. return className;
  90. }
  91. }
  92. }
  93. </script>
  94. <style>
  95. /* color start*/
  96. .tui-primary {
  97. background: #C74547 !important;
  98. color: #fff;
  99. }
  100. .tui-danger {
  101. background: #EB0909 !important;
  102. color: #fff;
  103. }
  104. .tui-red {
  105. background: #e41f19 !important;
  106. color: #fff;
  107. }
  108. .tui-warning {
  109. background: #ff7900 !important;
  110. color: #fff;
  111. }
  112. .tui-green {
  113. background: #19be6b !important;
  114. color: #fff;
  115. }
  116. .tui-white {
  117. background: #fff !important;
  118. color: #333 !important;
  119. }
  120. .tui-gray {
  121. background: #ededed !important;
  122. color: #999 !important;
  123. }
  124. .tui-hover-gray {
  125. background: #f7f7f9 !important;
  126. }
  127. /* color end*/
  128. /* button start*/
  129. .tui-btn {
  130. width: 100%;
  131. position: relative;
  132. border: 0 !important;
  133. border-radius: 10rpx;
  134. display: inline-block;
  135. }
  136. .tui-btn::after {
  137. content: "";
  138. position: absolute;
  139. width: 200%;
  140. height: 200%;
  141. -webkit-transform-origin: 0 0;
  142. transform-origin: 0 0;
  143. -webkit-transform: scale(0.5, 0.5);
  144. transform: scale(0.5, 0.5);
  145. -webkit-box-sizing: border-box;
  146. box-sizing: border-box;
  147. left: 0;
  148. top: 0;
  149. border-radius: 20rpx;
  150. }
  151. .tui-btn-block {
  152. font-size: 36rpx;
  153. height: 90rpx;
  154. line-height: 90rpx;
  155. }
  156. .tui-white::after {
  157. border: 1px solid #eaeef1;
  158. }
  159. .tui-white-hover {
  160. background: #e5e5e5 !important;
  161. color: #2e2e2e !important;
  162. }
  163. .tui-dark-disabled {
  164. opacity: 0.6 !important;
  165. color: #fafbfc !important;
  166. }
  167. .tui-outline-hover {
  168. opacity: 0.5;
  169. }
  170. .tui-primary-hover {
  171. background: #a2383a !important;
  172. color: #e5e5e5 !important;
  173. }
  174. .tui-primary-outline::after {
  175. border: 1px solid #C74547 !important;
  176. }
  177. .tui-primary-outline {
  178. color: #C74547 !important;
  179. background: none;
  180. }
  181. .tui-danger-hover {
  182. background: #c80808 !important;
  183. color: #e5e5e5 !important;
  184. }
  185. .tui-danger-outline {
  186. color: #EB0909 !important;
  187. background: none;
  188. }
  189. .tui-danger-outline::after {
  190. border: 1px solid #EB0909 !important;
  191. }
  192. .tui-red-hover {
  193. background: #c51a15 !important;
  194. color: #e5e5e5 !important;
  195. }
  196. .tui-red-outline {
  197. color: #e41f19 !important;
  198. background: none;
  199. }
  200. .tui-red-outline::after {
  201. border: 1px solid #e41f19 !important;
  202. }
  203. .tui-warning-hover {
  204. background: #e56d00 !important;
  205. color: #e5e5e5 !important;
  206. }
  207. .tui-warning-outline {
  208. color: #ff7900 !important;
  209. background: none;
  210. }
  211. .tui-warning-outline::after {
  212. border: 1px solid #ff7900 !important;
  213. }
  214. .tui-green-hover {
  215. background: #16ab60 !important;
  216. color: #e5e5e5 !important;
  217. }
  218. .tui-green-outline {
  219. color: #44cf85 !important;
  220. background: none;
  221. }
  222. .tui-green-outline::after {
  223. border: 1px solid #44cf85 !important;
  224. }
  225. .tui-gray-hover {
  226. background: #d5d5d5 !important;
  227. color: #898989;
  228. }
  229. .tui-gray-outline
  230. {
  231. color: #999 !important;
  232. background: none !important;
  233. }
  234. .tui-white-outline{
  235. color: #fff !important;
  236. background: none !important;
  237. }
  238. .tui-gray-outline::after
  239. {
  240. border: 1px solid #ccc !important;
  241. }
  242. .tui-white-outline::after {
  243. border: 1px solid #fff !important;
  244. }
  245. /*圆角 */
  246. .tui-fillet {
  247. border-radius: 45rpx;
  248. }
  249. .tui-white.tui-fillet::after {
  250. border-radius: 90rpx;
  251. }
  252. .tui-outline-fillet::after {
  253. border-radius: 90rpx;
  254. }
  255. /*平角*/
  256. .tui-rightAngle {
  257. border-radius: 0;
  258. }
  259. .tui-white.tui-rightAngle::after {
  260. border-radius: 0;
  261. }
  262. .tui-outline-rightAngle::after {
  263. border-radius: 0;
  264. }
  265. /*渐变 */
  266. .tui-gradual {
  267. background: linear-gradient(-90deg, #C74547, #5c8dff);
  268. border-radius: 45rpx;
  269. color: #fff;
  270. }
  271. .tui-gradual-hover {
  272. color: #d5d4d9 !important;
  273. background: linear-gradient(-90deg, #a2383a, #4e77d9);
  274. }
  275. .btn-gradual-disabled {
  276. color: #fafbfc !important;
  277. border-radius: 45rpx;
  278. background: linear-gradient(-90deg, #cad8fb, #c9d3fb);
  279. }
  280. /*不同尺寸 */
  281. .tui-btn-mini {
  282. width: auto;
  283. font-size: 30rpx;
  284. height: 70rpx;
  285. line-height: 70rpx;
  286. }
  287. .tui-btn-small {
  288. width: auto;
  289. font-size: 30rpx;
  290. height: 60rpx;
  291. line-height: 60rpx;
  292. }
  293. /* button end*/
  294. </style>