Home.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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" @touchmove="preventTouchMove($event)">
  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. <pull-up :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="getMoreSearch" :isValid="isValid"></pull-up>
  73. </div>
  74. </template>
  75. <script>
  76. import SeekList from './applyPurchase/SeekList.vue'
  77. import MainSearch from '~/components/mobile/search/MainSearch.vue'
  78. import { RemindBox, LoginBox, PullUp } from '~components/mobile/common'
  79. export default {
  80. data () {
  81. return {
  82. showStoreInfo: false,
  83. showMainSearch: false,
  84. swiperOption: {
  85. autoplay: 3000,
  86. initialSlide: 0,
  87. pagination: '.swiper-pagination',
  88. // 解决点击分页器后图片就不能轮播的问题
  89. autoplayDisableOnInteraction: false,
  90. paginationClickable: true,
  91. mousewheelControl: false,
  92. effect: 'fade',
  93. lazyLoading: true,
  94. loop: true,
  95. prevButton: '.swiper-button-prev',
  96. nextButton: '.swiper-button-next'
  97. },
  98. remindText: '',
  99. timeoutCount: 0,
  100. showLoginBox: false,
  101. isSearchSearchingMore: false,
  102. page: 1,
  103. size: 5,
  104. purchaseManListData: [],
  105. isChange: false,
  106. isDataChange: false,
  107. url: '',
  108. isValid: true
  109. }
  110. },
  111. components: {
  112. SeekList,
  113. MainSearch,
  114. RemindBox,
  115. LoginBox,
  116. PullUp
  117. },
  118. watch: {
  119. '$store.state.applyPurchase.purchaseManList.purchaseHomeList.data': {
  120. handler: function (val) {
  121. if (this.isChange) {
  122. this.purchaseManListData = []
  123. this.page = 1
  124. this.isChange = false
  125. this.isDataChange = false
  126. } else {
  127. this.purchaseManListData = this.purchaseManListData.concat(val.content)
  128. this.isSearchSearchingMore = false
  129. this.isDataChange = true
  130. }
  131. },
  132. immediate: true
  133. }
  134. // $route: {
  135. // handler: function (val) {
  136. // window.removeEventListener('scroll', this.scroll)
  137. // }
  138. // }
  139. },
  140. computed: {
  141. purchaseManList () {
  142. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.data
  143. },
  144. allPage () {
  145. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  146. },
  147. fetching () {
  148. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.fetching
  149. }
  150. },
  151. methods: {
  152. // scroll: function () {
  153. // let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  154. // if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  155. // this.getMoreSearch()
  156. // }
  157. // },
  158. onHomeSearchClick () {
  159. this.isValid = false
  160. this.showMainSearch = true
  161. this.$store.dispatch('searchData/getSearchHistory')
  162. },
  163. onCancelSearch: function () {
  164. this.isValid = true
  165. this.showMainSearch = false
  166. },
  167. goOpportunity () {
  168. if (this.user.logged) {
  169. if (this.user.data.enterprise.uu) {
  170. this.$router.push('/mobile/applyPurchase/list/businessOpportunity')
  171. } else if (this.user.data.enterprise.isVendor !== 313) {
  172. this.onRemind('抱歉,您暂未开通卖家中心,可前往PC端开通')
  173. }
  174. } else {
  175. this.url = '/mobile/applyPurchase/list/businessOpportunity'
  176. this.showLoginBox = true
  177. }
  178. },
  179. onRemind: function (str) {
  180. this.remindText = str
  181. this.timeoutCount ++
  182. },
  183. reloadData: function () {
  184. 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'})
  185. },
  186. getMoreSearch: function () {
  187. this.page++
  188. this.isSearchSearchingMore = true
  189. this.reloadData()
  190. }
  191. },
  192. mounted() {
  193. this.$nextTick(() => {
  194. // window.addEventListener('scroll', this.scroll, false)
  195. if (this.$route.query.code) {
  196. let ua = window.navigator.userAgent.toLowerCase()
  197. if (ua.match(/micromessenger/i)[0] === 'micromessenger') {
  198. let info = localStorage.getItem('USOFTMALLWECHATINFO')
  199. if (info) {
  200. this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', JSON.parse(info))
  201. }
  202. this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
  203. }
  204. }
  205. })
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. .home {
  211. padding-bottom: 1rem;
  212. background: #f3f3f7;
  213. .header {
  214. height: 3.26rem;
  215. position: relative;
  216. .home-bg {
  217. height: 3.26rem;
  218. width: 100%;
  219. }
  220. .search-content {
  221. position: absolute;
  222. top: 0;
  223. width: 100%;
  224. }
  225. .swiper-container {
  226. height: 3.26rem;
  227. position: absolute;
  228. top: 0;
  229. width: 100%;
  230. z-index: 0;
  231. }
  232. .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets {
  233. bottom: .1rem !important;
  234. }
  235. .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet {
  236. width: .16rem !important;
  237. height: .16rem !important;
  238. margin: 0 .2rem;
  239. }
  240. }
  241. .link-list {
  242. background: #fff;
  243. height: 1.56rem;
  244. margin-bottom: .2rem;
  245. li {
  246. position: relative;
  247. display: inline-block;
  248. width: 25%;
  249. text-align: center;
  250. float: left;
  251. height: 1.56rem;
  252. img {
  253. width: .7rem;
  254. height: .7rem;
  255. margin-top: .2rem;
  256. }
  257. span {
  258. font-size: .26rem;
  259. color: #666;
  260. display: block;
  261. margin-top: .15rem;
  262. }
  263. i {
  264. height: 0.9rem;
  265. width: .01rem;
  266. background: #ddd;
  267. display: block;
  268. position: absolute;
  269. right: 0;
  270. top: .2rem;
  271. }
  272. }
  273. }
  274. }
  275. </style>