List.vue 4.2 KB

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