Home.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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_03.jpg" alt="">
  35. </div>-->
  36. <div class="swiper-slide">
  37. <img class="home-bg" src="/images/mobile/@2x/applyPurchase/home/app-banner_01.jpg" alt="">
  38. </div>
  39. <div class="swiper-slide">
  40. <img class="home-bg" src="/images/mobile/@2x/applyPurchase/home/app-banner_02.jpg" 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>
  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>
  54. <a @click="goOpportunity">
  55. <img src="/images/mobile/@2x/home/seek.png" alt="">
  56. <span>公司商机</span>
  57. </a>
  58. </li>
  59. <li>
  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>-->
  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>
  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. }
  146. },
  147. components: {
  148. SeekList,
  149. MainSearch,
  150. RemindBox,
  151. LoginBox,
  152. PullUp,
  153. StatisticsMobile
  154. },
  155. watch: {
  156. '$store.state.applyPurchase.purchaseManList.purchaseHomeList.data': {
  157. handler: function (val) {
  158. if (val.length === 0) {
  159. // console.log(111)
  160. this.$store.dispatch('applyPurchase/loadMobileHomeList', {
  161. pageNumber: 1,
  162. pageSize: 5,
  163. enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null
  164. })
  165. } else if (this.isChange) {
  166. this.purchaseManListData = []
  167. this.page = 1
  168. this.isChange = false
  169. this.isDataChange = false
  170. } else {
  171. // console.log(val.content)
  172. this.purchaseManListData = this.purchaseManListData.concat(val.content)
  173. this.isSearchSearchingMore = false
  174. this.isDataChange = true
  175. }
  176. },
  177. immediate: true
  178. },
  179. 'keyword': function (val, oldVal) {
  180. let keywords = this.similarKeywords.data
  181. if (!keywords || !keywords.length) {
  182. this.onChange()
  183. }
  184. }
  185. // $route: {
  186. // handler: function (val) {
  187. // window.removeEventListener('scroll', this.scroll)
  188. // }
  189. // }
  190. },
  191. computed: {
  192. similarKeywords () {
  193. return this.$store.state.search.keywords.data
  194. },
  195. placeholder() {
  196. if (this.ChooseTop === 'component') {
  197. return '请输入您要搜索的型号'
  198. } else if (this.ChooseTop === 'kind') {
  199. return '请输入您要搜索的物料名称'
  200. } else if (this.ChooseTop === 'store') {
  201. return '请输入您要搜索的卖家名称'
  202. } else if (this.ChooseTop === 'brand') {
  203. return '请输入您要搜索的品牌'
  204. }
  205. },
  206. purchaseManList () {
  207. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.data
  208. },
  209. allPage () {
  210. return Math.floor(this.purchaseManList.totalElements / this.purchaseManList.size) + Math.floor(this.purchaseManList.totalElements % this.purchaseManList.size > 0 ? 1 : 0)
  211. },
  212. fetching () {
  213. return this.$store.state.applyPurchase.purchaseManList.purchaseHomeList.fetching
  214. }
  215. },
  216. methods: {
  217. onSearch (item) {
  218. if (item) {
  219. this.keyword = item
  220. }
  221. if (this.keyword) {
  222. this.$router.push(`/mobile/search/newkeycode?choosetype=${this.ChooseTop}&keyword=${encodeURIComponent(this.keyword)}`)
  223. }
  224. },
  225. onChange () {
  226. if (!this.keyword) {
  227. this.associate.show = false
  228. this.$store.dispatch('resetSearchKeywords')
  229. } else {
  230. this.searchKeywords()
  231. }
  232. if (this.click_flag) {
  233. this.associate.show = false
  234. }
  235. },
  236. setChangelistHander(str) {
  237. this.ChooseTop = str
  238. if (!this.keyword) return
  239. this.$store.dispatch('searchKeywords', {keyword: this.keyword, type: this.ChooseTop})
  240. this.associate.show = true
  241. },
  242. searchKeywords () {
  243. this.$store.dispatch('searchKeywords', {keyword: this.keyword, type: this.ChooseTop})
  244. this.associate.show = true
  245. },
  246. onAssociateClick (word) {
  247. if (this.ChooseTop === 'component') {
  248. this.keyword = word.code
  249. } else if (this.ChooseTop === 'kind') {
  250. this.keyword = word.nameCn
  251. } else if (this.ChooseTop === 'store') {
  252. this.keyword = word.name
  253. } else if (this.ChooseTop === 'brand') {
  254. this.keyword = word.nameEn
  255. }
  256. this.onSearch()
  257. },
  258. Getsimilar(word) {
  259. if (this.ChooseTop === 'component') {
  260. return word.code
  261. } else if (this.ChooseTop === 'kind') {
  262. return word.nameCn
  263. } else if (this.ChooseTop === 'store') {
  264. return word.name
  265. } else if (this.ChooseTop === 'brand') {
  266. return word.nameEn
  267. }
  268. },
  269. // scroll: function () {
  270. // let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  271. // if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  272. // this.getMoreSearch()
  273. // }
  274. // },
  275. onHomeSearchClick () {
  276. this.isValid = false
  277. this.showMainSearch = true
  278. this.$store.dispatch('searchData/getSearchHistory')
  279. },
  280. onCancelSearch: function () {
  281. this.isValid = true
  282. this.showMainSearch = false
  283. },
  284. goOpportunity () {
  285. if (this.user.logged) {
  286. if (this.user.data.enterprise.uu) {
  287. this.$router.push('/mobile/center/vendor/seek?seekType=enterprise')
  288. } else if (this.user.data.enterprise.isVendor !== 313) {
  289. this.onRemind('抱歉,您暂未开通卖家中心,可前往PC端开通')
  290. }
  291. } else {
  292. this.url = '/mobile/center/vendor/seek?seekType=wait'
  293. this.showLoginBox = true
  294. }
  295. },
  296. onRemind: function (str) {
  297. this.remindText = str
  298. this.timeoutCount ++
  299. },
  300. reloadData: function () {
  301. 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'})
  302. },
  303. getMoreSearch: function () {
  304. this.page++
  305. this.isSearchSearchingMore = true
  306. this.reloadData()
  307. },
  308. // 商家入驻
  309. goOpenStoreApply: function () {
  310. if (this.user.logged) {
  311. if (this.user.data.enterprise.uu) {
  312. if (this.user.data.enterprise.isVendor === 313) {
  313. this.$http.get('/basic/vendor/transactionInfo').then(response => {
  314. if (response.data.isOpenStore) {
  315. window.location.href = '/mobile/user/storeinfo'
  316. } else {
  317. this.onRemind('您的申请已提交,请耐心等待工作人员审核(2-3个工作日)')
  318. }
  319. }, err => {
  320. this.$message.error('获取开店信息失败')
  321. console.log(err)
  322. })
  323. } else {
  324. this.$router.push('/mobile/store')
  325. }
  326. } else {
  327. this.$router.push('/mobile/store/register')
  328. }
  329. } else {
  330. this.login()
  331. }
  332. }
  333. },
  334. mounted() {
  335. this.$nextTick(() => {
  336. let ua = this.$store.state.option.userAgent.toLowerCase()
  337. let info = localStorage.getItem('USOFTMALLWECHATINFO')
  338. // 如果本地有缓存 则证明存在openid
  339. info = info && JSON.parse(info)
  340. if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger' && !this.$route.query.code && !info) {
  341. window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb3274b676737a319&redirect_uri=https://mall.usoftchina.com&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  342. } else if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger') {
  343. if (!info) {
  344. this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
  345. }
  346. }
  347. })
  348. }
  349. }
  350. </script>
  351. <style lang="scss">
  352. @mixin overFlowHidden {
  353. overflow: hidden;
  354. text-overflow: ellipsis;
  355. white-space: nowrap;
  356. }
  357. @mixin lineHeight($value) {
  358. height: $value;
  359. line-height: $value;
  360. }
  361. @import '~assets/scss/mobileCommon';
  362. .swiper-slide1 {
  363. background: url('/images/mobile/@2x/applyPurchase/home/app-banner_01.jpg');
  364. background-repeat: no-repeat;
  365. background-size: cover;
  366. }
  367. .home {
  368. padding-bottom: 1rem;
  369. background: #f3f3f7;
  370. .search-content {
  371. padding: 0.19rem 0 0.15rem;
  372. position: absolute;
  373. z-index: 10;
  374. width: 100%;
  375. input {
  376. margin-top: -0.02rem;
  377. outline: 0;
  378. border: 0;
  379. }
  380. }
  381. .main-search-header-controll {
  382. width: 5.48rem;
  383. margin-left: 0.21rem;
  384. transform: translateY(1px);
  385. div {
  386. div {
  387. font-size: 0.28rem;
  388. color: #fff;
  389. margin: 0;
  390. border-radius: 0;
  391. padding: 0.1rem 0.1rem;
  392. a {
  393. font-size: .26rem;
  394. color: #f1f1f1;
  395. }
  396. &.active {
  397. background: #fff;
  398. border-top-left-radius: 0.05rem;
  399. border-top-right-radius: 0.05rem;
  400. }
  401. &.active a {
  402. color: #2d8cf0;
  403. }
  404. }
  405. }
  406. }
  407. .associate-list {
  408. position: absolute;
  409. width: 100%;
  410. background: #fff;
  411. top: 1.29rem;
  412. border: 1px solid #dcdcdc;
  413. z-index: 100;
  414. height: 100%;
  415. left: 0;
  416. bottom: 0;
  417. right: 0;
  418. overflow-y: auto;
  419. li {
  420. height: 0.7rem;
  421. line-height: .9rem;
  422. margin: 0 .45rem;
  423. border-bottom: .04rem solid #f1f0f0;
  424. @include overFlowHidden();
  425. i {
  426. font-size: .36rem;
  427. margin-right: .24rem;
  428. color: #ddd;
  429. }
  430. span {
  431. color: #999;
  432. font-size: .28rem;
  433. line-height: .58rem;
  434. height: .58rem;
  435. display: inline-block;
  436. }
  437. &:active, &:hover {
  438. background: #eee;
  439. }
  440. &:last-child {
  441. text-align: center;
  442. font-size: .3rem;
  443. color: #3976f4;
  444. border-bottom: none;
  445. &:active, &:hover {
  446. background: #fff;
  447. }
  448. }
  449. }
  450. }
  451. .header {
  452. position: relative;
  453. height: 4.08rem;
  454. overflow: hidden;
  455. .swiper-container {
  456. width: 100%;
  457. z-index: 0;
  458. height: 4.08rem;
  459. overflow: hidden;
  460. img {
  461. max-width: 100%;
  462. /*height: 4.08rem;*/
  463. }
  464. }
  465. .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets {
  466. bottom: .1rem !important;
  467. }
  468. .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet {
  469. width: .16rem !important;
  470. height: .16rem !important;
  471. margin: 0 .2rem;
  472. }
  473. }
  474. .link-list {
  475. background: #fff;
  476. height: 1.56rem;
  477. margin-bottom: .2rem;
  478. li {
  479. position: relative;
  480. display: inline-block;
  481. width: 24%;
  482. text-align: center;
  483. float: left;
  484. height: 1.56rem;
  485. img {
  486. width: .7rem;
  487. height: .7rem;
  488. margin-top: .2rem;
  489. }
  490. span {
  491. font-size: .26rem;
  492. color: #666;
  493. display: block;
  494. margin-top: .15rem;
  495. }
  496. i {
  497. height: 0.9rem;
  498. width: .01rem;
  499. background: #ddd;
  500. display: block;
  501. position: absolute;
  502. right: 0;
  503. top: .2rem;
  504. }
  505. }
  506. }
  507. }
  508. </style>