news-item.nvue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <!-- remove list-cell layer fix android 4.x overflow limit error: 28 layers! -->
  3. <!-- <view class="list-cell view" @click="click"></view> -->
  4. <view class="media-item view" hover-class="media-item-hover" v-if="options.title" @click="click">
  5. <!-- <view class="view" :style="options.article_type === 2 ? 'flex-direction: row';" :class="{'media-image-right': options.article_type === 2, 'media-image-left': options.article_type === 1}"> -->
  6. <!-- TODO 在支付宝小程序下 需要用 style 覆盖标签的默认样式 -->
  7. <view class="view" :style="{flexDirection: (options.article_type === 1 || options.article_type === 2)?(options.article_type === 2 ?'row':'row-reverse'):'column' }">
  8. <text class="media-title" :class="{'media-title2': options.article_type === 1 || options.article_type === 2}">{{options.title}}</text>
  9. <view v-if="options.image_list || options.image_url" class="image-section flex-row" :class="{'image-section-right': options.article_type === 2, 'image-section-left': options.article_type === 1}"
  10. :style="{flexDirection: 'row' }">
  11. <image class="image-list1" :class="{'image-list2': options.article_type === 1 || options.article_type === 2}" v-if="options.image_url"
  12. :src="options.image_url"></image>
  13. <image class="image-list3" v-if="options.image_list" :src="source.url" v-for="(source, i) in options.image_list"
  14. :key="i" />
  15. </view>
  16. </view>
  17. <view class="media-foot flex-row" style="flex-direction: row;">
  18. <view class="media-info flex-row" style="flex-direction: row;">
  19. <text class="info-text">{{options.source}}</text>
  20. <text class="info-text">{{options.comment_count}}条评论</text>
  21. <text class="info-text">{{options.datetime}}</text>
  22. </view>
  23. <view class="max-close-view" @click.stop="close">
  24. <view class="close-l close-h"></view>
  25. <view class="close-l close-v"></view>
  26. </view>
  27. </view>
  28. <view class="media-item-line" style="position: absolute;"></view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. props: {
  34. options: {
  35. type: Object,
  36. default: function(e) {
  37. return {}
  38. }
  39. }
  40. },
  41. methods: {
  42. click() {
  43. this.$emit('click');
  44. },
  45. close(e) {
  46. this.$emit('close');
  47. }
  48. }
  49. }
  50. </script>
  51. <style>
  52. .view {
  53. flex-direction: column;
  54. }
  55. .flex-row {
  56. flex-direction: row;
  57. }
  58. .flex-col {
  59. flex-direction: column;
  60. }
  61. .list-cell {
  62. width: 750rpx;
  63. padding: 0 30rpx;
  64. }
  65. .uni-list-cell-hover {
  66. background-color: #eeeeee;
  67. }
  68. .media-item {
  69. position: relative;
  70. flex: 1;
  71. flex-direction: column;
  72. /* border-bottom-width: 1rpx;
  73. border-bottom-style: solid;
  74. border-bottom-color: #ebebeb; */
  75. padding: 20rpx 30rpx 21rpx 30rpx;
  76. }
  77. .media-item-hover{
  78. background-color: #eee;
  79. }
  80. .media-item-line {
  81. position: absolute;
  82. left: 30rpx;
  83. right: 30rpx;
  84. bottom: 0;
  85. height: 1rpx;
  86. background-color: #ebebeb;
  87. }
  88. .media-image-right {
  89. flex-direction: row;
  90. }
  91. .media-image-left {
  92. flex-direction: row-reverse;
  93. }
  94. .media-title {
  95. flex: 1;
  96. }
  97. .media-title {
  98. lines: 3;
  99. text-overflow: ellipsis;
  100. font-size: 30rpx;
  101. color: #555555;
  102. }
  103. .media-title2 {
  104. flex: 1;
  105. margin-top: 6rpx;
  106. line-height: 40rpx;
  107. }
  108. .image-section {
  109. margin-top: 20rpx;
  110. flex-direction: row;
  111. justify-content: space-between;
  112. }
  113. .image-section-right {
  114. margin-top: 0rpx;
  115. margin-left: 10rpx;
  116. width: 225rpx;
  117. height: 146rpx;
  118. }
  119. .image-section-left {
  120. margin-top: 0rpx;
  121. margin-right: 10rpx;
  122. width: 225rpx;
  123. height: 146rpx;
  124. }
  125. .image-list1 {
  126. width: 690rpx;
  127. height: 481rpx;
  128. }
  129. .image-list2 {
  130. width: 225rpx;
  131. height: 146rpx;
  132. }
  133. .image-list3 {
  134. width: 225rpx;
  135. /* #ifdef H5 */
  136. width: 30%;
  137. /* #endif */
  138. height: 146rpx;
  139. /* #ifdef H5 */
  140. height: 146px;
  141. /* #endif */
  142. }
  143. .media-info {
  144. flex-direction: row;
  145. align-items: center;
  146. }
  147. .info-text {
  148. margin-right: 20rpx;
  149. color: #999999;
  150. font-size: 24rpx;
  151. }
  152. .media-foot {
  153. margin-top: 25rpx;
  154. flex-direction: row;
  155. align-items: center;
  156. justify-content: space-between;
  157. }
  158. .max-close-view {
  159. position: relative;
  160. align-items: center;
  161. flex-direction: row;
  162. width: 40rpx;
  163. height: 30rpx;
  164. line-height: 30rpx;
  165. border-width: 1rpx;
  166. border-style: solid;
  167. border-color: #aaaaaa;
  168. border-radius: 4px;
  169. justify-content: center;
  170. text-align: center;
  171. }
  172. .close-l {
  173. position: absolute;
  174. width: 18rpx;
  175. height: 1rpx;
  176. background-color: #aaaaaa;
  177. }
  178. .close-h {
  179. transform: rotate(45deg);
  180. }
  181. .close-v {
  182. transform: rotate(-45deg);
  183. }
  184. </style>