List.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="list">
  3. <div class="wrapper">
  4. <div class="tip" v-for="item in tipList" :key="item.id" @click="tipClick(item.id)">
  5. <img :src="item.image_input[0]" />
  6. <div class="info hand">
  7. <div class="title clamp">{{item.title}}</div>
  8. <div class="content clamp">{{item.synopsis}}</div>
  9. <div class="num">{{item.visit}}人已观看</div>
  10. </div>
  11. </div>
  12. <el-pagination layout="prev, pager, next" :total="total" background prev-text="上一页" next-text="下一页" @current-change="currentChange" :page-size="limit"></el-pagination>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import { splist } from '../../request/api.js'
  18. export default {
  19. data() {
  20. return {
  21. tipList: [],
  22. alllist: [],
  23. total: 0,
  24. page: 1,
  25. limit: 7
  26. }
  27. },
  28. created() {
  29. this.getAllList()
  30. },
  31. methods: {
  32. tipClick(id) {
  33. this.$router.push('/popularScience/detail?id=' + id)
  34. },
  35. //分页页码改变触发事件
  36. currentChange(e) {
  37. console.log(e);
  38. this.page = e
  39. this.getList()
  40. },
  41. getAllList() {
  42. let obj = this
  43. let data = {
  44. page: this.page,
  45. limit: this.limit
  46. }
  47. splist().then(({data}) => {
  48. obj.total = data.count
  49. obj.tipList = data.list
  50. console.log(obj.total,'obj.total ++++++++++')
  51. })
  52. },
  53. getList() {
  54. let obj = this
  55. let data = {
  56. page: this.page,
  57. limit: this.limit
  58. }
  59. splist(data).then(({data}) => {
  60. obj.tipList = data.list
  61. })
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .tip{
  68. width: 815px;
  69. height: 127px;
  70. border-bottom: 1px solid #F2F2F2;
  71. display: flex;
  72. align-items: center;
  73. img {
  74. width: 155px;
  75. height: 98px;
  76. }
  77. .info {
  78. padding-left: 16px;
  79. .title {
  80. padding-top: 5px;
  81. width: 200px;
  82. // height: 19px;
  83. font-size: 18px;
  84. font-family: PingFang SC;
  85. font-weight: bold;
  86. color: #333333;
  87. }
  88. .content {
  89. width: 491px;
  90. height: 16px;
  91. font-size: 16px;
  92. font-family: PingFang SC;
  93. font-weight: 500;
  94. color: #999999;
  95. line-height: 1;
  96. padding-top: 11px;
  97. }
  98. .num {
  99. margin-top: 24px;
  100. height: 16px;
  101. font-size: 16px;
  102. font-family: PingFang SC;
  103. font-weight: 500;
  104. color: #999999;
  105. line-height: 27px;
  106. text-align: right;
  107. }
  108. }
  109. }
  110. /deep/ .el-pagination {
  111. margin-top: 50px;
  112. text-align: center;
  113. }
  114. </style>