Home.vue 10 KB

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