articleList.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <common-wrapper v-show="!isSortType" :config="configData">
  3. <view
  4. class="articleList"
  5. :class="{
  6. large: dataConfig.styleConfig.tabVal == 0,
  7. small: dataConfig.styleConfig.tabVal == 2,
  8. }"
  9. v-if="articleList.length"
  10. >
  11. <navigator
  12. :url="'/pages/extension/news_details/index?id=' + item.id"
  13. hover-class="none"
  14. v-for="(item, index) in articleList"
  15. :key="index"
  16. :style="[articleItemStyle]"
  17. class="item"
  18. >
  19. <view v-if="dataConfig.styleConfig.tabVal != 0" class="image-wrap">
  20. <easy-loadimage
  21. :imageSrc="item.image_input[0]"
  22. :borderRadius="borderRadius"
  23. width="100%"
  24. height="100%"
  25. ></easy-loadimage>
  26. </view>
  27. <view class="text-wrap">
  28. <view class="title-wrap">
  29. <view
  30. class="title"
  31. :class="{
  32. line1: dataConfig.styleConfig.tabVal != 1,
  33. line2: dataConfig.styleConfig.tabVal == 1,
  34. }"
  35. :style="[titleStyle]"
  36. >{{ item.title }}</view
  37. >
  38. </view>
  39. <view v-if="dataConfig.styleConfig.tabVal == 0" class="image-wrap">
  40. <easy-loadimage
  41. :imageSrc="item.image_input[0]"
  42. :borderRadius="borderRadius"
  43. width="100%"
  44. height="100%"
  45. ></easy-loadimage>
  46. </view>
  47. <view class="time-wrap" :style="[numberStyle]">
  48. <view
  49. v-if="dataConfig.checkboxList.type.includes(0)"
  50. class="time time-wrap-item"
  51. :style="[timeStyle]"
  52. >{{ item.add_time }}</view
  53. >
  54. <view v-else class="time time-wrap-item"></view>
  55. <view class="like-wrap time-wrap-item">
  56. <view
  57. v-if="dataConfig.checkboxList.type.includes(1)"
  58. class="view acea-row row-middle"
  59. :class="!isLike ? 'on' : ''"
  60. >
  61. <text
  62. class="iconfont icon-liulan"
  63. :style="[iconEyesStyle]"
  64. ></text
  65. >{{ item.visit }}
  66. </view>
  67. <!-- <view v-if="dataConfig.checkboxList.type.includes(2)" class="like">
  68. <text class="iconfont icon-ic_Like" :style="[iconLikeStyle]"></text>{{ item.likes }}
  69. </view> -->
  70. </view>
  71. </view>
  72. </view>
  73. </navigator>
  74. </view>
  75. </common-wrapper>
  76. </template>
  77. <script>
  78. import commonWrapper from "./commonWrapper.vue";
  79. import { getArticleList } from "@/api/api.js";
  80. import dayjs from "@/plugin/dayjs/dayjs.min.js";
  81. export default {
  82. components: { commonWrapper },
  83. name: "articleList",
  84. props: {
  85. dataConfig: {
  86. type: Object,
  87. default: () => {},
  88. },
  89. isSortType: {
  90. type: String | Number,
  91. default: 0,
  92. },
  93. },
  94. data() {
  95. return {
  96. articleList: [],
  97. };
  98. },
  99. computed: {
  100. configData() {
  101. return {
  102. ...this.dataConfig,
  103. paddingConfig: this.dataConfig.paddingConfig || {
  104. isAll: false,
  105. valList: [
  106. {
  107. val: this.dataConfig.topConfig
  108. ? this.dataConfig.topConfig.val
  109. : 0,
  110. },
  111. {
  112. val: this.dataConfig.prConfig ? this.dataConfig.prConfig.val : 0,
  113. },
  114. {
  115. val: this.dataConfig.bottomConfig
  116. ? this.dataConfig.bottomConfig.val
  117. : 0,
  118. },
  119. {
  120. val: this.dataConfig.prConfig ? this.dataConfig.prConfig.val : 0,
  121. },
  122. ],
  123. },
  124. marginConfig: this.dataConfig.marginConfig || {
  125. isAll: false,
  126. valList: [
  127. {
  128. val: this.dataConfig.mbConfig ? this.dataConfig.mbConfig.val : 0,
  129. },
  130. {
  131. val: 0,
  132. },
  133. {
  134. val: 0,
  135. },
  136. {
  137. val: 0,
  138. },
  139. ],
  140. },
  141. };
  142. },
  143. isLike() {
  144. let like = true;
  145. like = this.dataConfig.checkboxList.type.includes(2);
  146. return like;
  147. },
  148. borderRadius() {
  149. let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
  150. if (this.dataConfig.filletImg.type) {
  151. borderRadius = `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${
  152. this.dataConfig.filletImg.valList[1].val * 2
  153. }rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx ${
  154. this.dataConfig.filletImg.valList[2].val * 2
  155. }rpx`;
  156. }
  157. return borderRadius;
  158. },
  159. timeStyle() {
  160. return {
  161. color: this.dataConfig.timeColor.color[0].item,
  162. };
  163. },
  164. iconEyesStyle() {
  165. return {
  166. color: this.dataConfig.browseColor.color[0].item,
  167. };
  168. },
  169. // iconLikeStyle() {
  170. // return {
  171. // 'color': this.dataConfig.likeColor.color[0].item,
  172. // };
  173. // },
  174. numberStyle() {
  175. return {
  176. color: this.dataConfig.statisticColor.color[0].item,
  177. };
  178. },
  179. articleItemStyle() {
  180. let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
  181. if (this.dataConfig.fillet.type) {
  182. borderRadius = `${this.dataConfig.fillet.valList[0].val * 2}rpx ${
  183. this.dataConfig.fillet.valList[1].val * 2
  184. }rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx ${
  185. this.dataConfig.fillet.valList[2].val * 2
  186. }rpx`;
  187. }
  188. return {
  189. "border-radius": borderRadius,
  190. background: `linear-gradient(90deg, ${this.dataConfig.bgColor.color[0].item} 0%, ${this.dataConfig.bgColor.color[1].item} 100%)`,
  191. };
  192. },
  193. titleStyle() {
  194. let styleObject = {
  195. color: this.dataConfig.nameColor.color[0].item,
  196. };
  197. if (!this.dataConfig.nameConfig.tabVal) {
  198. styleObject["font-weight"] = "bold";
  199. }
  200. return styleObject;
  201. },
  202. },
  203. mounted() {
  204. this.getCidArticle();
  205. },
  206. methods: {
  207. getCidArticle: function () {
  208. let limit = this.$config.LIMIT;
  209. getArticleList(this.dataConfig.selectConfig.activeValue || 0, {
  210. page: 1,
  211. // limit: this.dataConfig.numConfig.val >= limit ? limit : this.dataConfig.numConfig.val
  212. limit: this.dataConfig.numConfig.val,
  213. }).then((res) => {
  214. if (this.dataConfig.styleConfig.tabVal == 2) {
  215. res.data.forEach((item) => {
  216. item.add_time = dayjs(item.add_time).format("MM-DD HH:mm");
  217. });
  218. }
  219. this.articleList = res.data;
  220. });
  221. },
  222. },
  223. };
  224. </script>
  225. <style lang="scss">
  226. .articleList {
  227. .item {
  228. display: flex;
  229. padding: 20rpx;
  230. margin: 0;
  231. background: #ffffff;
  232. margin-bottom: 20rpx;
  233. &:last-child {
  234. margin-bottom: 0;
  235. }
  236. }
  237. .text-wrap {
  238. flex: 1;
  239. display: flex;
  240. flex-direction: column;
  241. padding: 0 0 6rpx 24rpx;
  242. }
  243. .title-wrap {
  244. flex: 1;
  245. }
  246. .title {
  247. font-size: 30rpx;
  248. line-height: 42rpx;
  249. color: #333333;
  250. }
  251. .label-wrap {
  252. margin-top: 16rpx;
  253. font-size: 0;
  254. }
  255. .label {
  256. display: inline-flex;
  257. flex-wrap: nowrap;
  258. height: 28rpx;
  259. padding: 0 6rpx;
  260. border: 1rpx solid #e93323;
  261. border-radius: 6rpx;
  262. font-size: 20rpx;
  263. color: #e93323;
  264. }
  265. .image-wrap {
  266. width: 240rpx;
  267. height: 152rpx;
  268. }
  269. .time-wrap {
  270. display: flex;
  271. font-size: 24rpx;
  272. line-height: 34rpx;
  273. color: #999999;
  274. .time-wrap-item:first-child {
  275. flex: 1;
  276. }
  277. }
  278. .like-wrap {
  279. display: flex;
  280. }
  281. .view {
  282. flex: 1;
  283. &.on {
  284. margin-right: 0;
  285. }
  286. }
  287. .iconfont {
  288. margin-right: 8rpx;
  289. font-size: 28rpx;
  290. }
  291. &.large {
  292. .item {
  293. flex-direction: column;
  294. padding: 0;
  295. }
  296. .text-wrap {
  297. padding: 32rpx 24rpx;
  298. }
  299. .image-wrap {
  300. width: 100%;
  301. height: 320rpx;
  302. margin-top: 24rpx;
  303. }
  304. .time-wrap {
  305. margin-top: 24rpx;
  306. }
  307. }
  308. &.small {
  309. display: flex;
  310. flex-wrap: wrap;
  311. justify-content: space-between;
  312. .item {
  313. flex-direction: column;
  314. width: calc(50% - 10rpx);
  315. padding: 0;
  316. margin-bottom: 20rpx;
  317. box-sizing: border-box;
  318. }
  319. .text-wrap {
  320. padding: 20rpx 20rpx 18rpx;
  321. box-sizing: border-box;
  322. }
  323. .image-wrap {
  324. width: 100%;
  325. height: auto;
  326. aspect-ratio: 342 / 216;
  327. }
  328. .label-wrap {
  329. margin-top: 16rpx;
  330. }
  331. .time-wrap {
  332. margin-top: 16rpx;
  333. }
  334. .like-wrap {
  335. justify-content: space-between;
  336. }
  337. }
  338. }
  339. </style>