index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div class="mobile-content">
  3. <div class="seek-title">
  4. <img src="/images/mobile/@2x/applyPurchase/home/seek-title.png" alt="">
  5. <span>最新求购信息</span>
  6. </div>
  7. <seek-list :purchaseManList="purchaseManList"></seek-list>
  8. <loading v-show="isSearchSearchingMore"></loading>
  9. </div>
  10. </template>
  11. <script>
  12. import SeekList from '~components/mobile/applyPurchase/SeekList.vue'
  13. import {Loading} from '~components/mobile/common'
  14. export default {
  15. layout: 'mobile',
  16. components: {
  17. SeekList,
  18. Loading
  19. },
  20. data () {
  21. return {
  22. isSearchSearchingMore: false,
  23. page: 1,
  24. size: 10
  25. }
  26. },
  27. // mounted: function () {
  28. // let _this = this
  29. // _this.$nextTick(function () {
  30. // window.addEventListener('scroll', function () {
  31. // _this.scroll()
  32. // }, false)
  33. // })
  34. // },
  35. fetch ({store}) {
  36. return Promise.all([
  37. store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: 1, pageSize: 10, enUU: store.state.option.user.data.enterprise ? store.state.option.user.data.enterprise.uu : null})
  38. ])
  39. },
  40. computed: {
  41. purchaseManList () {
  42. return this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  43. },
  44. allPage () {
  45. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  46. }
  47. },
  48. methods: {
  49. scroll: function () {
  50. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  51. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  52. this.getMoreSearch()
  53. }
  54. },
  55. getMoreSearch: function () {
  56. this.page++
  57. this.isSearchSearchingMore = true
  58. this.$store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: this.page, pageSize: this.size, enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null})
  59. }
  60. }
  61. }
  62. </script>