Home.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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="display_card">
  52. <statistics-mobile/>
  53. </div>
  54. <div class="seek-title">
  55. <img src="/images/mobile/@2x/applyPurchase/home/seek-title.png" alt="">
  56. <span>最新求购信息</span>
  57. <nuxt-link to="/mobile/applyPurchase/list">查看更多 <img src="/images/mobile/@2x/applyPurchase/home/arrow-right.png" alt=""></nuxt-link>
  58. </div>
  59. <seek-list :purchaseManList="purchaseManListData" :isDataChange="isDataChange"></seek-list>
  60. </div>
  61. <div class="mobile-modal" v-if="showStoreInfo" @touchmove="preventTouchMove($event)">
  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" :url="url"></login-box>
  75. <pull-up :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="getMoreSearch" :isValid="isValid"></pull-up>
  76. </div>
  77. </template>
  78. <script>
  79. import SeekList from './applyPurchase/SeekList.vue'
  80. import MainSearch from '~/components/mobile/search/MainSearch.vue'
  81. import { RemindBox, LoginBox, PullUp, StatisticsMobile } from '~components/mobile/common'
  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. url: '',
  111. isValid: true
  112. }
  113. },
  114. components: {
  115. SeekList,
  116. MainSearch,
  117. RemindBox,
  118. LoginBox,
  119. PullUp,
  120. StatisticsMobile
  121. },
  122. watch: {
  123. '$store.state.applyPurchase.purchaseManList.purchaseHomeList.data': {
  124. handler: function (val) {
  125. if (this.isChange) {
  126. this.purchaseManListData = []
  127. this.page = 1
  128. this.isChange = false
  129. this.isDataChange = false
  130. } else {
  131. this.purchaseManListData = this.purchaseManListData.concat(val.content)
  132. this.isSearchSearchingMore = false
  133. this.isDataChange = true
  134. }
  135. },
  136. immediate: true
  137. }
  138. // $route: {
  139. // handler: function (val) {
  140. // window.removeEventListener('scroll', this.scroll)
  141. // }
  142. // }
  143. },
  144. computed: {
  145. purchaseManList () {
  146. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.data
  147. },
  148. allPage () {
  149. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  150. },
  151. fetching () {
  152. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.fetching
  153. }
  154. },
  155. methods: {
  156. // scroll: function () {
  157. // let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  158. // if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  159. // this.getMoreSearch()
  160. // }
  161. // },
  162. onHomeSearchClick () {
  163. this.isValid = false
  164. this.showMainSearch = true
  165. this.$store.dispatch('searchData/getSearchHistory')
  166. },
  167. onCancelSearch: function () {
  168. this.isValid = true
  169. this.showMainSearch = false
  170. },
  171. goOpportunity () {
  172. if (this.user.logged) {
  173. if (this.user.data.enterprise.uu) {
  174. this.$router.push('/mobile/applyPurchase/list/businessOpportunity')
  175. } else if (this.user.data.enterprise.isVendor !== 313) {
  176. this.onRemind('抱歉,您暂未开通卖家中心,可前往PC端开通')
  177. }
  178. } else {
  179. this.url = '/mobile/applyPurchase/list/businessOpportunity'
  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. mounted() {
  197. this.$nextTick(() => {
  198. // window.addEventListener('scroll', this.scroll, false)
  199. if (this.$route.query.code) {
  200. let ua = window.navigator.userAgent.toLowerCase()
  201. if (ua.match(/micromessenger/i)[0] === 'micromessenger') {
  202. let info = localStorage.getItem('USOFTMALLWECHATINFO')
  203. if (info) {
  204. this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', JSON.parse(info))
  205. } else {
  206. this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
  207. }
  208. }
  209. }
  210. })
  211. }
  212. }
  213. </script>
  214. <style lang="scss">
  215. .home {
  216. padding-bottom: 1rem;
  217. background: #f3f3f7;
  218. .header {
  219. height: 3.26rem;
  220. position: relative;
  221. .home-bg {
  222. height: 3.26rem;
  223. width: 100%;
  224. }
  225. .search-content {
  226. position: absolute;
  227. top: 0;
  228. width: 100%;
  229. }
  230. .swiper-container {
  231. height: 3.26rem;
  232. position: absolute;
  233. top: 0;
  234. width: 100%;
  235. z-index: 0;
  236. }
  237. .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets {
  238. bottom: .1rem !important;
  239. }
  240. .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet {
  241. width: .16rem !important;
  242. height: .16rem !important;
  243. margin: 0 .2rem;
  244. }
  245. }
  246. .link-list {
  247. background: #fff;
  248. height: 1.56rem;
  249. margin-bottom: .2rem;
  250. li {
  251. position: relative;
  252. display: inline-block;
  253. width: 25%;
  254. text-align: center;
  255. float: left;
  256. height: 1.56rem;
  257. img {
  258. width: .7rem;
  259. height: .7rem;
  260. margin-top: .2rem;
  261. }
  262. span {
  263. font-size: .26rem;
  264. color: #666;
  265. display: block;
  266. margin-top: .15rem;
  267. }
  268. i {
  269. height: 0.9rem;
  270. width: .01rem;
  271. background: #ddd;
  272. display: block;
  273. position: absolute;
  274. right: 0;
  275. top: .2rem;
  276. }
  277. }
  278. }
  279. }
  280. </style>