uni-card.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view :class="isFull ? 'uni-card--full' : ''" class="uni-card" @click="onClick">
  3. <view v-if="title" class="uni-card__header">
  4. <view v-if="thumbnail" class="uni-card__header-extra-img-view">
  5. <image :src="thumbnail" class="uni-card__header-extra-img" />
  6. </view>
  7. <view class="uni-card__header-title-text">{{ title }}</view>
  8. <view v-if="extra" class="uni-card__header-extra-text">{{ extra }}</view>
  9. </view>
  10. <view class="uni-card__content uni-card__content--pd">
  11. <slot />
  12. </view>
  13. <view v-if="note" class="uni-card__footer">{{ note }}</view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'UniCard',
  19. props: {
  20. title: {
  21. type: String,
  22. default: ''
  23. }, // 标题
  24. extra: {
  25. type: String,
  26. default: ''
  27. }, // 扩展信息
  28. note: {
  29. type: String,
  30. default: ''
  31. }, // Tips
  32. thumbnail: {
  33. type: String,
  34. default: ''
  35. }, // 缩略图
  36. isFull: { // 内容区域是否通栏
  37. type: Boolean,
  38. default: false
  39. }
  40. },
  41. methods: {
  42. onClick() {
  43. this.$emit('click')
  44. }
  45. }
  46. }
  47. </script>
  48. <style>
  49. @charset "UTF-8";
  50. .uni-card {
  51. margin-left: 24upx;
  52. margin-right: 24upx;
  53. background: #fff;
  54. box-shadow: none;
  55. position: relative;
  56. display: flex;
  57. flex-direction: column
  58. }
  59. .uni-card:after {
  60. content: '';
  61. position: absolute;
  62. transform-origin: center;
  63. box-sizing: border-box;
  64. pointer-events: none;
  65. top: -50%;
  66. left: -50%;
  67. right: -50%;
  68. bottom: -50%;
  69. border: 1px solid #c8c7cc;
  70. border-radius: 12upx;
  71. transform: scale(.5)
  72. }
  73. .uni-card__footer,
  74. .uni-card__header {
  75. position: relative;
  76. display: flex;
  77. flex-direction: row;
  78. padding: 16upx;
  79. align-items: center
  80. }
  81. .uni-card__header:after {
  82. position: absolute;
  83. bottom: 0;
  84. right: 0;
  85. left: 0;
  86. height: 1px;
  87. content: '';
  88. -webkit-transform: scaleY(.5);
  89. transform: scaleY(.5);
  90. background-color: #c8c7cc
  91. }
  92. .uni-card__header-title {
  93. flex: 1;
  94. margin-right: 16upx;
  95. display: flex;
  96. flex-direction: row;
  97. justify-content: flex-start;
  98. align-items: center
  99. }
  100. .uni-card__header-title-text {
  101. font-size: 32upx;
  102. flex: 1;
  103. text-overflow: ellipsis;
  104. white-space: nowrap;
  105. overflow: hidden
  106. }
  107. .uni-card__header-extra-img-view {
  108. display: flex
  109. }
  110. .uni-card__header-extra-img {
  111. height: 40upx;
  112. width: 40upx;
  113. margin-right: 16upx
  114. }
  115. .uni-card__header-extra-text {
  116. flex: 0 0 auto;
  117. width: 30%;
  118. margin-left: 16upx;
  119. font-size: 28upx;
  120. text-align: right;
  121. text-overflow: ellipsis;
  122. white-space: nowrap;
  123. overflow: hidden
  124. }
  125. .uni-card__content--pd {
  126. padding: 16upx
  127. }
  128. .uni-card__footer {
  129. justify-content: space-between;
  130. color: #999;
  131. font-size: 24upx;
  132. padding-top: 0
  133. }
  134. .uni-card--full {
  135. margin: 0
  136. }
  137. </style>