news-item.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="news-item" @click="onClickDetail(item)">
  3. <view class="news-title">{{ item.title }}</view>
  4. <view class="news-time">{{ formatDate(item.publish_time) }}</view>
  5. <view class="news-summary">
  6. <view class="text">{{ item.content }}</view>
  7. <view class="to-detail"><view>了解详情</view> <view class="arrow iconfont icon-right-s"></view></view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import { link } from '@/utils/request'
  13. export default {
  14. components: {
  15. },
  16. props: {
  17. type: String,
  18. item: Object
  19. },
  20. data() {
  21. return {
  22. }
  23. },
  24. created() {
  25. },
  26. methods: {
  27. formatDate(dateString) {
  28. const date = new Date(dateString);
  29. const year = date.getFullYear();
  30. const month = date.getMonth() + 1; // 月份从 0 开始
  31. const day = date.getDate();
  32. return `${year}年${month}月${day}日`;
  33. },
  34. onClickDetail(item) {
  35. if (this.type === 'exhibitor') {
  36. this.navigateTo(link('/' + item.urla))
  37. } else {
  38. this.navigateTo('https://www.productronicachina.com.cn/2025%E6%85%95%E5%B0%BC%E9%BB%91%E4%B8%8A%E6%B5%B7%E7%94%B5%E5%AD%90%E7%94%9F%E4%BA%A7%E8%AE%BE%E5%A4%87%E5%B1%953%E6%9C%88%E5%A5%8F%E5%93%8D%E6%96%B0%E7%AF%87%E7%AB%A0-%E6%8E%A2%E7%B4%A2%E7%94%B5%E5%AD%90%E5%88%B6%E9%80%A0%E7%9A%84%E6%97%A0%E9%99%90%E5%8F%AF%E8%83%BD')
  39. }
  40. }
  41. }
  42. }
  43. </script>
  44. <style lang="scss">
  45. .news-item{
  46. display: flex;
  47. flex-direction: column;
  48. height: 210rpx;
  49. background-color: #F6F6F6;
  50. border-radius: 10rpx;
  51. padding: 24rpx 30rpx;
  52. }
  53. .news-summary{
  54. display: flex;
  55. align-items: center;
  56. }
  57. .news-title{
  58. @include text-ellipsis-line;
  59. font-family: Arial, Arial;
  60. font-weight: bold;
  61. font-size: $fontSize3;
  62. line-height: 35rpx;
  63. }
  64. .news-time{
  65. font-size: $fontSize0;
  66. color: #555555;
  67. margin: 12rpx 0;
  68. }
  69. .news-summary{
  70. font-size: $fontSize1;
  71. line-height: 25rpx;
  72. .text{
  73. padding-right: 30rpx;
  74. color: #555555;
  75. @include text-ellipsis-line;
  76. -webkit-line-clamp: 2;
  77. }
  78. .to-detail{
  79. display: flex;
  80. align-items: center;
  81. flex-shrink: 0;
  82. color: $buttonPrimaryColor;
  83. font-size: 16rpx;
  84. font-weight: bold;
  85. padding: 0 24rpx;
  86. }
  87. .arrow{
  88. margin-left: 12rpx;
  89. font-size: $fontSize0;
  90. }
  91. }
  92. </style>