index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. @include themify($themes) {
  86. color: themed('color');
  87. }
  88. &:active {
  89. color: #fff;
  90. @include themify($themes) {
  91. background-color: themed('color');
  92. }
  93. }
  94. }
  95. .van-pagination__prev,
  96. .van-pagination__next {
  97. background: transparent !important;
  98. color: #101010;
  99. &::after {
  100. border-color: transparent !important;
  101. }
  102. &:hover {
  103. @include themify($themes) {
  104. color: themed('color');
  105. }
  106. }
  107. }
  108. .van-pagination__item--active {
  109. @include themify($themes) {
  110. background-color: themed('color') !important;
  111. }
  112. color: #fff;
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. @media screen and (max-width: 768px) {
  120. .simple-pagination {
  121. &.theme-red {
  122. ::v-deep {
  123. .van-pagination__prev,
  124. .van-pagination__next {
  125. color: #101010;
  126. &::after {
  127. border-color: transparent !important;
  128. }
  129. &:active {
  130. color: #fff;
  131. @include themify($themes) {
  132. background-color: themed('color');
  133. }
  134. }
  135. }
  136. }
  137. }
  138. &.theme-black {
  139. ::v-deep {
  140. .van-pagination__prev,
  141. .van-pagination__next {
  142. color: #101010;
  143. &::after {
  144. border-color: transparent !important;
  145. }
  146. &:active {
  147. color: #fff;
  148. background-color: #000;
  149. }
  150. }
  151. }
  152. }
  153. }
  154. }
  155. </style>