news-item.nvue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="media-item">
  3. <view class="infoList" @tap="toRankDetail" :data-key="newsItem.baseEntityId">
  4. <view class="listBox">
  5. <div class="leftImg" v-if="newsItem.pictureUrl">
  6. <image class="img" :src="'https://m.geidcp.com/api/file/pub/' + newsItem.pictureUrl" mode="">
  7. </image>
  8. </div>
  9. <view class="rightCont" :style="{ width: newsItem.pictureUrl?'460upx':'690upx' }">
  10. <view class="title">
  11. <text class="title-text-new" v-if="newFlag(newsItem.publishDate)">new</text>
  12. <text class="title-text">{{ newsItem.title }}</text>
  13. </view>
  14. <view class="info-cont">
  15. <text class="cont-text">{{ newsItem.content }}</text>
  16. </view>
  17. <view class="title-base">
  18. <text class="base-text">{{ newsItem.auther }}</text>
  19. <text class="time">{{ formatDate(newsItem.publishDate) }}</text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import moment from "moment";
  28. export default {
  29. props: {
  30. newsItem: {
  31. type: Object,
  32. default: function(e) {
  33. return {}
  34. }
  35. }
  36. },
  37. mounted() {
  38. },
  39. computed: {
  40. },
  41. methods: {
  42. formatDate(value, formatString, defaultString) {
  43. if (value == null) {
  44. return defaultString ? defaultString : "";
  45. }
  46. formatString = formatString || 'YYYY-MM-DD';
  47. return moment(value).format(formatString);
  48. },
  49. toRankDetail(e) { //详情
  50. let key = e.currentTarget.dataset.key;
  51. uni.navigateTo({
  52. url: './components/rankDetail?key=' + key
  53. });
  54. },
  55. newFlag(value) {
  56. let itemDate = this.formatDate(value)
  57. let nowDate = this.formatDate(new Date())
  58. console.log(itemDate, nowDate)
  59. return nowDate == itemDate
  60. }
  61. }
  62. }
  63. </script>
  64. <style scoped>
  65. .infoList {
  66. padding: 0 30upx;
  67. }
  68. .listBox {
  69. /* #ifndef APP-PLUS-NVUE */
  70. display: flex;
  71. /* #endif */
  72. flex-direction: row;
  73. justify-content: space-between;
  74. border-bottom-width: 1px;
  75. border-bottom-style: solid;
  76. border-bottom-color: #F1F1F1;
  77. padding: 30upx 0;
  78. }
  79. .img {
  80. width: 185upx;
  81. height: 140upx;
  82. }
  83. .rightCont {
  84. width: 460upx;
  85. }
  86. .title {
  87. /* #ifndef APP-PLUS-NVUE */
  88. display: flex;
  89. /* #endif */
  90. flex-direction: row;
  91. }
  92. .title-text {
  93. overflow: hidden;
  94. text-overflow: ellipsis;
  95. lines: 2;
  96. /* #ifndef APP-PLUS-NVUE */
  97. display: -webkit-box;
  98. -webkit-line-clamp: 2;
  99. -webkit-box-orient: vertical;
  100. /* #endif */
  101. color: #333333;
  102. font-size: 32upx;
  103. font-weight: 700;
  104. flex: 1;
  105. }
  106. .title-text-new {
  107. color: red;
  108. /* border: 1upx solid red; */
  109. border-radius: 20upx;
  110. padding: 0 10upx;
  111. margin-right: 10upx;
  112. font-size: 28upx;
  113. line-height: 32upx;
  114. }
  115. .cont-text {
  116. margin-top: 15upx;
  117. font-size: 32upx;
  118. text-overflow: ellipsis;
  119. lines: 2;
  120. /* #ifndef APP-PLUS-NVUE */
  121. overflow: hidden;
  122. display: -webkit-box;
  123. -webkit-line-clamp: 2;
  124. -webkit-box-orient: vertical;
  125. /* #endif */
  126. }
  127. .title-base {
  128. margin-top: 15upx;
  129. /* #ifndef APP-PLUS-NVUE */
  130. display: flex;
  131. /* #endif */
  132. flex-direction: row;
  133. }
  134. .base-text {
  135. font-size: 28upx;
  136. color: #999999;
  137. }
  138. .time {
  139. margin-left: 30upx;
  140. font-size: 28upx;
  141. color: #999999;
  142. }
  143. .media-item {
  144. position: relative;
  145. flex: 1;
  146. flex-direction: column;
  147. /* padding: 20upx 30upx 0; */
  148. background-color: #FFFFFF;
  149. }
  150. </style>