index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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="user.logged ? '品牌/类目型号//规格/公司' : '品牌/类目/型号/规格'" @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 :isSearch="isSearch" :keyword="remindKeyword" :purchaseManList="purchaseManListData" :isDataChange="isDataChange"></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. isDataChange: false,
  40. isSearch: false,
  41. remindKeyword: ''
  42. }
  43. },
  44. mounted: function () {
  45. this.$nextTick(() => {
  46. window.addEventListener('scroll', this.scroll, false)
  47. })
  48. },
  49. // watch: {
  50. // $route: function (val, oldVal) {
  51. // window.removeEventListener('scroll', this.scroll, false)
  52. // }
  53. // },
  54. fetch ({store}) {
  55. return Promise.all([
  56. 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})
  57. ])
  58. },
  59. computed: {
  60. purchaseManList () {
  61. let list = this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  62. if (this.isChange) {
  63. this.purchaseManListData = []
  64. this.page = 1
  65. this.isChange = false
  66. this.isDataChange = true
  67. } else {
  68. this.purchaseManListData = this.purchaseManListData.concat(list.content)
  69. this.isSearchSearchingMore = false
  70. this.isDataChange = false
  71. }
  72. return this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  73. },
  74. allPage () {
  75. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  76. }
  77. },
  78. methods: {
  79. scroll: function () {
  80. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  81. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  82. this.getMoreSearch()
  83. }
  84. },
  85. getMoreSearch: function () {
  86. this.page++
  87. this.isSearchSearchingMore = true
  88. this.reloadData()
  89. },
  90. reloadData: function () {
  91. 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, isLogin: this.user.logged ? '1' : '0'})
  92. },
  93. searchSeek: function () {
  94. this.isSearch = true
  95. this.remindKeyword = this.seekKeyword
  96. this.page = 1
  97. this.isChange = true
  98. this.reloadData()
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .mobile-content {
  105. .mobile-header {
  106. position: fixed;
  107. top: 0;
  108. z-index: 10;
  109. width:100%;
  110. height:.88rem;
  111. line-height: .88rem;
  112. background: #3e82f5;
  113. padding:0 .2rem 0 .1rem;
  114. color:#fff;
  115. > a {
  116. font-size:.28rem;
  117. color:#fff;
  118. position: absolute;
  119. i {
  120. font-size: .48rem;
  121. margin-right: -.1rem;
  122. }
  123. }
  124. .search-content {
  125. margin-left: .5rem;
  126. line-height: normal;
  127. padding-top: .14rem;
  128. input {
  129. color: #333;
  130. width: 6.48rem;
  131. line-height: normal;
  132. }
  133. span {
  134. height: .46rem;
  135. line-height: .46rem;
  136. }
  137. }
  138. }
  139. }
  140. </style>