Home.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div>
  3. <scroll :data="purchaseManListData" class="home" :pullup="true" @scrollToEnd="scrollToEnd">
  4. <div v-if="!showMainSearch">
  5. <div class="header">
  6. <div v-swiper:mySwiper="swiperOption">
  7. <div class="swiper-wrapper">
  8. <div class="swiper-slide">
  9. <img class="home-bg" src="/images/mobile/@2x/applyPurchase/home/app-banner_01.jpg" alt="">
  10. </div>
  11. <div class="swiper-slide">
  12. <img class="home-bg" src="/images/mobile/@2x/applyPurchase/home/app-banner_02.jpg" alt="">
  13. </div>
  14. </div>
  15. <div class="swiper-pagination swiper-pagination-bullets"></div>
  16. </div>
  17. <div class="search-content">
  18. <input type="text" placeholder="请输入您要查找的型号、品牌或店铺" @click="onHomeSearchClick()">
  19. <span>
  20. <i class="iconfont icon-sousuo"></i>
  21. </span>
  22. <img src="/images/mobile/@2x/applyPurchase/home/phone.png" alt="" @click="showStoreInfo = true">
  23. </div>
  24. </div>
  25. <ul class="link-list">
  26. <li>
  27. <nuxt-link to="/mobile/supplier">
  28. <img src="/images/mobile/@2x/home/supplier.png" alt="">
  29. <span>供应商</span>
  30. </nuxt-link>
  31. </li>
  32. <li>
  33. <a @click="goOpportunity">
  34. <img src="/images/mobile/@2x/home/seek.png" alt="">
  35. <span>我的商机</span>
  36. </a>
  37. </li>
  38. <li>
  39. <nuxt-link to="/mobile/shop">
  40. <img src="/images/mobile/@2x/home/store.png" alt="">
  41. <span>店铺列表</span>
  42. <!-- <i></i>-->
  43. </nuxt-link>
  44. </li>
  45. <li>
  46. <nuxt-link to="/mobile/brand/brandCenter/A">
  47. <img src="/images/mobile/@2x/home/brand.png" alt="">
  48. <span>品牌墙</span>
  49. </nuxt-link>
  50. </li>
  51. </ul>
  52. <div class="seek-title">
  53. <img src="/images/mobile/@2x/applyPurchase/home/seek-title.png" alt="">
  54. <span>最新求购信息</span>
  55. <nuxt-link to="/mobile/applyPurchase/list">查看更多 <img src="/images/mobile/@2x/applyPurchase/home/arrow-right.png" alt=""></nuxt-link>
  56. </div>
  57. <seek-list :purchaseManList="purchaseManListData" :isDataChange="isDataChange"></seek-list>
  58. <Loading v-show="this.page < this.allPage"></Loading>
  59. </div>
  60. </scroll>
  61. <div class="mobile-modal" v-if="showStoreInfo">
  62. <div class="mobile-modal-box">
  63. <div class="mobile-modal-header">联系方式<i @click="showStoreInfo = false" class="icon-guanbi iconfont"></i></div>
  64. <div class="mobile-modal-content">
  65. <div>商家地址:深圳市南山区英唐大厦1楼</div>
  66. <!-- <div class="content-line link-url">在线咨询</div>-->
  67. <div>致电:<a href="tel:4008301818" target="_blank" class="content-line link-url">4008301818</a></div>
  68. <div>邮件:<a href="mailto:yrsc@usoftchina.com" target="_blank" class="content-line link-url">yrsc@usoftchina.com</a></div>
  69. </div>
  70. </div>
  71. </div>
  72. <main-search v-if="showMainSearch" @cancelSearchAction="onCancelSearch"></main-search>
  73. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  74. <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox"></login-box>
  75. </div>
  76. </template>
  77. <script>
  78. import SeekList from './applyPurchase/SeekList.vue'
  79. import MainSearch from '~/components/mobile/search/MainSearch.vue'
  80. import { RemindBox, LoginBox, Loading } from '~components/mobile/common'
  81. import Scroll from '~components/common/scroll/scroll'
  82. export default {
  83. data () {
  84. return {
  85. showStoreInfo: false,
  86. showMainSearch: false,
  87. swiperOption: {
  88. autoplay: 3000,
  89. initialSlide: 0,
  90. pagination: '.swiper-pagination',
  91. // 解决点击分页器后图片就不能轮播的问题
  92. autoplayDisableOnInteraction: false,
  93. paginationClickable: true,
  94. mousewheelControl: false,
  95. effect: 'fade',
  96. lazyLoading: true,
  97. loop: true,
  98. prevButton: '.swiper-button-prev',
  99. nextButton: '.swiper-button-next'
  100. },
  101. remindText: '',
  102. timeoutCount: 0,
  103. showLoginBox: false,
  104. isSearchSearchingMore: false,
  105. page: 1,
  106. size: 5,
  107. purchaseManListData: [],
  108. isChange: false,
  109. isDataChange: false
  110. }
  111. },
  112. components: {
  113. SeekList,
  114. MainSearch,
  115. RemindBox,
  116. LoginBox,
  117. Scroll,
  118. Loading
  119. },
  120. mounted: function () {
  121. this.$nextTick(() => {
  122. window.addEventListener('scroll', this.scroll, false)
  123. })
  124. },
  125. watch: {
  126. '$store.state.applyPurchase.purchaseManList.purchaseHomeList.data': {
  127. handler: function (val) {
  128. if (this.isChange) {
  129. this.purchaseManListData = []
  130. this.page = 1
  131. this.isChange = false
  132. this.isDataChange = false
  133. } else {
  134. this.purchaseManListData = this.purchaseManListData.concat(val.content)
  135. this.isSearchSearchingMore = false
  136. this.isDataChange = true
  137. }
  138. },
  139. immediate: true
  140. }
  141. // $route: {
  142. // handler: function (val) {
  143. // window.removeEventListener('scroll', this.scroll)
  144. // }
  145. // }
  146. },
  147. computed: {
  148. purchaseManList () {
  149. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.data
  150. },
  151. allPage () {
  152. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  153. }
  154. },
  155. methods: {
  156. scrollToEnd() {
  157. this.getMoreSearch()
  158. },
  159. scroll: function () {
  160. // let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  161. // if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  162. // this.getMoreSearch()
  163. // }
  164. },
  165. onHomeSearchClick () {
  166. this.showMainSearch = true
  167. this.$store.dispatch('searchData/getSearchHistory')
  168. },
  169. onCancelSearch: function () {
  170. this.showMainSearch = false
  171. },
  172. goOpportunity () {
  173. if (this.user.logged) {
  174. if (this.user.data.enterprise.uu) {
  175. this.$router.push('/mobile/applyPurchase/list/businessOpportunity')
  176. } else if (this.user.data.enterprise.isVendor !== 313) {
  177. this.onRemind('抱歉,您暂未开通卖家中心,可前往PC端开通')
  178. }
  179. } else {
  180. this.showLoginBox = true
  181. }
  182. },
  183. onRemind: function (str) {
  184. this.remindText = str
  185. this.timeoutCount ++
  186. },
  187. reloadData: function () {
  188. this.$store.dispatch('applyPurchase/loadMobileHomeList', {pageNumber: this.page, pageSize: this.size, sorting: {'releaseDate': 'DESC'}, enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null, isLogin: this.user.logged ? '1' : '0'})
  189. },
  190. getMoreSearch: function () {
  191. this.page++
  192. this.isSearchSearchingMore = true
  193. this.reloadData()
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss">
  199. .home {
  200. /*padding-bottom: 1rem;*/
  201. background: #f3f3f7;
  202. position: absolute;
  203. bottom: 1rem;
  204. width: 100%;
  205. left: 0;
  206. right: 0;
  207. top: 0;
  208. overflow: hidden;
  209. .header {
  210. height: 3.26rem;
  211. position: relative;
  212. .home-bg {
  213. height: 3.26rem;
  214. width: 100%;
  215. }
  216. .search-content {
  217. position: absolute;
  218. top: 0;
  219. width: 100%;
  220. }
  221. .swiper-container {
  222. height: 3.26rem;
  223. position: absolute;
  224. top: 0;
  225. width: 100%;
  226. z-index: 0;
  227. }
  228. .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets {
  229. bottom: .1rem !important;
  230. }
  231. .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet {
  232. width: .16rem !important;
  233. height: .16rem !important;
  234. margin: 0 .2rem;
  235. }
  236. }
  237. .link-list {
  238. background: #fff;
  239. height: 1.56rem;
  240. margin-bottom: .2rem;
  241. li {
  242. position: relative;
  243. display: inline-block;
  244. width: 25%;
  245. text-align: center;
  246. float: left;
  247. height: 1.56rem;
  248. img {
  249. width: .7rem;
  250. height: .7rem;
  251. margin-top: .2rem;
  252. }
  253. span {
  254. font-size: .26rem;
  255. color: #666;
  256. display: block;
  257. margin-top: .15rem;
  258. }
  259. i {
  260. height: 0.9rem;
  261. width: .01rem;
  262. background: #ddd;
  263. display: block;
  264. position: absolute;
  265. right: 0;
  266. top: .2rem;
  267. }
  268. }
  269. }
  270. }
  271. </style>