index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view
  3. class="tui-tag-class"
  4. :class="[
  5. size ? 'tui-tag-' + size : 'tui-tag',
  6. getClassName(shape, plain),
  7. getTypeClass(type, plain)
  8. ]"
  9. @tap="handleClick"
  10. v-if="visible"
  11. >
  12. <slot></slot>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'tuiTag',
  18. props: {
  19. type: {
  20. type: String,
  21. default: 'primary'
  22. },
  23. // '', small
  24. size: {
  25. type: String,
  26. default: ''
  27. },
  28. // circle, square,circleLeft,circleRight
  29. shape: {
  30. type: String,
  31. default: 'square'
  32. },
  33. // 是否空心
  34. plain: {
  35. type: Boolean,
  36. default: false
  37. },
  38. // 是否可见
  39. visible: {
  40. type: Boolean,
  41. default: true
  42. }
  43. },
  44. methods: {
  45. handleClick() {
  46. this.$emit('click');
  47. },
  48. getTypeClass: function(type, plain) {
  49. return plain ? 'tui-' + type + '-outline' : 'tui-' + type;
  50. },
  51. getClassName: function(shape, plain) {
  52. // circle, square,circleLeft,circleRight
  53. let className = plain ? 'tui-tag-outline ' : '';
  54. if (shape !== 'square') {
  55. if (shape === 'circle') {
  56. className =
  57. className + (plain ? 'tui-tag-outline-fillet' : 'tui-tag-fillet');
  58. } else if (shape === 'circleLeft') {
  59. className = className + 'tui-tag-fillet-left';
  60. } else if (shape === 'circleRight') {
  61. className = className + 'tui-tag-fillet-right';
  62. }
  63. }
  64. return className;
  65. }
  66. }
  67. };
  68. </script>
  69. <style>
  70. /* color start*/
  71. .tui-primary {
  72. background: #5677fc !important;
  73. color: #fff;
  74. }
  75. .tui-light-primary {
  76. background: #5c8dff !important;
  77. color: #fff;
  78. }
  79. .tui-dark-primary {
  80. background: #4a67d6 !important;
  81. color: #fff;
  82. }
  83. .tui-dLight-primary {
  84. background: #4e77d9 !important;
  85. color: #fff;
  86. }
  87. .tui-danger {
  88. background: #ed3f14 !important;
  89. color: #fff;
  90. }
  91. .tui-red {
  92. background: #ff201f !important;
  93. color: #fff;
  94. }
  95. .tui-warning {
  96. background: #ff7900 !important;
  97. color: #fff;
  98. }
  99. .tui-green {
  100. background: #19be6b !important;
  101. color: #fff;
  102. }
  103. .tui-high-green {
  104. background: #52dcae !important;
  105. color: #52dcae;
  106. }
  107. .tui-black {
  108. background: #000 !important;
  109. color: #fff;
  110. }
  111. .tui-white {
  112. background: #fff !important;
  113. color: #333 !important;
  114. }
  115. .tui-translucent {
  116. background: rgba(0, 0, 0, 0.7);
  117. }
  118. .tui-light-black {
  119. background: #333 !important;
  120. }
  121. .tui-gray {
  122. background: #ededed !important;
  123. }
  124. .tui-phcolor-gray {
  125. background: #ccc !important;
  126. }
  127. .tui-divider-gray {
  128. background: #eaeef1 !important;
  129. }
  130. .tui-btn-gray {
  131. background: #ededed !important;
  132. color: #999 !important;
  133. }
  134. .tui-hover-gray {
  135. background: #f7f7f9 !important;
  136. }
  137. .tui-bg-gray {
  138. background: #fafafa !important;
  139. }
  140. .tui-light-blue {
  141. background: #ecf6fd;
  142. color: #4dabeb !important;
  143. }
  144. .tui-light-brownish {
  145. background: #fcebef;
  146. color: #8a5966 !important;
  147. }
  148. .tui-light-orange {
  149. background: #fef5eb;
  150. color: #faa851 !important;
  151. }
  152. .tui-light-green {
  153. background: #e8f6e8;
  154. color: #44cf85 !important;
  155. }
  156. .tui-primary-outline::after {
  157. border: 1px solid #5677fc !important;
  158. }
  159. .tui-primary-outline {
  160. color: #5677fc !important;
  161. background: none;
  162. }
  163. .tui-danger-outline {
  164. color: #ed3f14 !important;
  165. background: none;
  166. }
  167. .tui-danger-outline::after {
  168. border: 1px solid #ed3f14 !important;
  169. }
  170. .tui-red-outline {
  171. color: #ff201f !important;
  172. background: none;
  173. }
  174. .tui-red-outline::after {
  175. border: 1px solid #ff201f !important;
  176. }
  177. .tui-warning-outline {
  178. color: #ff7900 !important;
  179. background: none;
  180. }
  181. .tui-warning-outline::after {
  182. border: 1px solid #ff7900 !important;
  183. }
  184. .tui-green-outline {
  185. color: #44cf85 !important;
  186. background: none;
  187. }
  188. .tui-green-outline::after {
  189. border: 1px solid #44cf85 !important;
  190. }
  191. .tui-high-green-outline {
  192. color: #52dcae !important;
  193. background: none;
  194. }
  195. .tui-high-green-outline::after {
  196. border: 1px solid #52dcae !important;
  197. }
  198. .tui-gray-outline {
  199. color: #999 !important;
  200. background: none;
  201. }
  202. .tui-gray-outline::after {
  203. border: 1px solid #ccc !important;
  204. }
  205. .tui-black-outline {
  206. color: #333 !important;
  207. background: none;
  208. }
  209. .tui-black-outline::after {
  210. border: 1px solid #333 !important;
  211. }
  212. .tui-white-outline {
  213. color: #fff !important;
  214. background: none;
  215. }
  216. .tui-white-outline::after {
  217. border: 1px solid #fff !important;
  218. }
  219. /* color end*/
  220. /* tag start*/
  221. .tui-tag {
  222. padding: 16upx 26upx;
  223. font-size: 28upx;
  224. border-radius: 6upx;
  225. /* display: inline-block;
  226. vertical-align: middle; */
  227. line-height: 28upx;
  228. }
  229. .tui-tag-small {
  230. padding: 10upx 16upx;
  231. font-size: 24upx;
  232. border-radius: 6upx;
  233. /* display: inline-block;
  234. vertical-align: middle; */
  235. line-height: 24upx;
  236. }
  237. .tui-tag-outline {
  238. position: relative;
  239. background: none;
  240. color: #5677fc;
  241. }
  242. .tui-tag-outline::after {
  243. content: '';
  244. position: absolute;
  245. width: 200%;
  246. height: 200%;
  247. -webkit-transform-origin: 0 0;
  248. transform-origin: 0 0;
  249. -webkit-transform: scale(0.5, 0.5);
  250. transform: scale(0.5, 0.5);
  251. -webkit-box-sizing: border-box;
  252. box-sizing: border-box;
  253. left: 0;
  254. top: 0;
  255. border-radius: 80upx;
  256. border: 1px solid #5677fc;
  257. }
  258. .tui-tag-fillet {
  259. border-radius: 50upx;
  260. }
  261. .tui-white.tui-tag-fillet::after {
  262. border-radius: 80upx;
  263. }
  264. .tui-tag-outline-fillet::after {
  265. border-radius: 80upx;
  266. }
  267. .tui-tag-fillet-left {
  268. border-radius: 50upx 0 0 50upx;
  269. }
  270. .tui-tag-fillet-right {
  271. border-radius: 0 50upx 50upx 0;
  272. }
  273. .tui-tag-fillet-left.tui-tag-outline::after {
  274. border-radius: 100upx 0 0 100upx;
  275. }
  276. .tui-tag-fillet-right.tui-tag-outline::after {
  277. border-radius: 0 100upx 100upx 0;
  278. }
  279. /* tag end*/
  280. </style>