lunbo.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div id="lunbo">
  3. <el-row>
  4. <el-col :span="24" style="width:540;height:304px;" v-loading="loading">
  5. <div class="block">
  6. <el-carousel height="304px">
  7. <el-carousel-item class="list" v-for="(item, index) in infoList" :key="index" @click.native="$turnTo(item)">
  8. <el-image style="width:540px;height:304px;" :src="item.pic"></el-image>
  9. <span class="title textOver">{{ item.title }}</span>
  10. <span>{{ item.url }}</span>
  11. </el-carousel-item>
  12. </el-carousel>
  13. </div>
  14. </el-col>
  15. </el-row>
  16. </div>
  17. </template>
  18. <script>
  19. import _ from 'lodash';
  20. export default {
  21. name: 'lunbo',
  22. props: {
  23. carouselList: null,
  24. },
  25. components: {},
  26. data: () => ({
  27. infoList: [],
  28. loading: true,
  29. }),
  30. watch: {
  31. carouselList: {
  32. handler(val) {
  33. if (val) this.assignData(val);
  34. },
  35. },
  36. },
  37. created() {},
  38. computed: {},
  39. methods: {
  40. assignData(data) {
  41. let columns = _.get(data, 'children');
  42. let news = [];
  43. for (const item of columns) {
  44. if (!this.path) this.path = item.path;
  45. let carouselList = _.get(item, `children`);
  46. if (carouselList) {
  47. news = news.concat(news, carouselList);
  48. }
  49. }
  50. this.$set(this, `infoList`, news);
  51. this.loading = false;
  52. },
  53. // turnTo(item) {
  54. // if (item.info_type == 1) {
  55. // window.location.href = item.url;
  56. // } else {
  57. // let route = this.$route.path;
  58. // this.$router.push({ path: `/detail?id=${item.id}` });
  59. // }
  60. // },
  61. },
  62. };
  63. </script>
  64. <style lang="less" scoped>
  65. .textOver {
  66. overflow: hidden;
  67. text-overflow: ellipsis;
  68. white-space: nowrap;
  69. }
  70. /deep/.el-carousel__indicators {
  71. display: none;
  72. }
  73. .list .title {
  74. position: absolute;
  75. bottom: 0;
  76. left: 0;
  77. width: 100%;
  78. height: 40px;
  79. line-height: 40px;
  80. background-color: rgba(0, 0, 0, 0.4);
  81. padding: 0 10px;
  82. font-size: 16px;
  83. color: #fff;
  84. }
  85. .list:hover {
  86. cursor: pointer;
  87. }
  88. </style>