tab.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="rank-table" :class="{'td-underline': !isMoblie}">
  3. <div class="table-nav">
  4. <button :class="{'active': curTab == 0}" @click="curTab = 0">{{$t('table.live')}}</button>
  5. <button :class="{'active': curTab == 1}" @click="curTab = 1">{{$t('table.myBet')}}</button>
  6. <button :class="{'active': curTab == 2}" @click="curTab = 2">{{$t('table.hugeWin')}}</button>
  7. </div>
  8. <div class="game-table-border">
  9. <div class="game-table-bg">
  10. <live @endloading="isLoadMore = false" :bot="liveBot" v-show="curTab == 0"></live>
  11. <mine @endloading="isLoadMore = false" :bot="myBetBot" v-show="curTab == 1"></mine>
  12. <huge-prize @endloading="isLoadMore = false" :bot="hugeWinBot" v-show="curTab == 2"></huge-prize>
  13. <div class="load-more" v-show="isLoadMore">{{$t('loading')}}</div>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import live from './live'
  20. import hugePrize from './hugePrize'
  21. import mine from './mine'
  22. import { debounce } from 'throttle-debounce'
  23. export default {
  24. components: {
  25. live,
  26. hugePrize,
  27. mine
  28. },
  29. mounted () {
  30. window.addEventListener('scroll', this.handleScroll())
  31. },
  32. computed: {
  33. account () {
  34. return this.$store.account
  35. }
  36. },
  37. data () {
  38. return {
  39. tabList: [
  40. this.$t('table.live'),
  41. this.$t('table.myBet'),
  42. this.$t('table.hugeWin')
  43. ],
  44. curTab: 0,
  45. isMoblie: /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent),
  46. isLoadMore: false,
  47. liveBot: 1,
  48. myBetBot: 1,
  49. hugeWinBot: 1
  50. }
  51. },
  52. methods: {
  53. loadMore () {
  54. this.isLoadMore = true
  55. if (this.curTab === 0) {
  56. this.liveBot++
  57. } else if (this.curTab === 1) {
  58. this.myBetBot++
  59. } else if (this.curTab === 2) {
  60. this.hugeWinBot++
  61. }
  62. },
  63. handleScroll () {
  64. let beforeScrollTop = document.documentElement.scrollTop
  65. let self = this
  66. this.scrollFun = debounce(500, (e) => {
  67. var afterScrollTop = document.documentElement.scrollTop
  68. if (afterScrollTop - beforeScrollTop > 0) {
  69. var wScrollY = window.scrollY
  70. var wInnerH = window.innerHeight
  71. var bScrollH = document.body.scrollHeight
  72. if (wScrollY + wInnerH + 200 >= bScrollH) {
  73. if (self.isLoadMore === false) {
  74. self.loadMore()
  75. }
  76. }
  77. }
  78. beforeScrollTop = afterScrollTop
  79. })
  80. return this.scrollFun
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. @import './style.scss';
  87. </style>