tui-card.vue 4.2 KB

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