Home.vue 8.4 KB

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