articleList.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <!-- 新闻列表 -->
  3. <view v-show="!isSortType" :style="[articleWrapperStyle]">
  4. <view class="articleList" :class="{
  5. large: dataConfig.styleConfig.tabVal == 0,
  6. small: dataConfig.styleConfig.tabVal == 2,
  7. }" v-if="articleList.length">
  8. <navigator :url='"/pages/extension/news_details/index?id="+item.id' hover-class="none" v-for="(item,index) in articleList" :key="index" :style="[articleItemStyle]" class="item">
  9. <view v-if="dataConfig.styleConfig.tabVal != 0" class="image-wrap">
  10. <easy-loadimage :imageSrc="item.image_input[0]" :borderRadius="borderRadius" width="100%" height="100%"></easy-loadimage>
  11. </view>
  12. <view class="text-wrap">
  13. <view class="title-wrap">
  14. <view class="title" :class="{
  15. line1: dataConfig.styleConfig.tabVal != 1,
  16. line2: dataConfig.styleConfig.tabVal == 1,
  17. }" :style="[titleStyle]">{{ item.title }}</view>
  18. </view>
  19. <view v-if="dataConfig.styleConfig.tabVal == 0" class="image-wrap">
  20. <easy-loadimage :imageSrc="item.image_input[0]" :borderRadius="borderRadius" width="100%" height="100%"></easy-loadimage>
  21. </view>
  22. <view class="time-wrap" :style="[numberStyle]">
  23. <view v-if="dataConfig.checkboxList.type.includes(0)" class="time time-wrap-item" :style="[timeStyle]">{{ item.add_time }}</view>
  24. <view class="like-wrap time-wrap-item">
  25. <view v-if="dataConfig.checkboxList.type.includes(1)" class="view">
  26. <text class="iconfont icon-ic_Eyes" :style="[iconEyesStyle]"></text>{{ item.visit }}
  27. </view>
  28. <view v-if="dataConfig.checkboxList.type.includes(2)" class="like">
  29. <text class="iconfont icon-ic_Like" :style="[iconLikeStyle]"></text>{{ item.likes }}
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </navigator>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. getArticleList
  41. } from '@/api/api.js';
  42. export default {
  43. name: 'articleList',
  44. props: {
  45. dataConfig: {
  46. type: Object,
  47. default: () => {}
  48. },
  49. isSortType: {
  50. type: String | Number,
  51. default: 0
  52. }
  53. },
  54. data() {
  55. return {
  56. articleList: [],
  57. }
  58. },
  59. computed: {
  60. borderRadius() {
  61. let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
  62. if (this.dataConfig.filletImg.type) {
  63. borderRadius =
  64. `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${this.dataConfig.filletImg.valList[1].val * 2}rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx ${this.dataConfig.filletImg.valList[2].val * 2}rpx`;
  65. }
  66. return borderRadius;
  67. },
  68. timeStyle() {
  69. return {
  70. 'color': this.dataConfig.timeColor.color[0].item,
  71. };
  72. },
  73. iconEyesStyle() {
  74. return {
  75. 'color': this.dataConfig.browseColor.color[0].item,
  76. };
  77. },
  78. iconLikeStyle() {
  79. return {
  80. 'color': this.dataConfig.likeColor.color[0].item,
  81. };
  82. },
  83. numberStyle() {
  84. return {
  85. 'color': this.dataConfig.statisticColor.color[0].item,
  86. };
  87. },
  88. articleItemStyle() {
  89. let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
  90. if (this.dataConfig.fillet.type) {
  91. borderRadius =
  92. `${this.dataConfig.fillet.valList[0].val * 2}rpx ${this.dataConfig.fillet.valList[1].val * 2}rpx ${this.dataConfig.fillet.valList[2].val * 2}rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx`;
  93. }
  94. return {
  95. 'border-radius': borderRadius,
  96. 'background': `linear-gradient(90deg, ${this.dataConfig.bgColor.color[0].item} 0%, ${this.dataConfig.bgColor.color[1].item} 100%)`,
  97. };
  98. },
  99. articleWrapperStyle() {
  100. return {
  101. 'padding': `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
  102. 'margin-top': `${this.dataConfig.mbConfig.val * 2}rpx`,
  103. 'background': this.dataConfig.bottomBgColor.color[0].item,
  104. };
  105. },
  106. titleStyle() {
  107. let styleObject = {
  108. 'color': this.dataConfig.nameColor.color[0].item,
  109. };
  110. if (!this.dataConfig.nameConfig.tabVal) {
  111. styleObject['font-weight'] = 'bold';
  112. }
  113. return styleObject;
  114. }
  115. },
  116. mounted() {
  117. this.getCidArticle();
  118. },
  119. methods: {
  120. getCidArticle: function() {
  121. let limit = this.$config.LIMIT;
  122. getArticleList(this.dataConfig.selectConfig.activeValue || 0, {
  123. page: 1,
  124. limit: this.dataConfig.numConfig.val >= limit ? limit : this.dataConfig.numConfig.val
  125. }).then(res => {
  126. this.articleList = res.data;
  127. });
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="scss">
  133. .articleList {
  134. .item {
  135. display: flex;
  136. padding: 20rpx;
  137. margin: 0;
  138. background: #FFFFFF;
  139. }
  140. .text-wrap {
  141. flex: 1;
  142. display: flex;
  143. flex-direction: column;
  144. padding: 0 0 6rpx 24rpx;
  145. }
  146. .title-wrap {
  147. flex: 1;
  148. }
  149. .title {
  150. font-size: 30rpx;
  151. line-height: 42rpx;
  152. color: #333333;
  153. }
  154. .label-wrap {
  155. margin-top: 16rpx;
  156. font-size: 0;
  157. }
  158. .label {
  159. display: inline-flex;
  160. flex-wrap: nowrap;
  161. height: 28rpx;
  162. padding: 0 6rpx;
  163. border: 1rpx solid #E93323;
  164. border-radius: 6rpx;
  165. font-size: 20rpx;
  166. color: #E93323;
  167. }
  168. .image-wrap {
  169. width: 240rpx;
  170. height: 152rpx;
  171. }
  172. .time-wrap {
  173. display: flex;
  174. font-size: 24rpx;
  175. line-height: 34rpx;
  176. color: #999999;
  177. .time-wrap-item:first-child {
  178. flex: 1;
  179. }
  180. }
  181. .like-wrap {
  182. display: flex;
  183. }
  184. .view {
  185. flex: 1;
  186. margin-right: 32rpx;
  187. }
  188. .iconfont {
  189. margin-right: 8rpx;
  190. font-size: 28rpx;
  191. }
  192. &.large {
  193. .item {
  194. flex-direction: column;
  195. padding: 0;
  196. }
  197. .text-wrap {
  198. padding: 32rpx 24rpx;
  199. }
  200. .image-wrap {
  201. width: 100%;
  202. height: 320rpx;
  203. margin-top: 24rpx;
  204. }
  205. .time-wrap {
  206. margin-top: 24rpx;
  207. }
  208. }
  209. &.small {
  210. display: flex;
  211. flex-wrap: wrap;
  212. justify-content: space-between;
  213. .item {
  214. flex-direction: column;
  215. width: 342rpx;
  216. padding: 0;
  217. margin-bottom: 20rpx;
  218. }
  219. .text-wrap {
  220. padding: 20rpx 20rpx 18rpx;
  221. }
  222. .image-wrap {
  223. width: 342rpx;
  224. height: 216rpx;
  225. }
  226. .label-wrap {
  227. margin-top: 16rpx;
  228. }
  229. .time-wrap {
  230. flex-direction: column;
  231. margin-top: 16rpx;
  232. }
  233. .like-wrap {
  234. justify-content: space-between;
  235. margin-top: 16rpx;
  236. }
  237. }
  238. }
  239. </style>