InvitePagination.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="pagination-wrap">
  3. <div class="left" @click="pageChangeHandle('left')">
  4. <van-icon name="arrow-double-left" :color="isDisabled('left')" />
  5. </div>
  6. <div class="page-num">{{ currentPage }}/{{ pageCount }}</div>
  7. <div class="right" @click="pageChangeHandle('right')">
  8. <van-icon name="arrow-double-right" :color="isDisabled('right')"/>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'InvitePagination',
  15. props: {
  16. total: {
  17. type: Number,
  18. default: 0
  19. },
  20. pageSize: {
  21. type: Number,
  22. default: 5
  23. },
  24. currentPage: {
  25. type: Number,
  26. default: 1
  27. },
  28. },
  29. computed: {
  30. isDisabled(type) {
  31. return ()=>{
  32. let color = '#979797';
  33. if (type === 'left' && this.currentPage === 1) {
  34. color = '#bbb';
  35. }
  36. if (type === 'right' && this.currentPage === this.pageCount) {
  37. color = '#bbb';
  38. }
  39. return color;
  40. };
  41. },
  42. pageCount() {
  43. return Math.ceil(this.total / this.pageSize);
  44. }
  45. },
  46. methods: {
  47. pageChangeHandle(type) {
  48. if (type === 'left' && this.currentPage > 1) {
  49. this.$emit('onPageChange', this.currentPage - 1);
  50. }
  51. if (type === 'right' && this.currentPage < this.pageCount) {
  52. this.$emit('onPageChange', this.currentPage + 1);
  53. }
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .van-icon-arrow-double-left::before {
  60. content: "\e668";
  61. }
  62. .van-icon-arrow-double-right::before {
  63. content: "\e660";
  64. }
  65. .pagination-wrap{
  66. display: flex;
  67. flex-wrap: nowrap;
  68. justify-content: flex-end;
  69. align-items: center;
  70. .left,.right{
  71. width: 17.52px;
  72. height: 17.52px;
  73. font-size: 12px;
  74. }
  75. .page-num{
  76. text-align: center;
  77. font-size: 12px;
  78. width: 45px;
  79. font-weight: 400;
  80. font-size: 12px;
  81. color: #333;
  82. }
  83. }
  84. </style>