articleList.vue 3.1 KB

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