index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <div class="user-content mobile-content">
  3. <div class="user-name">
  4. <img src="/images/component/default.png"/>
  5. <div class="user-info">
  6. <p v-text="userInfo.data.userName"></p>
  7. <p v-text="enterpriseInfo.enName"></p>
  8. </div>
  9. <a v-if="isVendor" v-text="userType === 'saler' ? '切换至买家中心' : '切换至卖家中心'" @click="switchType"></a>
  10. </div>
  11. <ul class="switch-list" v-if="userType !== 'saler'">
  12. <li :class="{active: activeType == 'seek'}" @click="activeType = 'seek'" v-text="userType === 'saler' ? '求购询价' : '我的求购'"></li>
  13. <li :class="{active: activeType == 'comp'}" @click="activeType = 'comp'">器件收藏</li>
  14. <li :class="{active: activeType == 'store'}" @click="activeType = 'store'">店铺关注</li>
  15. </ul>
  16. <div v-if="activeType == 'seek'">
  17. <div class="seek" v-if="userType !== 'saler'">
  18. <ul class="seek-type">
  19. <li :class="{active: seekType == 'wait'}" @click="switchSeek('wait')"><div>待报价</div></li>
  20. <li :class="{active: seekType == 'done'}" @click="switchSeek('done')"><div>已报价</div></li>
  21. <!--<li :class="{active: seekType == 'accept'}" @click="switchSeek('accept')"><div>已采纳</div></li>-->
  22. </ul>
  23. </div>
  24. <ul class="switch-list vendor-switch" v-if="userType === 'saler'">
  25. <li :class="{active: seekType == 'wait'}" @click="switchSeek('wait')"><div>待报价</div></li>
  26. <li :class="{active: seekType == 'done'}" @click="switchSeek('done')"><div>已报价</div></li>
  27. </ul>
  28. <div class="search-content">
  29. <input type="text" placeholder="请输入您要查找的型号或品牌" v-model="seekKeyword" @keyup.13="searchSeek">
  30. <span @click="searchSeek">
  31. <i class="iconfont icon-sousuo"></i>
  32. </span>
  33. </div>
  34. <seek-list :userType="userType" :seekType="seekType" :purchaseManList="purchaseManListData" :isDataChange="isDataChange"></seek-list>
  35. </div>
  36. <div class="shop-list" v-if="activeType == 'store'" v-for="item in focusPage.content" @click="goStoreDetail(item.storeInfo.uuid)">
  37. <h3>{{item.storeName}}</h3>
  38. <div class="list-item">
  39. <div class="item-img">
  40. <img :src="getBackground(item.storeInfo.type)" />
  41. <img :src="item.storeInfo.logoUrl || '/images/component/default.png'">
  42. </div>
  43. <div class="list-item-phone">
  44. <p>电话:<span>{{item.storeInfo.enterprise ? item.storeInfo.enterprise.enTel : '-'}}</span></p>
  45. <p>传真:<span>{{item.storeInfo.enterprise ? item.storeInfo.enterprise.enFax : '-'}}</span></p>
  46. <p>联系商家:<a @click="selectStoreInfo(item, $event)">点击查看</a></p>
  47. <i class="iconfont icon-shoucang" @click="cancelFocus('store', item, $event)"></i>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="detail-brand" v-for="(item, index) in collectSave.content" v-if="activeType == 'comp'" @click="goComponentDetail(item.componentinfo.uuid)">
  52. <a>
  53. <div class="brand-item">
  54. <p>型号:<span>{{item.componentinfo.code}}</span></p>
  55. <p>品牌:<span>{{item.componentinfo.brand.nameCn}}</span></p>
  56. <p>产品描述:<span>{{item.componentinfo.kind.nameCn}}</span></p>
  57. <i class="iconfont icon-shoucang" @click="cancelFocus('product', item, $event)"></i>
  58. </div>
  59. </a>
  60. </div>
  61. <div class="none-state" v-if="(activeType != 'seek') && ((collectSave.totalElements == 0 && activeType == 'comp') || (focusPage.totalElements == 0 && activeType == 'store') || (collectSave.totalElements == 0 && focusPage.totalElements == 0))">
  62. <img src="/images/mobile/@2x/empty-collect.png">
  63. <p v-text="getRemindText()"></p>
  64. <nuxt-link to="/">返回首页</nuxt-link>
  65. </div>
  66. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  67. <div class="mobile-modal" v-if="showStoreInfo">
  68. <div class="mobile-modal-box">
  69. <div class="mobile-modal-header">联系方式<i @click="showStoreInfo = false" class="icon-guanbi iconfont"></i></div>
  70. <div class="mobile-modal-content">
  71. <div v-if="checkInfo(storeInfo.enAddress || storeInfo.address)">商家地址:{{storeInfo.enAddress || storeInfo.address}}</div>
  72. <!--<div class="content-line link-url">在线咨询</div>-->
  73. <div v-if="checkInfo(storeInfo.enTel)">致电:<a :href="'tel:' + storeInfo.enTel" target="_blank" class="content-line link-url">{{storeInfo.enTel}}</a></div>
  74. <div v-if="checkInfo(storeInfo.enEmail)">邮件:<a :href="'mailto:' + storeInfo.enEmail" target="_blank" class="content-line link-url">{{storeInfo.enEmail}}</a></div>
  75. </div>
  76. </div>
  77. </div>
  78. <page-loading v-show="showLoading"></page-loading>
  79. <loading v-show="isSearchSearchingMore"></loading>
  80. <div v-if="purchaseManList && false"></div>
  81. <div v-if="purchaseManListFetching && false"></div>
  82. </div>
  83. </template>
  84. <script>
  85. import SeekList from '~components/mobile/applyPurchase/SeekList.vue'
  86. import {RemindBox, Loading} from '~components/mobile/common'
  87. import PageLoading from '~components/common/loading/PageLoading.vue'
  88. export default {
  89. layout: 'mobile',
  90. data () {
  91. return {
  92. userName: '',
  93. count: '',
  94. page: '',
  95. type: '',
  96. activeType: 'seek',
  97. collectResult: '取消成功',
  98. timeoutCount: 0,
  99. showStoreInfo: false,
  100. storeInfo: {},
  101. seekType: 'wait',
  102. showLoading: false,
  103. seekKeyword: '',
  104. isSearchSearchingMore: false,
  105. isChange: false,
  106. seekPage: 1,
  107. seekSize: 10,
  108. purchaseManListData: [],
  109. isDataChange: false
  110. }
  111. },
  112. components: {
  113. RemindBox,
  114. SeekList,
  115. PageLoading,
  116. Loading
  117. },
  118. fetch ({ store, route }) {
  119. return Promise.all([
  120. store.dispatch('product/saveStores', { count: 100, page: 1, type: 'component' }),
  121. store.dispatch('shop/StoreFocusPage', { count: 100, page: 1 }),
  122. store.dispatch(route.query.type === 'saler' ? 'applyPurchase/loadPurchaseManList' : 'applyPurchase/loadBuyerUnSayPricePurchaseManList', {pageNumber: 1, pageSize: 10, enUU: store.state.option.user.data.enterprise ? store.state.option.user.data.enterprise.uu : store.state.option.user.data.userUU, state: (!route.query.type || route.query.type === 'buyer') ? 'todo' : null})
  123. ])
  124. },
  125. mounted: function () {
  126. this.$nextTick(() => {
  127. window.addEventListener('scroll', this.scroll, false)
  128. })
  129. },
  130. methods: {
  131. cancelFocus: function (type, item, event) {
  132. event.stopPropagation()
  133. if (type === 'store') {
  134. this.$http.post('/trade/storeFocus/delete/storeId', [item.storeid])
  135. .then(response => {
  136. this.$store.dispatch('shop/StoreFocusPage', { count: 100, page: 1 })
  137. this.timeoutCount++
  138. })
  139. } else {
  140. // /trade/collection/
  141. this.$http.delete('/trade/collection/' + item.id)
  142. .then(response => {
  143. this.$store.dispatch('product/saveStores', { count: 100, page: 1, type: 'component' })
  144. this.timeoutCount++
  145. })
  146. }
  147. },
  148. getBackground: function (type) {
  149. let url = ''
  150. if (type === 'AGENCY') {
  151. url += '/images/mobile/@2x/shop/agency.png'
  152. } else if (type === 'DISTRIBUTION') {
  153. url += '/images/mobile/@2x/shop/distribution.png'
  154. } else if (type === 'ORIGINAL_FACTORY') {
  155. url += '/images/mobile/@2x/shop/original_factory.png'
  156. } else if (type === 'CONSIGNMENT') {
  157. url = '/images/mobile/@2x/shop/consignment.png'
  158. }
  159. return url
  160. },
  161. goStoreDetail: function (uuid) {
  162. this.$router.push('/mobile/shop/' + uuid)
  163. },
  164. goComponentDetail: function (uuid) {
  165. this.$router.push('/mobile/brand/componentDetail/' + uuid)
  166. },
  167. getRemindText: function () {
  168. if (this.activeType === 'comp') {
  169. return '抱歉,暂无器件收藏'
  170. } else if (this.activeType === 'store') {
  171. return '抱歉,暂无店铺关注'
  172. }
  173. },
  174. selectStoreInfo: function (store, event) {
  175. event.stopPropagation()
  176. this.storeInfo = store.storeInfo.enterprise || {}
  177. this.showStoreInfo = true
  178. },
  179. checkInfo: function (str) {
  180. return str && str.trim() !== ''
  181. },
  182. switchSeek: function (type) {
  183. this.seekType = type
  184. this.showLoading = true
  185. this.seekKeyword = ''
  186. this.isChange = true
  187. this.seekPage = 1
  188. this.reloadData()
  189. },
  190. switchType: function () {
  191. this.activeType = 'seek'
  192. this.seekType = 'wait'
  193. this.seekKeyword = ''
  194. this.$router.push('/mobile/user' + (this.userType === 'saler' ? '?type=buyer' : '?type=saler'))
  195. },
  196. searchSeek: function () {
  197. this.isChange = true
  198. this.reloadData()
  199. },
  200. reloadData: function () {
  201. let type = this.seekType
  202. if (this.userType !== 'saler') {
  203. if (type === 'wait') {
  204. this.$store.dispatch('applyPurchase/loadBuyerUnSayPricePurchaseManList', {pageNumber: this.seekPage, pageSize: this.seekSize, enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null, keyword: this.seekKeyword, state: 'todo'})
  205. } else if (type === 'done') {
  206. this.$store.dispatch('applyPurchase/loadBuyerPurchaseManList', {pageNumber: this.seekPage, pageSize: this.seekSize, enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null, _state: 'done', keyword: this.seekKeyword})
  207. } else {
  208. this.$store.dispatch('applyPurchase/loadBuyerPurchaseManList', {pageNumber: this.seekPage, pageSize: this.seekSize, enUU: this.$store.state.option.user.data.enterprise ? this.$store.state.option.user.data.enterprise.uu : null, _state: 'done', keyword: this.seekKeyword})
  209. }
  210. } else {
  211. if (type === 'wait') {
  212. this.$store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: this.seekPage, pageSize: this.seekSize, enUU: this.$store.state.option.user.data.enterprise.uu, keyword: this.seekKeyword})
  213. } else if (type === 'done') {
  214. this.$store.dispatch('applyPurchase/loadVendorPurchaseManList', {pageNumber: this.seekPage, pageSize: this.seekSize, _state: 'done', filter: {vendUU: this.$store.state.option.user.data.enterprise.uu, fromDate: null, endDate: null, keyword: this.seekKeyword}})
  215. } else {
  216. this.$store.dispatch('applyPurchase/loadVendorPurchaseManList', {pageNumber: this.seekPage, pageSize: this.seekSize, _state: 'done', filter: {vendUU: this.$store.state.option.user.data.enterprise.uu, fromDate: null, endDate: null, keyword: this.seekKeyword}})
  217. }
  218. }
  219. },
  220. scroll: function () {
  221. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  222. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.seekPage < this.allPage) {
  223. this.getMoreSearch()
  224. }
  225. },
  226. getMoreSearch: function () {
  227. this.seekPage++
  228. this.isSearchSearchingMore = true
  229. this.reloadData()
  230. }
  231. },
  232. computed: {
  233. collectSave () {
  234. return this.$store.state.product.common.collectList.data
  235. },
  236. userInfo () {
  237. return this.$store.state.option.user
  238. },
  239. enterpriseInfo () {
  240. let ens = this.userInfo.data.enterprises
  241. if (ens && ens.length) {
  242. for (let i = 0; i < ens.length; i++) {
  243. if (ens[i].current) {
  244. return ens[i]
  245. }
  246. }
  247. }
  248. return {enName: this.userInfo.data.userName + '(个人账户)'}
  249. },
  250. isVendor () {
  251. return this.enterpriseInfo.isVendor === 313
  252. },
  253. userType () {
  254. return this.$route.query.type
  255. },
  256. focusPage () {
  257. return this.$store.state.shop.storeInfo.focusPage.data
  258. },
  259. purchase () {
  260. return this.$store.state.applyPurchase.purchaseManList.purchaseManList
  261. },
  262. purchaseManList () {
  263. let list = this.purchase.data.content
  264. if (this.isChange) {
  265. this.purchaseManListData = []
  266. this.seekPage = 1
  267. this.isChange = false
  268. this.isDataChange = true
  269. } else {
  270. this.purchaseManListData = this.purchaseManListData.concat(list)
  271. this.isSearchSearchingMore = false
  272. this.isDataChange = false
  273. }
  274. // console.log(this.purchaseManListData)
  275. return this.purchase.data.content
  276. },
  277. allPage () {
  278. return Math.floor(this.purchase.data.totalElements / this.purchase.data.size) + Math.floor(this.purchase.data.totalElements % this.purchase.data.size > 0 ? 1 : 0)
  279. },
  280. purchaseManListFetching () {
  281. this.showLoading = false
  282. return this.purchase.fetching
  283. }
  284. }
  285. }
  286. </script>
  287. <style scoped lang="scss">
  288. .user-content{
  289. margin-bottom: .98rem;
  290. .none-state{
  291. text-align: center;
  292. padding:1.5rem 0;
  293. background: #fff;
  294. margin-top:.1rem;
  295. width:100%;
  296. img{
  297. margin:0 auto;
  298. width: 4.08rem;
  299. height: 2.62rem;
  300. }
  301. p {
  302. font-size: .32rem;
  303. color: #999;
  304. margin: 1.19rem 0 0 0;
  305. }
  306. a {
  307. display: block;
  308. font-size: .28rem;
  309. color: #fff;
  310. width: 1.88rem;
  311. height: .54rem;
  312. line-height: .54rem;
  313. background: #418bf6;
  314. margin: .7rem auto 0;
  315. border-radius: .05rem;
  316. }
  317. }
  318. .user-name{
  319. height: 1.8rem;
  320. padding: .28rem 0 .28rem .34rem;
  321. background: #fff;
  322. width: 100%;
  323. position: relative;
  324. img{
  325. display: inline-block;
  326. width: 1.25rem;
  327. height: 1.25rem;
  328. border: 1px solid #c5dbfc;
  329. border-radius: .05rem;
  330. vertical-align: middle;
  331. }
  332. .user-info {
  333. margin-left:.25rem;
  334. display: inline-block;
  335. vertical-align: middle;
  336. p{
  337. font-size:.3rem;
  338. margin:0;
  339. display: block;
  340. overflow: hidden;
  341. text-overflow: ellipsis;
  342. white-space: nowrap;
  343. width: 3.92rem;
  344. &:nth-child(2) {
  345. margin-top: .2rem;
  346. }
  347. }
  348. }
  349. > a {
  350. font-size: .24rem;
  351. position: absolute;
  352. top: .45rem;
  353. right: .1rem;
  354. color: #3f84f6;
  355. border: 1px solid #3f84f6;
  356. border-radius: .2rem;
  357. padding: .06rem .12rem;
  358. }
  359. }
  360. .shop-list {
  361. background:#fff;
  362. border-bottom: .1rem solid #dfe2e4;
  363. padding: .14rem 0 .14rem 0;
  364. h3{
  365. font-size: .32rem;
  366. line-height: .4rem;
  367. margin: 0 0 0 .27rem;
  368. overflow: hidden;
  369. text-overflow: ellipsis;
  370. white-space: nowrap;
  371. padding-top: .1rem;
  372. position: relative;
  373. top: .1rem;
  374. }
  375. .list-item{
  376. width:6.77rem;
  377. margin-left:.39rem;
  378. .item-img{
  379. width:2.4rem;
  380. vertical-align: middle;
  381. display: inline-block;
  382. img{
  383. &:nth-child(2) {
  384. width:2.4rem;
  385. height:1.69rem;
  386. border: 1px solid #eee;
  387. }
  388. &:nth-child(1) {
  389. position:absolute;
  390. width:.65rem;
  391. height:.33rem;
  392. }
  393. }
  394. }
  395. .list-item-phone{
  396. width:3.95rem;
  397. padding:.18rem 0;
  398. position:relative;
  399. display: inline-block;
  400. vertical-align: middle;
  401. margin-left: .26rem;
  402. p{
  403. font-size:.28rem;
  404. line-height: .67rem;
  405. margin:0;
  406. overflow: hidden;
  407. text-overflow: ellipsis;
  408. white-space: nowrap;
  409. width: 3.2rem;
  410. }
  411. i{
  412. display:block;
  413. position:absolute;
  414. top: -.06rem;
  415. right: -.18rem;
  416. font-size:.5rem;
  417. color:#ff7800;
  418. width: .6rem;
  419. height: .6rem;
  420. text-align: center;
  421. line-height: .6rem;
  422. }
  423. }
  424. }
  425. &:active {
  426. background: #e1e1e1;
  427. }
  428. }
  429. .detail-brand{
  430. background: #fff;
  431. width:100%;
  432. min-height:1.5rem;
  433. padding:.2rem 0;
  434. border-bottom: .1rem solid #dfe2e4;
  435. &:nth-child(1) {
  436. margin-top:.1rem;
  437. }
  438. .brand-item{
  439. width:7rem;
  440. margin:0 auto;
  441. border-radius:.1rem;
  442. background: #fff;
  443. padding:.2rem;
  444. position:relative;
  445. &:active{
  446. background: #e1e1e1;
  447. }
  448. p{
  449. font-size:.28rem;
  450. line-height:.4rem;
  451. color:#333;
  452. margin:0;
  453. }
  454. i{
  455. display:block;
  456. position:absolute;
  457. top:.2rem;
  458. right:.1rem;
  459. font-size:.5rem;
  460. color:#ff7800;
  461. width: .6rem;
  462. height: .6rem;
  463. line-height: .6rem;
  464. text-align: center;
  465. }
  466. }
  467. div.active{
  468. background: #d4d;
  469. }
  470. }
  471. .collect-list-type {
  472. background: #fff;
  473. border-bottom: 1px solid #acacac;
  474. p {
  475. font-size: .32rem;
  476. margin: 0 0 0 .13rem;
  477. width: .92rem;
  478. text-align: center;
  479. line-height: .5rem;
  480. border-bottom: .06rem solid #418bf6;
  481. }
  482. }
  483. ul.switch-list {
  484. li {
  485. display: inline-block;
  486. width: 2.5rem;
  487. height: .63rem;
  488. line-height: .63rem;
  489. text-align: center;
  490. font-size: .28rem;
  491. color: #666;
  492. background: #fff;
  493. border: 1px solid #b4b4b4;
  494. border-right: none;
  495. &.active {
  496. background: #0067e7;
  497. border: 1px solid #0067e7;
  498. color: #fff;
  499. }
  500. &:first-child {
  501. border-left: none;
  502. }
  503. &:last-child {
  504. border-right: none;
  505. }
  506. }
  507. &.vendor-switch {
  508. li {
  509. width: 50%;
  510. }
  511. }
  512. }
  513. .seek {
  514. .seek-type {
  515. margin-top: .15rem;
  516. li {
  517. font-size: .28rem;
  518. color: #666;
  519. display: inline-block;
  520. width: 50%;
  521. text-align: center;
  522. div {
  523. border-bottom: 1px solid #c1c4c9;
  524. margin: 0 auto;
  525. height: .46rem;
  526. line-height: .46rem;
  527. }
  528. &.active {
  529. color: #3f84f6;
  530. div {
  531. border-color: #3f84f6;
  532. }
  533. }
  534. }
  535. }
  536. }
  537. .search-content {
  538. text-align: center;
  539. padding: .25rem 0 0 0;
  540. input {
  541. border: 1px solid #376ff3;
  542. }
  543. span {
  544. height: .46rem;
  545. line-height: .46rem;
  546. }
  547. }
  548. }
  549. </style>