t-news-item.nvue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class="tui-list-view">
  3. <view class="tui-list-cell" :class="[lastChild ? 'tui-last-child' : '']" @click="bindClick">
  4. <view class="tui-title-box">
  5. <text class="tui-cell-title">{{ entity.title }}</text>
  6. </view>
  7. <view class="tui-img-container" v-if="entity.imgArr && entity.imgArr.length > 0">
  8. <view class="tui-cell-img" v-for="(item, index) in entity.imgArr" :key="index"><image :src="item" class="tui-img"></image></view>
  9. </view>
  10. <view class="tui-sub-title">
  11. <text class="tui-badge" :class="[getClass(entity.badgeType)]" v-if="entity.badgeType != 0">{{ entity.badgeText }}</text>
  12. <text class="tui-sub-content">{{ entity.subContent }}</text>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'tNewsItem',
  20. emits: ['click'],
  21. props: {
  22. entity: {
  23. type: Object,
  24. default: function(e) {
  25. return {};
  26. }
  27. },
  28. lastChild: {
  29. type: Boolean,
  30. default: false
  31. }
  32. },
  33. methods: {
  34. bindClick() {
  35. this.$emit('click');
  36. },
  37. getClass(type) {
  38. //1-tui-red 2-tui-blue 3-tui-orange 4-tui-green
  39. return ['tui-red', 'tui-blue', 'tui-orange', 'tui-green'][type - 1];
  40. }
  41. }
  42. };
  43. </script>
  44. <style>
  45. .tui-list-view {
  46. width: 750rpx;
  47. padding-left: 30rpx;
  48. background-color: #fff;
  49. /* padding-bottom: env(safe-area-inset-bottom); */
  50. }
  51. .tui-list-view:active {
  52. background-color: #eeeeee;
  53. }
  54. .tui-list-cell {
  55. width: 750rpx;
  56. padding-top: 30rpx;
  57. padding-bottom: 30rpx;
  58. padding-right: 30rpx;
  59. /* #ifdef APP-PLUS*/
  60. border-bottom-width: 1rpx;
  61. border-bottom-style: solid;
  62. border-bottom-color: #e6e6e6;
  63. /* #endif */
  64. position: relative;
  65. }
  66. /* #ifndef APP-PLUS*/
  67. .tui-list-cell::after {
  68. content: '';
  69. position: absolute;
  70. border-bottom: 1rpx solid #eaeef1;
  71. -webkit-transform: scaleY(0.5);
  72. transform: scaleY(0.5);
  73. bottom: 0;
  74. right: 0;
  75. left: 0;
  76. }
  77. /* #endif */
  78. .tui-last-child {
  79. border-bottom-width: 0;
  80. }
  81. .tui-title-box {
  82. width: 690rpx;
  83. flex: 1;
  84. /* #ifdef APP-PLUS */
  85. lines: 2;
  86. /* #endif */
  87. /* #ifndef APP-PLUS */
  88. word-break: break-all;
  89. overflow: hidden;
  90. display: -webkit-box;
  91. -webkit-box-orient: vertical;
  92. -webkit-line-clamp: 2;
  93. /* #endif */
  94. }
  95. .tui-cell-title {
  96. font-size: 36rpx;
  97. line-height: 56rpx;
  98. flex: 1;
  99. /* #ifdef APP-PLUS */
  100. lines: 2;
  101. /* #endif */
  102. /* #ifndef APP-PLUS */
  103. word-break: break-all;
  104. overflow: hidden;
  105. display: -webkit-box;
  106. -webkit-box-orient: vertical;
  107. -webkit-line-clamp: 2;
  108. /* #endif */
  109. text-overflow: ellipsis;
  110. color: #333333;
  111. }
  112. .tui-img-container {
  113. width: 690rpx;
  114. padding-top: 24rpx;
  115. height: 184rpx;
  116. flex-direction: row;
  117. justify-content: space-between;
  118. }
  119. .tui-cell-img {
  120. width: 220rpx;
  121. overflow: hidden;
  122. position: relative;
  123. }
  124. .tui-img {
  125. width: 220rpx;
  126. height: 184rpx;
  127. border-radius: 4rpx;
  128. }
  129. .tui-sub-title {
  130. padding-top: 24rpx;
  131. align-items: center;
  132. flex-direction: row;
  133. }
  134. .tui-sub-content {
  135. font-size: 28rpx;
  136. color: #bcbcbc;
  137. }
  138. .tui-badge {
  139. padding-top: 8rpx;
  140. padding-bottom: 8rpx;
  141. padding-left: 10rpx;
  142. padding-right: 10rpx;
  143. font-size: 24rpx;
  144. border-radius: 4rpx;
  145. margin-right: 20rpx;
  146. }
  147. .tui-red {
  148. background-color: #fcebef;
  149. color: #8a5966;
  150. }
  151. .tui-blue {
  152. background-color: #ecf6fd;
  153. color: #4dabeb;
  154. }
  155. .tui-orange {
  156. background-color: #fef5eb;
  157. color: #faa851;
  158. }
  159. .tui-green {
  160. background-color: #e8f6e8;
  161. color: #44cf85;
  162. }
  163. </style>