tui-card.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="tui-card-class tui-card" :class="[full?'tui-card-full':'',border?'tui-card-border':'']"
  3. @tap="handleClick" @longtap="longTap">
  4. <slot>
  5. <view class="tui-card-header" :class="{'tui-header-line':header.line}"
  6. :style="{background:header.bgcolor || '#fff'}">
  7. <view class="tui-header-left">
  8. <image :src="image.url" class="tui-header-thumb" :class="{'tui-thumb-circle':image.circle}"
  9. mode="widthFix" v-if="image.url"
  10. :style="{height:(image.height || 60)+'rpx',width:(image.width || 60)+'rpx'}"></image>
  11. <text class="tui-header-title"
  12. :style="{fontSize:(title.size || 30)+'rpx',color:(title.color || '#7A7A7A')}"
  13. v-if="title.text">{{title.text}}</text>
  14. </view>
  15. <view class="tui-header-right" :style="{fontSize:(tag.size || 24)+'rpx',color:(tag.color || '#b2b2b2')}"
  16. v-if="tag.text">
  17. {{tag.text}}
  18. </view>
  19. </view>
  20. </slot>
  21. <view class="tui-card-body">
  22. <slot name="body"></slot>
  23. </view>
  24. <view class="tui-card-footer">
  25. <slot name="footer"></slot>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. name: "tuiCard",
  32. emits: ['click', 'longclick'],
  33. props: {
  34. //是否铺满
  35. full: {
  36. type: Boolean,
  37. default: false
  38. },
  39. image: {
  40. type: Object,
  41. default: function() {
  42. return {
  43. url: "", //图片地址
  44. height: 60, //图片高度
  45. width: 60, //图片宽度
  46. circle: false
  47. }
  48. }
  49. },
  50. //标题
  51. title: {
  52. type: Object,
  53. default: function() {
  54. return {
  55. text: "", //标题文字
  56. size: 30, //字体大小
  57. color: "#7A7A7A" //字体颜色
  58. }
  59. }
  60. },
  61. //标签,时间等
  62. tag: {
  63. type: Object,
  64. default: function() {
  65. return {
  66. text: "", //标签文字
  67. size: 24, //字体大小
  68. color: "#b2b2b2" //字体颜色
  69. }
  70. }
  71. },
  72. header: {
  73. type: Object,
  74. default: function() {
  75. return {
  76. bgcolor: "#fff", //背景颜色
  77. line: false //是否去掉底部线条
  78. }
  79. }
  80. },
  81. //是否设置外边框
  82. border: {
  83. type: Boolean,
  84. default: false
  85. },
  86. index: {
  87. type: Number,
  88. default: 0
  89. }
  90. },
  91. methods: {
  92. handleClick() {
  93. this.$emit('click', {
  94. index: this.index
  95. });
  96. },
  97. longTap() {
  98. this.$emit('longclick', {
  99. index: this.index
  100. });
  101. }
  102. }
  103. }
  104. </script>
  105. <style scoped>
  106. .tui-card {
  107. margin: 0 30rpx;
  108. font-size: 28rpx;
  109. background-color: #fff;
  110. border-radius: 10rpx;
  111. box-shadow: 0 0 10rpx #eee;
  112. box-sizing: border-box;
  113. overflow: hidden;
  114. }
  115. .tui-card-full {
  116. margin: 0 !important;
  117. border-radius: 0 !important;
  118. }
  119. .tui-card-full::after {
  120. border-radius: 0 !important;
  121. }
  122. .tui-card-border {
  123. position: relative;
  124. box-shadow: none !important
  125. }
  126. .tui-card-border::after {
  127. content: ' ';
  128. position: absolute;
  129. height: 200%;
  130. width: 200%;
  131. border: 1px solid #ddd;
  132. transform-origin: 0 0;
  133. -webkit-transform-origin: 0 0;
  134. -webkit-transform: scale(0.5);
  135. transform: scale(0.5);
  136. left: 0;
  137. top: 0;
  138. border-radius: 20rpx;
  139. box-sizing: border-box;
  140. pointer-events: none;
  141. }
  142. .tui-card-header {
  143. width: 100%;
  144. padding: 20rpx;
  145. display: flex;
  146. align-items: center;
  147. justify-content: space-between;
  148. position: relative;
  149. box-sizing: border-box;
  150. overflow: hidden;
  151. border-top-left-radius: 10rpx;
  152. border-top-right-radius: 10rpx;
  153. }
  154. .tui-card-header::after {
  155. content: '';
  156. position: absolute;
  157. border-bottom: 1rpx solid #eaeef1;
  158. -webkit-transform: scaleY(0.5);
  159. transform: scaleY(0.5);
  160. bottom: 0;
  161. right: 0;
  162. left: 0;
  163. pointer-events: none;
  164. }
  165. .tui-header-line::after {
  166. border-bottom: 0 !important;
  167. }
  168. .tui-header-thumb {
  169. height: 60rpx;
  170. width: 60rpx;
  171. vertical-align: middle;
  172. margin-right: 20rpx;
  173. border-radius: 6rpx;
  174. }
  175. .tui-thumb-circle {
  176. border-radius: 50% !important;
  177. }
  178. .tui-header-title {
  179. display: inline-block;
  180. font-size: 30rpx;
  181. color: #7a7a7a;
  182. vertical-align: middle;
  183. max-width: 460rpx;
  184. overflow: hidden;
  185. white-space: nowrap;
  186. text-overflow: ellipsis;
  187. }
  188. .tui-header-right {
  189. font-size: 24rpx;
  190. color: #b2b2b2;
  191. }
  192. .tui-card-body {
  193. font-size: 32rpx;
  194. color: #262b3a;
  195. box-sizing: border-box;
  196. }
  197. .tui-card-footer {
  198. font-size: 28rpx;
  199. color: #596d96;
  200. border-bottom-left-radius: 10rpx;
  201. border-bottom-right-radius: 10rpx;
  202. box-sizing: border-box;
  203. }
  204. </style>