index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="simple-pagination p-2" :class="'theme-' + themeType">
  3. <van-pagination
  4. v-model="currentPage"
  5. :total-items="total"
  6. :items-per-page="pageItems"
  7. :show-page-size="6"
  8. :force-ellipses="true"
  9. :mode="mode"
  10. @change="$emit('change', currentPage)"
  11. />
  12. </div>
  13. </template>
  14. <script>
  15. import { mapGetters } from 'vuex'
  16. export default {
  17. props: {
  18. total: {
  19. type: Number,
  20. default: 0,
  21. },
  22. pageItems: {
  23. type: Number,
  24. default: 10,
  25. },
  26. themeType: {
  27. type: String,
  28. default: 'red',
  29. },
  30. },
  31. data() {
  32. return {
  33. currentPage: 1,
  34. }
  35. },
  36. computed: {
  37. ...mapGetters(['isPc']),
  38. mode() {
  39. return this.isPc ? 'multi' : 'simple'
  40. },
  41. },
  42. }
  43. </script>
  44. <style scoped lang="scss">
  45. @media screen and (min-width: 768px) {
  46. .simple-pagination {
  47. display: flex;
  48. justify-content: center;
  49. &.theme-black {
  50. .van-pagination {
  51. ::v-deep {
  52. .van-pagination__item {
  53. margin-left: 4px;
  54. margin-right: 4px;
  55. color: #000;
  56. &:active {
  57. color: #fff;
  58. background-color: #000;
  59. }
  60. }
  61. .van-pagination__prev,
  62. .van-pagination__next {
  63. background: transparent !important;
  64. color: #101010;
  65. &::after {
  66. border-color: transparent !important;
  67. }
  68. &:hover {
  69. color: #000;
  70. }
  71. }
  72. .van-pagination__item--active {
  73. background-color: #000 !important;
  74. color: #fff;
  75. }
  76. }
  77. }
  78. }
  79. &.theme-red {
  80. .van-pagination {
  81. ::v-deep {
  82. .van-pagination__item {
  83. margin-left: 4px;
  84. margin-right: 4px;
  85. color: #bc1724;
  86. &:active {
  87. color: #fff;
  88. background-color: #bc1724;
  89. }
  90. }
  91. .van-pagination__prev,
  92. .van-pagination__next {
  93. background: transparent !important;
  94. color: #101010;
  95. &::after {
  96. border-color: transparent !important;
  97. }
  98. &:hover {
  99. color: #bc1724;
  100. }
  101. }
  102. .van-pagination__item--active {
  103. background-color: #bc1724 !important;
  104. color: #fff;
  105. }
  106. }
  107. }
  108. }
  109. }
  110. }
  111. @media screen and (max-width: 768px) {
  112. .simple-pagination {
  113. &.theme-red {
  114. ::v-deep {
  115. .van-pagination__prev,
  116. .van-pagination__next {
  117. color: #101010;
  118. &::after {
  119. border-color: transparent !important;
  120. }
  121. &:active {
  122. color: #fff;
  123. background-color: #bc1724;
  124. }
  125. }
  126. }
  127. }
  128. &.theme-black {
  129. ::v-deep {
  130. .van-pagination__prev,
  131. .van-pagination__next {
  132. color: #101010;
  133. &::after {
  134. border-color: transparent !important;
  135. }
  136. &:active {
  137. color: #fff;
  138. background-color: #000;
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145. </style>