businessOpportunity.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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/opportunity.png" alt="">
  14. <span>我的商机</span>
  15. </div>
  16. <seek-list v-if="purchaseManListData && purchaseManListData.length" :purchaseManList="purchaseManListData" :isDataChange="isDataChange"></seek-list>
  17. <div class="com-none-state" v-else>
  18. <img src="/images/mobile/@2x/car@2x.png">
  19. <p>对个人物料库进行维护后,可获得更多的商机哦!</p>
  20. <nuxt-link to="/">返回首页</nuxt-link>
  21. </div>
  22. <loading v-show="isSearchSearchingMore"></loading>
  23. <div v-if="purchaseManList && false"></div>
  24. </div>
  25. </template>
  26. <script>
  27. import SeekList from '~components/mobile/applyPurchase/SeekList.vue'
  28. import {Loading} from '~components/mobile/common'
  29. export default {
  30. layout: 'mobile',
  31. components: {
  32. SeekList,
  33. Loading
  34. },
  35. data () {
  36. return {
  37. isSearchSearchingMore: false,
  38. page: 1,
  39. size: 10,
  40. purchaseManListData: [],
  41. showSeekSearch: true,
  42. seekKeyword: '',
  43. isChange: false,
  44. isDataChange: false
  45. }
  46. },
  47. mounted: function () {
  48. this.$nextTick(() => {
  49. window.addEventListener('scroll', this.scroll, false)
  50. })
  51. },
  52. // watch: {
  53. // $route: function (val, oldVal) {
  54. // window.removeEventListener('scroll', this.scroll, false)
  55. // }
  56. // },
  57. fetch ({store}) {
  58. return Promise.all([
  59. store.dispatch('applyPurchase/loadVendorPushList', {pageNumber: 1, pageSize: 10, sorting: {'releaseDate': 'DESC'}, enuu: store.state.option.user.data.enterprise ? store.state.option.user.data.enterprise.uu : null, useruu: store.state.option.user.data.userUU})
  60. ])
  61. },
  62. computed: {
  63. purchaseManList () {
  64. let list = this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  65. if (this.isChange) {
  66. this.purchaseManListData = []
  67. this.seekPage = 1
  68. this.isChange = false
  69. this.isDataChange = true
  70. } else {
  71. this.purchaseManListData = this.purchaseManListData.concat(list.content || [])
  72. this.isSearchSearchingMore = false
  73. this.isDataChange = false
  74. }
  75. return this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  76. },
  77. allPage () {
  78. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  79. }
  80. },
  81. methods: {
  82. scroll: function () {
  83. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  84. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  85. this.getMoreSearch()
  86. }
  87. if (this.$refs.searchSeekInput && this.$store.state.mobile.InputGetFocus) {
  88. this.$refs.searchSeekInput.blur()
  89. }
  90. },
  91. blur: function() {
  92. // setTimeout(() => {
  93. this.$store.dispatch('mobile/SetInputGetFocus', false)
  94. // }, 300)
  95. },
  96. inputGetFocus: function() {
  97. setTimeout(() => {
  98. this.$store.dispatch('mobile/SetInputGetFocus', true)
  99. }, 300)
  100. },
  101. getMoreSearch: function () {
  102. this.page++
  103. this.isSearchSearchingMore = true
  104. this.reloadData()
  105. },
  106. reloadData: function () {
  107. this.$store.dispatch('applyPurchase/loadVendorPushList', {pageNumber: this.page, pageSize: this.size, sorting: {'releaseDate': 'DESC'}, keyword: this.seekKeyword, enuu: this.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null, useruu: this.user.data.userUU})
  108. },
  109. goLastPage: function () {
  110. window.history.back(-1)
  111. },
  112. searchSeek: function () {
  113. this.page = 1
  114. this.isChange = true
  115. this.reloadData()
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .mobile-content {
  122. .mobile-header {
  123. position: fixed;
  124. top: 0;
  125. z-index: 10;
  126. width:100%;
  127. height:.88rem;
  128. line-height: .88rem;
  129. background: #3e82f5;
  130. padding:0 .2rem 0 .1rem;
  131. color:#fff;
  132. > a {
  133. font-size:.28rem;
  134. color:#fff;
  135. position: absolute;
  136. i {
  137. font-size: .48rem;
  138. margin-right: -.1rem;
  139. }
  140. }
  141. .search-content {
  142. margin-left: .5rem;
  143. line-height: normal;
  144. padding-top: .14rem;
  145. input {
  146. color: #333;
  147. width: 5.78rem;
  148. line-height: normal;
  149. }
  150. span {
  151. height: .46rem;
  152. line-height: .46rem;
  153. }
  154. }
  155. }
  156. }
  157. </style>