articleList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. console.log('121212',this.conStyle);
  77. this.getCidArticle();
  78. },
  79. methods: {
  80. getCidArticle: function() {
  81. let that = this;
  82. let limit = this.$config.LIMIT;
  83. getArticleList(that.selectConfig || 0, {
  84. page: 1,
  85. limit: this.numConfig >= limit ? limit : this.numConfig
  86. }).then(res => {
  87. that.articleList = res.data;
  88. });
  89. },
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. .articleList {
  95. background-color: #fff;
  96. padding: 20rpx 0;
  97. .item {
  98. padding: 20rpx;
  99. background-color: #fff;
  100. margin: 0 20rpx;
  101. &:last-child{
  102. margin-bottom: 0!important;
  103. }
  104. .text {
  105. width: 60%;
  106. .name {
  107. font-size: 30rpx;
  108. color: #282828;
  109. height: 82rpx;
  110. }
  111. .time {
  112. font-size: 24rpx;
  113. color: #999;
  114. margin-top: 40rpx;
  115. }
  116. }
  117. .pictrue {
  118. width: 37%;
  119. height: 156rpx;
  120. border-radius: 6rpx;
  121. image {
  122. width: 100%;
  123. height: 100%;
  124. border-radius: 6rpx;
  125. }
  126. }
  127. }
  128. }
  129. </style>