List.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="supplier-list 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="keyword" placeholder="请输入您要查找的供应商" @keyup.13="search">
  7. <span @click="search">
  8. <i class="iconfont icon-sousuo"></i>
  9. </span>
  10. </div>
  11. </div>
  12. <ul>
  13. <!--<li v-for="item in listData">-->
  14. <nuxt-link v-bind:key="item.id" v-for="item in listData" tag="li" :to="`/mobile/supplier/detail/${item.enUU}?isStore=${item.isStore}`">
  15. <nuxt-link :to="`/mobile/supplier/detail/${item.enUU}?isStore=${item.isStore}`">
  16. <img v-if="item.isStore == 1" class="open" src="/images/mobile/supplier/is-open.png" alt="">
  17. <span>{{item.enName}}</span>
  18. <img class="tag" src="/images/mobile/supplier/tag.png" alt="">
  19. </nuxt-link>
  20. </nuxt-link>
  21. <!--</li>-->
  22. </ul>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. data () {
  28. return {
  29. keyword: '',
  30. isSearchSearchingMore: false,
  31. page: 1,
  32. size: 10,
  33. listData: [],
  34. isChange: false,
  35. isDataChange: false
  36. }
  37. },
  38. mounted: function () {
  39. this.$nextTick(() => {
  40. window.addEventListener('scroll', this.scroll, false)
  41. })
  42. },
  43. watch: {
  44. 'list': {
  45. handler (val, oldVal) {
  46. if (this.isChange) {
  47. this.listData = val.content
  48. this.page = 1
  49. this.isChange = false
  50. this.isDataChange = true
  51. } else {
  52. this.listData = this.listData.concat(val.content)
  53. this.isSearchSearchingMore = false
  54. this.isDataChange = false
  55. }
  56. },
  57. immediate: true
  58. }
  59. },
  60. computed: {
  61. list () {
  62. return this.$store.state.supplier.data.list.data
  63. },
  64. allPage () {
  65. return Math.floor(this.list.totalElements / this.list.size) + Math.floor(this.list.totalElements % this.list.size > 0 ? 1 : 0)
  66. }
  67. },
  68. methods: {
  69. goLastPage: function () {
  70. window.history.back(-1)
  71. },
  72. scroll: function () {
  73. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  74. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  75. this.getMoreSearch()
  76. }
  77. },
  78. getMoreSearch: function () {
  79. this.page++
  80. this.isSearchSearchingMore = true
  81. this.reloadData()
  82. },
  83. reloadData: function () {
  84. this.$store.dispatch('supplier/getSupplierList', {keyword: this.keyword, page: this.page, size: this.size})
  85. },
  86. search: function () {
  87. this.page = 1
  88. this.isChange = true
  89. this.reloadData()
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .supplier-list {
  96. height: 100%;
  97. background: #29a9f9;
  98. .mobile-header {
  99. position: fixed;
  100. top: 0;
  101. z-index: 10;
  102. width:100%;
  103. height:.88rem;
  104. line-height: .88rem;
  105. background: #3e82f5;
  106. padding:0 .2rem 0 .1rem;
  107. color:#fff;
  108. > a {
  109. font-size:.28rem;
  110. color:#fff;
  111. position: absolute;
  112. i {
  113. font-size: .48rem;
  114. margin-right: -.1rem;
  115. }
  116. }
  117. .search-content {
  118. margin-left: .5rem;
  119. line-height: normal;
  120. padding-top: .14rem;
  121. input {
  122. color: #333;
  123. width: 6.48rem;
  124. line-height: normal;
  125. }
  126. span {
  127. height: .46rem;
  128. line-height: .46rem;
  129. }
  130. }
  131. }
  132. ul {
  133. margin: .26rem auto 0;
  134. width: 6.91rem;
  135. li {
  136. position: relative;
  137. height: 1.21rem;
  138. background: #fff;
  139. line-height: 1.21rem;
  140. padding-left: .74rem;
  141. font-size: .32rem;
  142. margin-bottom: .14rem;
  143. border-radius: .05rem;
  144. .open {
  145. width: 1.35rem;
  146. position: absolute;
  147. top: -.08rem;
  148. left: -.1rem;
  149. }
  150. .tag {
  151. width: 1.08rem;
  152. position: absolute;
  153. right: -.1rem;
  154. top: .16rem;
  155. }
  156. span {
  157. color: #333;
  158. }
  159. }
  160. }
  161. }
  162. </style>