articleList.vue 6.5 KB

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