Home.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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 (val.length === 0) {
  126. // console.log(111)
  127. this.$store.dispatch('applyPurchase/loadMobileHomeList', {
  128. pageNumber: 1,
  129. pageSize: 5,
  130. enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null
  131. })
  132. } else if (this.isChange) {
  133. this.purchaseManListData = []
  134. this.page = 1
  135. this.isChange = false
  136. this.isDataChange = false
  137. } else {
  138. // console.log(val.content)
  139. this.purchaseManListData = this.purchaseManListData.concat(val.content)
  140. this.isSearchSearchingMore = false
  141. this.isDataChange = true
  142. }
  143. },
  144. immediate: true
  145. }
  146. // $route: {
  147. // handler: function (val) {
  148. // window.removeEventListener('scroll', this.scroll)
  149. // }
  150. // }
  151. },
  152. computed: {
  153. purchaseManList () {
  154. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.data
  155. },
  156. allPage () {
  157. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  158. },
  159. fetching () {
  160. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.fetching
  161. }
  162. },
  163. methods: {
  164. // scroll: function () {
  165. // let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  166. // if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  167. // this.getMoreSearch()
  168. // }
  169. // },
  170. onHomeSearchClick () {
  171. this.isValid = false
  172. this.showMainSearch = true
  173. this.$store.dispatch('searchData/getSearchHistory')
  174. },
  175. onCancelSearch: function () {
  176. this.isValid = true
  177. this.showMainSearch = false
  178. },
  179. goOpportunity () {
  180. if (this.user.logged) {
  181. if (this.user.data.enterprise.uu) {
  182. this.$router.push('/mobile/applyPurchase/list/businessOpportunity')
  183. } else if (this.user.data.enterprise.isVendor !== 313) {
  184. this.onRemind('抱歉,您暂未开通卖家中心,可前往PC端开通')
  185. }
  186. } else {
  187. this.url = '/mobile/applyPurchase/list/businessOpportunity'
  188. this.showLoginBox = true
  189. }
  190. },
  191. onRemind: function (str) {
  192. this.remindText = str
  193. this.timeoutCount ++
  194. },
  195. reloadData: function () {
  196. 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'})
  197. },
  198. getMoreSearch: function () {
  199. this.page++
  200. this.isSearchSearchingMore = true
  201. this.reloadData()
  202. }
  203. },
  204. mounted() {
  205. this.$nextTick(() => {
  206. let ua = this.$store.state.option.userAgent.toLowerCase()
  207. let info = localStorage.getItem('USOFTMALLWECHATINFO')
  208. // 如果本地有缓存 则证明存在openid
  209. if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger' && !this.$route.query.code && !info) {
  210. 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`
  211. // window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd29bbca61728b189&redirect_uri=http://gwzcfb.natappfree.cc&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  212. } else if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger') {
  213. if (info) {
  214. this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', JSON.parse(info))
  215. } else {
  216. this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
  217. }
  218. }
  219. })
  220. }
  221. }
  222. </script>
  223. <style lang="scss">
  224. @import '~assets/scss/mobileCommon';
  225. .home {
  226. padding-bottom: 1rem;
  227. background: #f3f3f7;
  228. .header {
  229. height: 3.26rem;
  230. position: relative;
  231. .home-bg {
  232. height: 3.26rem;
  233. width: 100%;
  234. }
  235. .search-content {
  236. position: absolute;
  237. top: 0;
  238. width: 100%;
  239. }
  240. .swiper-container {
  241. height: 3.26rem;
  242. position: absolute;
  243. top: 0;
  244. width: 100%;
  245. z-index: 0;
  246. }
  247. .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets {
  248. bottom: .1rem !important;
  249. }
  250. .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet {
  251. width: .16rem !important;
  252. height: .16rem !important;
  253. margin: 0 .2rem;
  254. }
  255. }
  256. .link-list {
  257. background: #fff;
  258. height: 1.56rem;
  259. margin-bottom: .2rem;
  260. li {
  261. position: relative;
  262. display: inline-block;
  263. width: 25%;
  264. text-align: center;
  265. float: left;
  266. height: 1.56rem;
  267. img {
  268. width: .7rem;
  269. height: .7rem;
  270. margin-top: .2rem;
  271. }
  272. span {
  273. font-size: .26rem;
  274. color: #666;
  275. display: block;
  276. margin-top: .15rem;
  277. }
  278. i {
  279. height: 0.9rem;
  280. width: .01rem;
  281. background: #ddd;
  282. display: block;
  283. position: absolute;
  284. right: 0;
  285. top: .2rem;
  286. }
  287. }
  288. }
  289. }
  290. </style>