index.vue 4.9 KB

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