index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div class="mobile-content">
  3. <div class="mobile-header">
  4. <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  5. <div class="search-content">
  6. <input type="text" v-model="seekKeyword" placeholder="请输入您要查找的型号或品牌" @keyup.13="searchSeek">
  7. <span @click="searchSeek">
  8. <i class="iconfont icon-sousuo"></i>
  9. </span>
  10. </div>
  11. </div>
  12. <div class="seek-title">
  13. <img src="/images/mobile/@2x/applyPurchase/home/seek-title.png" alt="">
  14. <span>最新求购信息</span>
  15. </div>
  16. <seek-list :purchaseManList="purchaseManListData"></seek-list>
  17. <loading v-show="isSearchSearchingMore"></loading>
  18. <div v-if="purchaseManList && false"></div>
  19. </div>
  20. </template>
  21. <script>
  22. import SeekList from '~components/mobile/applyPurchase/SeekList.vue'
  23. import {Loading} from '~components/mobile/common'
  24. export default {
  25. layout: 'mobile',
  26. components: {
  27. SeekList,
  28. Loading
  29. },
  30. data () {
  31. return {
  32. isSearchSearchingMore: false,
  33. page: 1,
  34. size: 10,
  35. purchaseManListData: [],
  36. showSeekSearch: true,
  37. seekKeyword: '',
  38. isChange: false
  39. }
  40. },
  41. mounted: function () {
  42. this.$nextTick(() => {
  43. window.addEventListener('scroll', this.scroll, false)
  44. })
  45. },
  46. // watch: {
  47. // $route: function (val, oldVal) {
  48. // window.removeEventListener('scroll', this.scroll, false)
  49. // }
  50. // },
  51. fetch ({store}) {
  52. return Promise.all([
  53. store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: 1, pageSize: 10, sorting: {'releaseDate': 'DESC'}, keyword: this.seekKeyword, enUU: store.state.option.user.data.enterprise ? store.state.option.user.data.enterprise.uu : null})
  54. ])
  55. },
  56. computed: {
  57. purchaseManList () {
  58. let list = this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  59. if (this.isChange) {
  60. this.purchaseManListData = []
  61. this.seekPage = 1
  62. this.isChange = false
  63. } else {
  64. this.purchaseManListData = this.purchaseManListData.concat(list.content)
  65. this.isSearchSearchingMore = false
  66. }
  67. return this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  68. },
  69. allPage () {
  70. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  71. }
  72. },
  73. methods: {
  74. scroll: function () {
  75. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  76. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  77. this.getMoreSearch()
  78. }
  79. },
  80. getMoreSearch: function () {
  81. this.page++
  82. this.isSearchSearchingMore = true
  83. this.reloadData()
  84. },
  85. reloadData: function () {
  86. this.$store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: this.page, pageSize: this.size, sorting: {'releaseDate': 'DESC'}, keyword: this.seekKeyword, enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null})
  87. },
  88. goLastPage: function () {
  89. window.history.back(-1)
  90. },
  91. searchSeek: function () {
  92. this.page = 1
  93. this.isChange = true
  94. this.reloadData()
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .mobile-content {
  101. .mobile-header {
  102. position: fixed;
  103. top: 0;
  104. z-index: 10;
  105. width:100%;
  106. height:.88rem;
  107. line-height: .88rem;
  108. background: #3e82f5;
  109. padding:0 .2rem 0 .1rem;
  110. color:#fff;
  111. > a {
  112. font-size:.28rem;
  113. color:#fff;
  114. position: absolute;
  115. i {
  116. font-size: .48rem;
  117. margin-right: -.1rem;
  118. }
  119. }
  120. .search-content {
  121. margin-left: .5rem;
  122. line-height: normal;
  123. padding-top: .08rem;
  124. input {
  125. color: #333;
  126. }
  127. }
  128. }
  129. }
  130. </style>