index.vue 18 KB

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