index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div>
  3. <search-header @searchAction="searchSeek" :useMatchRule="false" :type="'purchase'" :outerKeyword="searchKeyword" :placeholder="user.logged ? '公司/品牌/物料名称/型号/规格' : '品牌/物料名称/型号/规格'"></search-header>
  4. <div class="mobile-content">
  5. <div class="seek-title">
  6. <img src="/images/mobile/@2x/applyPurchase/home/seek-title.png" alt="">
  7. <span>最新求购信息</span>
  8. </div>
  9. <seek-list :isSearch="isSearch" :keyword="searchKeyword" :purchaseManList="purchaseManListData" :isDataChange="isDataChange"></seek-list>
  10. <!--<loading v-show="isSearchSearchingMore"></loading>-->
  11. <div v-if="purchaseManList && false"></div>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import SeekList from '~components/mobile/applyPurchase/SeekList.vue'
  17. import {Loading} from '~components/mobile/common'
  18. import {SearchHeader} from '~components/mobile/base'
  19. export default {
  20. layout: 'mobile',
  21. components: {
  22. SeekList,
  23. Loading,
  24. SearchHeader
  25. },
  26. data () {
  27. return {
  28. isSearchSearchingMore: false,
  29. page: 1,
  30. size: 10,
  31. purchaseManListData: [],
  32. showSeekSearch: true,
  33. seekKeyword: '',
  34. isChange: false,
  35. isDataChange: false,
  36. isSearch: false,
  37. searchKeyword: ''
  38. }
  39. },
  40. mounted: function () {
  41. this.$nextTick(() => {
  42. window.addEventListener('scroll', this.scroll, false)
  43. })
  44. },
  45. // watch: {
  46. // $route: function (val, oldVal) {
  47. // window.removeEventListener('scroll', this.scroll, false)
  48. // }
  49. // },
  50. fetch ({store}) {
  51. return Promise.all([
  52. 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})
  53. ])
  54. },
  55. computed: {
  56. purchaseManList () {
  57. let list = this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  58. if (this.isChange) {
  59. this.purchaseManListData = []
  60. this.page = 1
  61. this.isChange = false
  62. this.isDataChange = true
  63. } else {
  64. this.purchaseManListData = this.purchaseManListData.concat(list.content)
  65. this.isSearchSearchingMore = false
  66. this.isDataChange = false
  67. }
  68. return this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  69. },
  70. allPage () {
  71. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  72. }
  73. },
  74. methods: {
  75. scroll: function () {
  76. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  77. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  78. this.getMoreSearch()
  79. }
  80. },
  81. getMoreSearch: function () {
  82. this.page++
  83. this.isSearchSearchingMore = true
  84. this.reloadData()
  85. },
  86. reloadData: function () {
  87. this.$store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: this.page, pageSize: this.size, sorting: {'releaseDate': 'DESC'}, keyword: this.seekKeyword = this.searchKeyword === '' ? null : this.searchKeyword, enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null, isLogin: this.user.logged ? '1' : '0'})
  88. },
  89. searchSeek: function (type) {
  90. this.isSearch = true
  91. this.searchKeyword = type.keyword
  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: .14rem;
  124. input {
  125. color: #333;
  126. width: 6.48rem;
  127. line-height: normal;
  128. }
  129. span {
  130. height: .46rem;
  131. line-height: .46rem;
  132. }
  133. }
  134. }
  135. }
  136. </style>