List.vue 5.7 KB

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