List2.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div>
  3. <search-header2 @searchAction="search" :type="'supplier'" :placeholder="'公司名/品牌/物料名称/型号'"></search-header2>
  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 {SearchHeader2} 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. field: null
  38. }
  39. },
  40. components: {
  41. RemindBox,
  42. SearchHeader2
  43. },
  44. mounted: function () {
  45. this.$nextTick(() => {
  46. window.addEventListener('scroll', this.scroll, false)
  47. })
  48. },
  49. watch: {
  50. 'list': {
  51. handler (val, oldVal) {
  52. if (this.isChange) {
  53. this.listData = val.content
  54. this.page = 1
  55. this.isChange = false
  56. this.isDataChange = true
  57. } else {
  58. this.listData = this.listData.concat(val.content)
  59. this.isSearchSearchingMore = false
  60. this.isDataChange = false
  61. }
  62. },
  63. immediate: true
  64. }
  65. },
  66. computed: {
  67. list () {
  68. return this.$store.state.supplier.data.list.data
  69. },
  70. allPage () {
  71. return Math.floor(this.list.totalElements / this.list.size) + Math.floor(this.list.totalElements % this.list.size > 0 ? 1 : 0)
  72. }
  73. },
  74. methods: {
  75. goLastPage: function () {
  76. window.history.back(-1)
  77. },
  78. scroll: function () {
  79. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  80. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  81. this.getMoreSearch()
  82. }
  83. },
  84. getMoreSearch: function () {
  85. this.page++
  86. this.isSearchSearchingMore = true
  87. this.reloadData()
  88. },
  89. reloadData: function () {
  90. this.$store.dispatch('supplier/getSupplierList', {keyword: this.keyword, page: this.page, size: this.size, field: this.field})
  91. },
  92. search: function (searchObj) {
  93. if (searchObj) {
  94. this.keyword = searchObj.keyword
  95. // console.log(searchObj)
  96. this.field = searchObj.type || null
  97. }
  98. this.page = 1
  99. this.isChange = true
  100. this.reloadData()
  101. },
  102. goSupplierDetail: function (item) {
  103. // /mobile/supplier/detail/${item.enUU}?isStore=${item.isStore}
  104. this.$http.get('/vendor/introduction/product/count', {params: {vendUU: item.enUU}})
  105. .then(response => {
  106. if (response.data.success && response.data.count > 0) {
  107. this.$router.push(`/mobile/supplier/detail/${item.enUU}?isStore=${item.isStore}`)
  108. } else {
  109. this.onRemind('供应商正在完善产品信息,暂时不能查看更多。')
  110. }
  111. })
  112. },
  113. onRemind: function(str) {
  114. this.remindText = str
  115. this.timeoutCount++
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .supplier-list {
  122. height: 100%;
  123. background: #29a9f9;
  124. .mobile-header {
  125. position: fixed;
  126. top: 0;
  127. z-index: 10;
  128. width:100%;
  129. height:.88rem;
  130. line-height: .88rem;
  131. background: #3e82f5;
  132. padding:0 .2rem 0 .1rem;
  133. color:#fff;
  134. > a {
  135. font-size:.28rem;
  136. color:#fff;
  137. position: absolute;
  138. i {
  139. font-size: .48rem;
  140. margin-right: -.1rem;
  141. }
  142. }
  143. .search-content {
  144. margin-left: .5rem;
  145. line-height: normal;
  146. padding-top: .14rem;
  147. input {
  148. color: #333;
  149. width: 6.48rem;
  150. line-height: normal;
  151. }
  152. span {
  153. height: .46rem;
  154. line-height: .46rem;
  155. }
  156. }
  157. }
  158. ul {
  159. margin: .26rem auto 0;
  160. width: 6.91rem;
  161. li {
  162. position: relative;
  163. height: 1.21rem;
  164. background: #fff;
  165. line-height: 1.21rem;
  166. padding-left: .74rem;
  167. font-size: .32rem;
  168. margin-bottom: .14rem;
  169. border-radius: .05rem;
  170. .open {
  171. width: 1.35rem;
  172. position: absolute;
  173. top: -.08rem;
  174. left: -.1rem;
  175. }
  176. .tag {
  177. position: absolute;
  178. right: .35rem;
  179. color: #3f84f6;
  180. }
  181. span {
  182. color: #333;
  183. width: 4.65rem;
  184. overflow: hidden;
  185. text-overflow: ellipsis;
  186. white-space: nowrap;
  187. display: inline-block;
  188. }
  189. }
  190. }
  191. }
  192. .com-none-state {
  193. padding: 1.5rem .5rem .5rem .5rem;
  194. }
  195. </style>