articleList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <!-- 新闻列表 -->
  3. <view v-show="!isSortType" :style="{padding:'0 '+prConfig*2+'rpx'}">
  4. <view class="articleList" :class="{borderRadius15:bgStyle===1}" :style="'background-color:'+bgColor+';margin-top:'+ mbConfig*2 +'rpx;'" v-if="articleList.length">
  5. <view v-if="listStyle">
  6. <navigator :url='"/pages/extension/news_details/index?id="+item.id' hover-class='none' class="item acea-row row-between-wrapper" :class="conStyle?'borderRadius15':''"
  7. :style="'margin-bottom:'+itemConfig*2+'rpx;'" v-for="(item,index) in articleList" :key='index'>
  8. <view class="pictrue">
  9. <image :src="item.image_input[0]" mode="aspectFill"></image>
  10. </view>
  11. <view class="text">
  12. <view class="name line2">{{item.title}}</view>
  13. <!-- #ifdef H5 || APP-PLUS -->
  14. <slot name="center" :item="item"></slot>
  15. <!-- #endif -->
  16. <!-- #ifdef MP -->
  17. <slot name="center{{index}}"></slot>
  18. <!-- #endif -->
  19. <view class="time">{{item.add_time}}</view>
  20. </view>
  21. </navigator>
  22. </view>
  23. <view v-else>
  24. <navigator :url='"/pages/extension/news_details/index?id="+item.id' hover-class='none' class="item acea-row row-between-wrapper" :class="conStyle?'borderRadius15':''"
  25. :style="'margin-bottom:'+itemConfig*2+'rpx;'" v-for="(item,index) in articleList" :key='index'>
  26. <view class="text">
  27. <view class="name line2">{{item.title}}</view>
  28. <!-- #ifdef H5 || APP-PLUS -->
  29. <slot name="center" :item="item"></slot>
  30. <!-- #endif -->
  31. <!-- #ifdef MP -->
  32. <slot name="center{{index}}"></slot>
  33. <!-- #endif -->
  34. <view class="time">{{item.add_time}}</view>
  35. </view>
  36. <view class="pictrue">
  37. <image :src="item.image_input[0]" mode="aspectFill"></image>
  38. </view>
  39. </navigator>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. getArticleList
  47. } from '@/api/api.js';
  48. export default {
  49. name: 'articleList',
  50. props: {
  51. dataConfig: {
  52. type: Object,
  53. default: () => {}
  54. },
  55. isSortType:{
  56. type: String | Number,
  57. default:0
  58. }
  59. },
  60. data() {
  61. return {
  62. articleList: [],
  63. numConfig: this.dataConfig.numConfig.val,
  64. selectConfig: this.dataConfig.selectConfig.activeValue,
  65. listStyle: this.dataConfig.listStyle.type,
  66. bgColor: this.dataConfig.bgColor.color[0].item,
  67. itemConfig: this.dataConfig.itemConfig.val,
  68. mbConfig: this.dataConfig.mbConfig.val,
  69. bgStyle: this.dataConfig.bgStyle.type,//背景样式
  70. prConfig: this.dataConfig.prConfig.val,//背景边距
  71. conStyle: this.dataConfig.conStyle.type,//内容样式
  72. }
  73. },
  74. created() {},
  75. mounted() {
  76. this.getCidArticle();
  77. },
  78. methods: {
  79. getCidArticle: function() {
  80. let that = this;
  81. let limit = this.$config.LIMIT;
  82. getArticleList(that.selectConfig || 0, {
  83. page: 1,
  84. limit: this.numConfig >= limit ? limit : this.numConfig
  85. }).then(res => {
  86. that.articleList = res.data;
  87. });
  88. },
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. .articleList {
  94. background-color: #fff;
  95. padding: 20rpx 0;
  96. .item {
  97. padding: 20rpx;
  98. background-color: #fff;
  99. margin: 0 20rpx;
  100. &:last-child{
  101. margin-bottom: 0!important;
  102. }
  103. .text {
  104. width: 60%;
  105. .name {
  106. font-size: 30rpx;
  107. color: #282828;
  108. height: 82rpx;
  109. }
  110. .time {
  111. font-size: 24rpx;
  112. color: #999;
  113. margin-top: 40rpx;
  114. }
  115. }
  116. .pictrue {
  117. width: 37%;
  118. height: 156rpx;
  119. border-radius: 6rpx;
  120. image {
  121. width: 100%;
  122. height: 100%;
  123. border-radius: 6rpx;
  124. }
  125. }
  126. }
  127. }
  128. </style>