List.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 v-if="listData && listData.length">
  13. <li v-for="item in listData" @click="goSupplierDetail(item)">
  14. <img v-if="item.isStore == 1" class="open" src="/images/mobile/supplier/is-open.png" alt="">
  15. <span>{{item.enName}}</span>
  16. <!--<img class="tag" src="/images/mobile/supplier/tag.png" alt="">-->
  17. <i class="tag iconfont icon-xiangyou"></i>
  18. </li>
  19. </ul>
  20. <div class="com-none-state" v-else>
  21. <img src="/images/mobile/@2x/search-empty.png">
  22. <p>抱歉,暂无搜索结果</p>
  23. <nuxt-link to="/">返回首页</nuxt-link>
  24. </div>
  25. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  26. </div>
  27. </template>
  28. <script>
  29. import { RemindBox } from '~components/mobile/common'
  30. export default {
  31. data () {
  32. return {
  33. keyword: '',
  34. isSearchSearchingMore: false,
  35. page: 1,
  36. size: 10,
  37. listData: [],
  38. isChange: false,
  39. isDataChange: false,
  40. remindText: '',
  41. timeoutCount: 0
  42. }
  43. },
  44. components: {
  45. RemindBox
  46. },
  47. mounted: function () {
  48. this.$nextTick(() => {
  49. window.addEventListener('scroll', this.scroll, false)
  50. })
  51. },
  52. watch: {
  53. 'list': {
  54. handler (val, oldVal) {
  55. if (this.isChange) {
  56. this.listData = val.content
  57. this.page = 1
  58. this.isChange = false
  59. this.isDataChange = true
  60. } else {
  61. this.listData = this.listData.concat(val.content)
  62. this.isSearchSearchingMore = false
  63. this.isDataChange = false
  64. }
  65. },
  66. immediate: true
  67. }
  68. },
  69. computed: {
  70. list () {
  71. return this.$store.state.supplier.data.list.data
  72. },
  73. allPage () {
  74. return Math.floor(this.list.totalElements / this.list.size) + Math.floor(this.list.totalElements % this.list.size > 0 ? 1 : 0)
  75. }
  76. },
  77. methods: {
  78. goLastPage: function () {
  79. window.history.back(-1)
  80. },
  81. scroll: function () {
  82. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  83. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  84. this.getMoreSearch()
  85. }
  86. },
  87. getMoreSearch: function () {
  88. this.page++
  89. this.isSearchSearchingMore = true
  90. this.reloadData()
  91. },
  92. reloadData: function () {
  93. this.$store.dispatch('supplier/getSupplierList', {keyword: this.keyword, page: this.page, size: this.size})
  94. },
  95. search: function () {
  96. this.page = 1
  97. this.isChange = true
  98. this.reloadData()
  99. },
  100. goSupplierDetail: function (item) {
  101. // /mobile/supplier/detail/${item.enUU}?isStore=${item.isStore}
  102. this.$http.get('/vendor/introduction/product/count', {params: {vendUU: item.enUU}})
  103. .then(response => {
  104. if (response.data.success && response.data.count > 0) {
  105. this.$router.push(`/mobile/supplier/detail/${item.enUU}?isStore=${item.isStore}`)
  106. } else {
  107. this.onRemind('供应商正在完善产品信息,暂时不能查看更多。')
  108. }
  109. })
  110. },
  111. onRemind: function(str) {
  112. this.remindText = str
  113. this.timeoutCount++
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .supplier-list {
  120. height: 100%;
  121. background: #29a9f9;
  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: 6.48rem;
  148. line-height: normal;
  149. }
  150. span {
  151. height: .46rem;
  152. line-height: .46rem;
  153. }
  154. }
  155. }
  156. ul {
  157. margin: .26rem auto 0;
  158. width: 6.91rem;
  159. li {
  160. position: relative;
  161. height: 1.21rem;
  162. background: #fff;
  163. line-height: 1.21rem;
  164. padding-left: .74rem;
  165. font-size: .32rem;
  166. margin-bottom: .14rem;
  167. border-radius: .05rem;
  168. .open {
  169. width: 1.35rem;
  170. position: absolute;
  171. top: -.08rem;
  172. left: -.1rem;
  173. }
  174. .tag {
  175. position: absolute;
  176. right: .35rem;
  177. color: #3f84f6;
  178. }
  179. span {
  180. color: #333;
  181. width: 4.65rem;
  182. overflow: hidden;
  183. text-overflow: ellipsis;
  184. white-space: nowrap;
  185. display: inline-block;
  186. }
  187. }
  188. }
  189. }
  190. </style>