Home.vue 16 KB

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