index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. @include useTheme() {
  48. display: flex;
  49. justify-content: center;
  50. &.theme-black {
  51. .van-pagination {
  52. ::v-deep {
  53. .van-pagination__item {
  54. margin-left: 4px;
  55. margin-right: 4px;
  56. color: #000;
  57. &:active {
  58. color: #fff;
  59. background-color: #000;
  60. }
  61. }
  62. .van-pagination__prev,
  63. .van-pagination__next {
  64. background: transparent !important;
  65. color: #101010;
  66. &::after {
  67. border-color: transparent !important;
  68. }
  69. &:hover {
  70. color: #000;
  71. }
  72. }
  73. .van-pagination__item--active {
  74. background-color: #000 !important;
  75. color: #fff;
  76. }
  77. }
  78. }
  79. }
  80. &.theme-red {
  81. .van-pagination {
  82. ::v-deep {
  83. .van-pagination__item {
  84. margin-left: 4px;
  85. margin-right: 4px;
  86. color: fetch('color');
  87. &:active {
  88. color: #fff;
  89. background-color: fetch('color');
  90. }
  91. }
  92. .van-pagination__prev,
  93. .van-pagination__next {
  94. background: transparent !important;
  95. color: #101010;
  96. &::after {
  97. border-color: transparent !important;
  98. }
  99. &:hover {
  100. color: fetch('color');
  101. }
  102. }
  103. .van-pagination__item--active {
  104. background-color: fetch('color') !important;
  105. color: #fff;
  106. }
  107. }
  108. }
  109. }
  110. }
  111. }
  112. }
  113. @media screen and (max-width: 768px) {
  114. .simple-pagination {
  115. @include useTheme() {
  116. &.theme-red {
  117. ::v-deep {
  118. .van-pagination__prev,
  119. .van-pagination__next {
  120. color: #101010;
  121. &::after {
  122. border-color: transparent !important;
  123. }
  124. &:active {
  125. color: #fff;
  126. background-color: fetch('color');
  127. }
  128. }
  129. }
  130. }
  131. &.theme-black {
  132. ::v-deep {
  133. .van-pagination__prev,
  134. .van-pagination__next {
  135. color: #101010;
  136. &::after {
  137. border-color: transparent !important;
  138. }
  139. &:active {
  140. color: rgb(236, 216, 216);
  141. background-color: #000;
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. }
  149. </style>