Home.vue 10 KB

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