SpecCard.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="spec-card" :class="{ active: active }" @click="clickCard">
  3. <span class="float-tip" :class="floatTipClass" v-if="showFloatTip">
  4. <slot name="float-tip">
  5. <span class="icon-crown"></span>
  6. <span v-if="defaultFloatTipText">{{ defaultFloatTipText }}</span>
  7. </slot>
  8. </span>
  9. <slot name="default"></slot>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'spec-card-active',
  15. props: {
  16. defaultFloatTipText: {
  17. type: String,
  18. default: ''
  19. },
  20. floatTipClass: {
  21. type: String,
  22. default: ''
  23. },
  24. showFloatTip: {
  25. type: Boolean,
  26. default: false
  27. },
  28. active: {
  29. type: Boolean,
  30. default: false
  31. }
  32. },
  33. methods: {
  34. clickCard () {
  35. this.$emit('onClick')
  36. }
  37. }
  38. }
  39. </script>
  40. <style lang="scss" scoped>
  41. .spec-card {
  42. position: relative;
  43. display: flex;
  44. flex-direction: column;
  45. align-items: center;
  46. justify-content: space-between;
  47. padding: 16px;
  48. background-color: #f5f6f7;
  49. border-radius: 8px;
  50. border: 2px solid transparent;
  51. box-sizing: border-box;
  52. cursor: pointer;
  53. &.active {
  54. border-color: #2abed1;
  55. background-color: #fff;
  56. &::after {
  57. content: '';
  58. position: absolute;
  59. right: -2px;
  60. bottom: -2px;
  61. width: 26px;
  62. height: 26px;
  63. background-image: url(~@/assets/images/spec-active.png);
  64. background-repeat: no-repeat;
  65. background-size: contain;
  66. }
  67. }
  68. .float-tip {
  69. position: absolute;
  70. // left: 0px;
  71. left: -2px;
  72. top: 0px;
  73. padding: 0 8px;
  74. color: #fff;
  75. font-size: 12px;
  76. line-height: 20px;
  77. border-radius: 8px 2px 10px 2px;
  78. background-color: #2abed1;
  79. z-index: 9;
  80. .icon-crown{
  81. display: inline-block;
  82. width: 12px;
  83. height: 10px;
  84. margin-right: 4px;
  85. background: url('~@/assets/images/icon/icon-crown.png') no-repeat center;
  86. background-size: cover;
  87. ::before{
  88. content: ''!important;
  89. }
  90. }
  91. }
  92. }
  93. </style>