Home.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. <template>
  2. <div class="home">
  3. <div v-if="!showMainSearch">
  4. <ul class="associate-list" v-show="associate.show" @click="associate.show = false">
  5. <li @click.stop="onAssociateClick(similar)" v-for="similar in similarKeywords.result">
  6. <i class="icon-sousuo iconfont"></i>
  7. <span>{{Getsimilar(similar)}}</span>
  8. <!--<span v-if="ChooseTop === 'component'">{{similar.code}}</span>-->
  9. <!--<span v-else-if="ChooseTop === 'product'">{{similar}}</span>-->
  10. <!--<span v-else-if="ChooseTop === 'store'">{{similar}}</span>-->
  11. <!--<span v-else-if="ChooseTop === 'brand'">{{similar.nameEn}}</span>-->
  12. </li>
  13. <li @click.stop="onSearch(keyword)">查找“{{baseUtils.filterStringEllipsis(keyword, 30)}}”</li>
  14. </ul>
  15. <div class="header">
  16. <div class="search-content" @touchmove="preventTouchMove($event)">
  17. <div class="main-search-header-controll clearfix">
  18. <div style="display: flex;align-items: center;justify-content: space-between;width:100%;">
  19. <div :class="ChooseTop === 'component' ? 'active' : ''" @click="setChangelistHander('component')"><a>型号</a></div>
  20. <div :class="ChooseTop === 'kind' ? 'active' : ''" @click="setChangelistHander('kind')"><a>物料名称</a></div>
  21. <div :class="ChooseTop === 'store' ? 'active' : ''" @click="setChangelistHander('store')"><a>卖家</a></div>
  22. <div :class="ChooseTop === 'brand' ? 'active' : ''" @click="setChangelistHander('brand')"><a>品牌</a></div>
  23. </div>
  24. </div>
  25. <input type="text" v-model="keyword" id="search-box" @keyup.13="onSearch()" :placeholder="placeholder">
  26. <span @click="onSearch()" style="top: 0">
  27. <i class="iconfont icon-sousuo"></i>
  28. </span>
  29. <img src="/images/mobile/@2x/applyPurchase/home/phone.png" alt="" @click="showStoreInfo = true">
  30. </div>
  31. <div v-swiper:mySwiper="swiperOption">
  32. <div class="swiper-wrapper">
  33. <div class="swiper-slide">
  34. <img class="home-bg" src="/images/mobile/@2x/applyPurchase/home/app-banner_01.jpg" alt="">
  35. </div>
  36. <div class="swiper-slide">
  37. <img class="home-bg" src="/images/mobile/@2x/applyPurchase/home/app-banner_02.jpg" alt="">
  38. </div>
  39. <!--<div class="swiper-slide">-->
  40. <!--<img class="home-bg" src="/images/mobile/@2x/applyPurchase/home/app-banner_03.png" alt="">-->
  41. <!--</div>-->
  42. </div>
  43. <div class="swiper-pagination swiper-pagination-bullets"></div>
  44. </div>
  45. </div>
  46. <ul class="link-list">
  47. <li v-bind:class="{'widthActive' : isShowStoreApply}">
  48. <nuxt-link to="/mobile/supplier">
  49. <img src="/images/mobile/@2x/home/supplier.png" alt="">
  50. <span>供应商</span>
  51. </nuxt-link>
  52. </li>
  53. <li v-bind:class="{'widthActive' : isShowStoreApply}">
  54. <a @click="goOpportunity">
  55. <img src="/images/mobile/@2x/home/seek.png" alt="">
  56. <span>公司商机</span>
  57. </a>
  58. </li>
  59. <li v-bind:class="{'widthActive' : isShowStoreApply}">
  60. <nuxt-link to="/mobile/shop">
  61. <img src="/images/mobile/@2x/home/store.png" alt="">
  62. <span>店铺列表</span>
  63. <!-- <i></i>-->
  64. </nuxt-link>
  65. </li>
  66. <li v-bind:class="{'widthActive' : isShowStoreApply}">
  67. <nuxt-link to="/mobile/brand/brandCenter/A">
  68. <img src="/images/mobile/@2x/home/brand.png" alt="">
  69. <span>品牌墙</span>
  70. </nuxt-link>
  71. </li>
  72. <li v-bind:class="{'widthActive' : isShowStoreApply}" v-show="isShowStoreApply">
  73. <a @click="goOpenStoreApply">
  74. <img src="/images/mobile/@2x/home/store-into.png" alt="">
  75. <span>商家入驻</span>
  76. </a>
  77. </li>
  78. </ul>
  79. <div class="display_card">
  80. <statistics-mobile/>
  81. </div>
  82. <div class="seek-title">
  83. <img src="/images/mobile/@2x/applyPurchase/home/seek-title.png" alt="">
  84. <span>最新求购信息</span>
  85. <nuxt-link to="/mobile/applyPurchase/list">查看更多 <img src="/images/mobile/@2x/applyPurchase/home/arrow-right.png" alt=""></nuxt-link>
  86. </div>
  87. <seek-list :purchaseManList="purchaseManListData" :isDataChange="isDataChange"></seek-list>
  88. </div>
  89. <div class="mobile-modal" v-if="showStoreInfo" @touchmove="preventTouchMove($event)">
  90. <div class="mobile-modal-box">
  91. <div class="mobile-modal-header">联系方式<i @click="showStoreInfo = false" class="icon-guanbi iconfont"></i></div>
  92. <div class="mobile-modal-content">
  93. <div>商家地址:深圳市南山区英唐大厦1楼</div>
  94. <!-- <div class="content-line link-url">在线咨询</div>-->
  95. <div>致电:<a href="tel:4008301818" target="_blank" class="content-line">4008301818</a></div>
  96. <div>邮件:<a href="mailto:yrsc@usoftchina.com" target="_blank" class="content-line">yrsc@usoftchina.com</a></div>
  97. </div>
  98. </div>
  99. </div>
  100. <main-search v-if="showMainSearch" @cancelSearchAction="onCancelSearch"></main-search>
  101. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  102. <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox" :url="url"></login-box>
  103. <pull-up :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="getMoreSearch" :isValid="isValid"></pull-up>
  104. </div>
  105. </template>
  106. <script>
  107. import SeekList from './applyPurchase/SeekList.vue'
  108. import MainSearch from '~/components/mobile/search/MainSearch.vue'
  109. import { RemindBox, LoginBox, PullUp, StatisticsMobile } from '~components/mobile/common'
  110. export default {
  111. data () {
  112. return {
  113. showStoreInfo: false,
  114. showMainSearch: false,
  115. swiperOption: {
  116. autoplay: 3000,
  117. initialSlide: 0,
  118. pagination: '.swiper-pagination',
  119. // 解决点击分页器后图片就不能轮播的问题
  120. autoplayDisableOnInteraction: false,
  121. paginationClickable: true,
  122. mousewheelControl: false,
  123. effect: 'fade',
  124. lazyLoading: true,
  125. loop: true,
  126. prevButton: '.swiper-button-prev',
  127. nextButton: '.swiper-button-next'
  128. },
  129. remindText: '',
  130. timeoutCount: 0,
  131. showLoginBox: false,
  132. isSearchSearchingMore: false,
  133. page: 1,
  134. size: 5,
  135. purchaseManListData: [],
  136. isChange: false,
  137. isDataChange: false,
  138. url: '',
  139. isValid: true,
  140. ChooseTop: 'component',
  141. keyword: '',
  142. associate: {
  143. show: false
  144. },
  145. isShowStoreApply: false
  146. }
  147. },
  148. components: {
  149. SeekList,
  150. MainSearch,
  151. RemindBox,
  152. LoginBox,
  153. PullUp,
  154. StatisticsMobile
  155. },
  156. watch: {
  157. '$store.state.applyPurchase.purchaseManList.purchaseHomeList.data': {
  158. handler: function (val) {
  159. if (val.length === 0) {
  160. // console.log(111)
  161. this.$store.dispatch('applyPurchase/loadMobileHomeList', {
  162. pageNumber: 1,
  163. pageSize: 5,
  164. enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null
  165. })
  166. } else if (this.isChange) {
  167. this.purchaseManListData = []
  168. this.page = 1
  169. this.isChange = false
  170. this.isDataChange = false
  171. } else {
  172. // console.log(val.content)
  173. this.purchaseManListData = this.purchaseManListData.concat(val.content)
  174. this.isSearchSearchingMore = false
  175. this.isDataChange = true
  176. }
  177. },
  178. immediate: true
  179. },
  180. 'keyword': function (val, oldVal) {
  181. let keywords = this.similarKeywords.data
  182. if (!keywords || !keywords.length) {
  183. this.onChange()
  184. }
  185. }
  186. // $route: {
  187. // handler: function (val) {
  188. // window.removeEventListener('scroll', this.scroll)
  189. // }
  190. // }
  191. },
  192. computed: {
  193. similarKeywords () {
  194. return this.$store.state.search.keywords.data
  195. },
  196. placeholder() {
  197. if (this.ChooseTop === 'component') {
  198. return '请输入您要搜索的型号'
  199. } else if (this.ChooseTop === 'kind') {
  200. return '请输入您要搜索的物料名称'
  201. } else if (this.ChooseTop === 'store') {
  202. return '请输入您要搜索的卖家名称'
  203. } else if (this.ChooseTop === 'brand') {
  204. return '请输入您要搜索的品牌'
  205. }
  206. },
  207. purchaseManList () {
  208. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.data
  209. },
  210. allPage () {
  211. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  212. },
  213. fetching () {
  214. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.fetching
  215. }
  216. },
  217. methods: {
  218. onSearch (item) {
  219. if (item) {
  220. this.keyword = item
  221. }
  222. if (this.keyword) {
  223. this.$router.push(`/mobile/search/newkeycode?choosetype=${this.ChooseTop}&keyword=${encodeURIComponent(this.keyword)}`)
  224. }
  225. },
  226. onChange () {
  227. if (!this.keyword) {
  228. this.associate.show = false
  229. this.$store.dispatch('resetSearchKeywords')
  230. } else {
  231. this.searchKeywords()
  232. }
  233. if (this.click_flag) {
  234. this.associate.show = false
  235. }
  236. },
  237. setChangelistHander(str) {
  238. this.ChooseTop = str
  239. if (!this.keyword) return
  240. this.$store.dispatch('searchKeywords', {keyword: this.keyword, type: this.ChooseTop})
  241. this.associate.show = true
  242. },
  243. searchKeywords () {
  244. this.$store.dispatch('searchKeywords', {keyword: this.keyword, type: this.ChooseTop})
  245. this.associate.show = true
  246. },
  247. onAssociateClick (word) {
  248. if (this.ChooseTop === 'component') {
  249. this.keyword = word.code
  250. } else if (this.ChooseTop === 'kind') {
  251. this.keyword = word.nameCn
  252. } else if (this.ChooseTop === 'store') {
  253. this.keyword = word.name
  254. } else if (this.ChooseTop === 'brand') {
  255. this.keyword = word.nameEn
  256. }
  257. this.onSearch()
  258. },
  259. Getsimilar(word) {
  260. if (this.ChooseTop === 'component') {
  261. return word.code
  262. } else if (this.ChooseTop === 'kind') {
  263. return word.nameCn
  264. } else if (this.ChooseTop === 'store') {
  265. return word.name
  266. } else if (this.ChooseTop === 'brand') {
  267. return word.nameEn
  268. }
  269. },
  270. // scroll: function () {
  271. // let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  272. // if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  273. // this.getMoreSearch()
  274. // }
  275. // },
  276. onHomeSearchClick () {
  277. this.isValid = false
  278. this.showMainSearch = true
  279. this.$store.dispatch('searchData/getSearchHistory')
  280. },
  281. onCancelSearch: function () {
  282. this.isValid = true
  283. this.showMainSearch = false
  284. },
  285. goOpportunity () {
  286. if (this.user.logged) {
  287. if (this.user.data.enterprise.uu) {
  288. this.$router.push('/mobile/center/vendor/seek?seekType=wait')
  289. } else if (this.user.data.enterprise.isVendor !== 313) {
  290. this.onRemind('抱歉,您暂未开通卖家中心,可前往PC端开通')
  291. }
  292. } else {
  293. this.url = '/mobile/center/vendor/seek?seekType=wait'
  294. this.showLoginBox = true
  295. }
  296. },
  297. onRemind: function (str) {
  298. this.remindText = str
  299. this.timeoutCount ++
  300. },
  301. reloadData: function () {
  302. 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'})
  303. },
  304. getMoreSearch: function () {
  305. this.page++
  306. this.isSearchSearchingMore = true
  307. this.reloadData()
  308. },
  309. // 商家入驻
  310. goOpenStoreApply: function () {
  311. if (this.user.logged) {
  312. if (this.user.data.enterprise.uu) {
  313. if (this.user.data.enterprise.isVendor === 313) {
  314. this.$http.get('/basic/vendor/transactionInfo').then(response => {
  315. if (response.data.isOpenStore) {
  316. // window.location.href = '/mobile/user/storeinfo'
  317. } else {
  318. this.setRemindText('您的申请已提交,请耐心等待工作人员审核(2-3个工作日)')
  319. }
  320. }, err => {
  321. this.$message.error('获取开店信息失败')
  322. console.log(err)
  323. })
  324. } else {
  325. this.$router.push('/mobile/store')
  326. }
  327. } else {
  328. this.$router.push('/mobile/store/register')
  329. }
  330. } else {
  331. this.login()
  332. }
  333. },
  334. storeApply: function () {
  335. if (this.user.logged) {
  336. if (this.user.data.enterprise.uu) {
  337. if (this.user.data.enterprise.isVendor === 313) {
  338. this.$http.get('/basic/vendor/transactionInfo').then(response => {
  339. if (response.data.isOpenStore) {
  340. this.isShowStoreApply = false
  341. } else {
  342. this.isShowStoreApply = true
  343. }
  344. }, err => {
  345. this.$message.error('获取开店信息失败')
  346. console.log(err)
  347. })
  348. } else {
  349. this.isShowStoreApply = true
  350. }
  351. } else {
  352. this.isShowStoreApply = true
  353. }
  354. } else {
  355. this.isShowStoreApply = false
  356. }
  357. }
  358. },
  359. mounted() {
  360. this.$nextTick(() => {
  361. this.storeApply()
  362. let ua = this.$store.state.option.userAgent.toLowerCase()
  363. let info = localStorage.getItem('USOFTMALLWECHATINFO')
  364. // 如果本地有缓存 则证明存在openid
  365. info = info && JSON.parse(info)
  366. if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger' && !this.$route.query.code && !info) {
  367. 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`
  368. } else if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger') {
  369. if (!info) {
  370. this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
  371. }
  372. }
  373. })
  374. }
  375. }
  376. </script>
  377. <style lang="scss">
  378. @mixin overFlowHidden {
  379. overflow: hidden;
  380. text-overflow: ellipsis;
  381. white-space: nowrap;
  382. }
  383. @mixin lineHeight($value) {
  384. height: $value;
  385. line-height: $value;
  386. }
  387. @import '~assets/scss/mobileCommon';
  388. .swiper-slide1 {
  389. background: url('/images/mobile/@2x/applyPurchase/home/app-banner_01.jpg');
  390. background-repeat: no-repeat;
  391. background-size: cover;
  392. }
  393. .home {
  394. padding-bottom: 1rem;
  395. background: #f3f3f7;
  396. .search-content {
  397. padding: 0.19rem 0 0.15rem;
  398. position: absolute;
  399. z-index: 10;
  400. width: 100%;
  401. input {
  402. margin-top: -0.02rem;
  403. outline: 0;
  404. border: 0;
  405. }
  406. }
  407. .main-search-header-controll {
  408. width: 5.48rem;
  409. margin-left: 0.21rem;
  410. transform: translateY(1px);
  411. div {
  412. div {
  413. font-size: 0.28rem;
  414. color: #fff;
  415. margin: 0;
  416. border-radius: 0;
  417. padding: 0.1rem 0.1rem;
  418. a {
  419. font-size: .26rem;
  420. color: #f1f1f1;
  421. }
  422. &.active {
  423. background: #fff;
  424. border-top-left-radius: 0.05rem;
  425. border-top-right-radius: 0.05rem;
  426. }
  427. &.active a {
  428. color: #2d8cf0;
  429. }
  430. }
  431. }
  432. }
  433. .associate-list {
  434. position: absolute;
  435. width: 100%;
  436. background: #fff;
  437. top: 1.29rem;
  438. border: 1px solid #dcdcdc;
  439. z-index: 100;
  440. height: 100%;
  441. left: 0;
  442. bottom: 0;
  443. right: 0;
  444. overflow-y: auto;
  445. li {
  446. height: 0.7rem;
  447. line-height: .9rem;
  448. margin: 0 .45rem;
  449. border-bottom: .04rem solid #f1f0f0;
  450. @include overFlowHidden();
  451. i {
  452. font-size: .36rem;
  453. margin-right: .24rem;
  454. color: #ddd;
  455. }
  456. span {
  457. color: #999;
  458. font-size: .28rem;
  459. line-height: .58rem;
  460. height: .58rem;
  461. display: inline-block;
  462. }
  463. &:active, &:hover {
  464. background: #eee;
  465. }
  466. &:last-child {
  467. text-align: center;
  468. font-size: .3rem;
  469. color: #3976f4;
  470. border-bottom: none;
  471. &:active, &:hover {
  472. background: #fff;
  473. }
  474. }
  475. }
  476. }
  477. .header {
  478. position: relative;
  479. height: 4.08rem;
  480. overflow: hidden;
  481. .swiper-container {
  482. width: 100%;
  483. z-index: 0;
  484. height: 4.08rem;
  485. overflow: hidden;
  486. img {
  487. max-width: 100%;
  488. /*height: 4.08rem;*/
  489. }
  490. }
  491. .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets {
  492. bottom: .1rem !important;
  493. }
  494. .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet {
  495. width: .16rem !important;
  496. height: .16rem !important;
  497. margin: 0 .2rem;
  498. }
  499. }
  500. .link-list {
  501. background: #fff;
  502. height: 1.56rem;
  503. margin-bottom: .2rem;
  504. li {
  505. position: relative;
  506. display: inline-block;
  507. width: 25%;
  508. text-align: center;
  509. float: left;
  510. height: 1.56rem;
  511. img {
  512. width: .7rem;
  513. height: .7rem;
  514. margin-top: .2rem;
  515. }
  516. span {
  517. font-size: .26rem;
  518. color: #666;
  519. display: block;
  520. margin-top: .15rem;
  521. }
  522. i {
  523. height: 0.9rem;
  524. width: .01rem;
  525. background: #ddd;
  526. display: block;
  527. position: absolute;
  528. right: 0;
  529. top: .2rem;
  530. }
  531. }
  532. li.widthActive{
  533. width: 20%;
  534. }
  535. }
  536. }
  537. </style>