index.vue 18 KB

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