Home.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div class="home">
  3. <div 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" :url="url"></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. url: ''
  107. }
  108. },
  109. components: {
  110. SeekList,
  111. MainSearch,
  112. RemindBox,
  113. LoginBox
  114. },
  115. watch: {
  116. '$store.state.applyPurchase.purchaseManList.purchaseHomeList.data': {
  117. handler: function (val) {
  118. if (this.isChange) {
  119. this.purchaseManListData = []
  120. this.page = 1
  121. this.isChange = false
  122. this.isDataChange = false
  123. } else {
  124. this.purchaseManListData = this.purchaseManListData.concat(val.content)
  125. this.isSearchSearchingMore = false
  126. this.isDataChange = true
  127. }
  128. },
  129. immediate: true
  130. }
  131. // $route: {
  132. // handler: function (val) {
  133. // window.removeEventListener('scroll', this.scroll)
  134. // }
  135. // }
  136. },
  137. computed: {
  138. purchaseManList () {
  139. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.data
  140. },
  141. allPage () {
  142. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  143. }
  144. },
  145. methods: {
  146. scroll: function () {
  147. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  148. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  149. this.getMoreSearch()
  150. }
  151. },
  152. onHomeSearchClick () {
  153. this.showMainSearch = true
  154. this.$store.dispatch('searchData/getSearchHistory')
  155. },
  156. onCancelSearch: function () {
  157. this.showMainSearch = false
  158. },
  159. goOpportunity () {
  160. if (this.user.logged) {
  161. if (this.user.data.enterprise.uu) {
  162. this.$router.push('/mobile/applyPurchase/list/businessOpportunity')
  163. } else if (this.user.data.enterprise.isVendor !== 313) {
  164. this.onRemind('抱歉,您暂未开通卖家中心,可前往PC端开通')
  165. }
  166. } else {
  167. this.url = '/mobile/applyPurchase/list/businessOpportunity'
  168. this.showLoginBox = true
  169. }
  170. },
  171. onRemind: function (str) {
  172. this.remindText = str
  173. this.timeoutCount ++
  174. },
  175. reloadData: function () {
  176. 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'})
  177. },
  178. getMoreSearch: function () {
  179. this.page++
  180. this.isSearchSearchingMore = true
  181. this.reloadData()
  182. }
  183. },
  184. mounted() {
  185. this.$nextTick(() => {
  186. window.addEventListener('scroll', this.scroll, false)
  187. if (this.$route.query.code) {
  188. let ua = window.navigator.userAgent.toLowerCase()
  189. if (ua.match(/micromessenger/i)[0] === 'micromessenger') {
  190. let info = localStorage.getItem('USOFTMALLWECHATINFO')
  191. if (info) {
  192. this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', JSON.parse(info))
  193. }
  194. this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
  195. }
  196. }
  197. })
  198. }
  199. }
  200. </script>
  201. <style lang="scss">
  202. .home {
  203. padding-bottom: 1rem;
  204. background: #f3f3f7;
  205. .header {
  206. height: 3.26rem;
  207. position: relative;
  208. .home-bg {
  209. height: 3.26rem;
  210. width: 100%;
  211. }
  212. .search-content {
  213. position: absolute;
  214. top: 0;
  215. width: 100%;
  216. }
  217. .swiper-container {
  218. height: 3.26rem;
  219. position: absolute;
  220. top: 0;
  221. width: 100%;
  222. z-index: 0;
  223. }
  224. .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets {
  225. bottom: .1rem !important;
  226. }
  227. .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet {
  228. width: .16rem !important;
  229. height: .16rem !important;
  230. margin: 0 .2rem;
  231. }
  232. }
  233. .link-list {
  234. background: #fff;
  235. height: 1.56rem;
  236. margin-bottom: .2rem;
  237. li {
  238. position: relative;
  239. display: inline-block;
  240. width: 25%;
  241. text-align: center;
  242. float: left;
  243. height: 1.56rem;
  244. img {
  245. width: .7rem;
  246. height: .7rem;
  247. margin-top: .2rem;
  248. }
  249. span {
  250. font-size: .26rem;
  251. color: #666;
  252. display: block;
  253. margin-top: .15rem;
  254. }
  255. i {
  256. height: 0.9rem;
  257. width: .01rem;
  258. background: #ddd;
  259. display: block;
  260. position: absolute;
  261. right: 0;
  262. top: .2rem;
  263. }
  264. }
  265. }
  266. }
  267. </style>