news-item.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view class="news-item" @click="onClickDetail(item)">
  3. <view class="news-title">{{ item.title }}</view>
  4. <view class="news-time">
  5. <template
  6. v-if="(item.publish_time && item.publish_time !== '0000-00-00 00:00:00') || (item.pub_date && item.pub_date !== '0000-00-00 00:00:00')">
  7. {{ formatDate(item.publish_time || item.pub_date) }}
  8. </template>
  9. </view>
  10. <view class="news-summary">
  11. <view class="text">{{ item.content || item.description }}</view>
  12. <view class="to-detail">
  13. <view>了解详情</view>
  14. <view class="arrow iconfont icon-right-s"></view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import {link} from '@/utils/request'
  21. export default {
  22. components: {},
  23. props: {
  24. type: String,
  25. item: Object
  26. },
  27. data() {
  28. return {
  29. websiteUrl: process.env.WEBSITE
  30. }
  31. },
  32. created() {
  33. },
  34. methods: {
  35. formatDate(dateString) {
  36. const date = new Date(dateString);
  37. const year = date.getFullYear();
  38. const month = date.getMonth() + 1; // 月份从 0 开始
  39. const day = date.getDate();
  40. return `${year}年${month}月${day}日`;
  41. },
  42. onClickDetail(item) {
  43. if (this.type === 'exhibitor') {
  44. // this.navigateTo(this.$store.getters.website_url + '/mini-pro-news?news_id='+ item.id +'&v=' + this.$store.getters.version)
  45. this.navigateTo('/pages/exhibitor/exhibitor-news?id=' + item.id)
  46. } else {
  47. this.navigateTo(this.websiteUrl + '/' + item.urla)
  48. }
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss">
  54. .news-item {
  55. display: flex;
  56. flex-direction: column;
  57. min-height: 210rpx;
  58. background-color: #F6F6F6;
  59. border-radius: 10rpx;
  60. padding: 24rpx 30rpx;
  61. }
  62. .news-summary {
  63. display: flex;
  64. align-items: center;
  65. }
  66. .news-title {
  67. @include text-ellipsis-line;
  68. font-weight: bold;
  69. font-size: $fontSize3;
  70. line-height: 1.4;
  71. }
  72. .news-time {
  73. font-size: $fontSize0;
  74. color: #555555;
  75. margin: 12rpx 0;
  76. }
  77. .news-summary {
  78. font-size: $fontSize1;
  79. line-height: 25rpx;
  80. .text {
  81. padding-right: 30rpx;
  82. color: #555555;
  83. @include text-ellipsis-line;
  84. -webkit-line-clamp: 2;
  85. line-height: 1.4;
  86. }
  87. .to-detail {
  88. display: flex;
  89. align-items: center;
  90. flex-shrink: 0;
  91. color: $buttonPrimaryColor;
  92. font-size: 16rpx;
  93. font-weight: bold;
  94. padding: 0 24rpx;
  95. }
  96. .arrow {
  97. margin-left: 12rpx;
  98. font-size: $fontSize0;
  99. }
  100. }
  101. </style>