FloorList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <template>
  2. <div class="floor-list">
  3. <div class="container">
  4. <floor-bar :floors="floorsList"></floor-bar>
  5. <!--<a href="/store/33069557578d44e69bd91ad12d28a8d4" target="_blank"><img src="/images/all/banner-cuxiao.png" alt=""></a>-->
  6. <!--<div v-if="purchaseManListData && false"></div>-->
  7. <div class="banner">
  8. <ul class="seek-banner">
  9. <!--<li><a href="/store/33069557578d44e69bd91ad12d28a8d4" target="_blank"><img src="/images/all/banner-cuxiao001.jpg" alt=""></a></li>-->
  10. <li>
  11. <div class="banner-cuxiao">
  12. <div class="wrap">
  13. <p class="title"><span>最新求购</span><img class="new-animate" src="/images/all/banner-cuxiao03.jpg" alt="">
  14. <nuxt-link to="/applyPurchase">查看更多</nuxt-link>
  15. </p>
  16. <div class="list-head">
  17. <span>发布时间</span>
  18. <span>买家名称</span>
  19. <span>品牌</span>
  20. <span>物料名称(类目)</span>
  21. <span>型号</span>
  22. <span>规格</span>
  23. <span>操作</span>
  24. </div>
  25. <ul>
  26. <li v-for="(purchaseMan, index) in purchaseManListData.content" :style="'top: -' + 32 * timerIndex + 'px'" :class="{'top': isTop}">
  27. <div>{{purchaseMan.date | date}}</div>
  28. <div>
  29. <span :title="user.logged ? purchaseMan.inquiry.enterprise.enName : null" v-if="purchaseMan.inquiry && purchaseMan.inquiry.enterprise && purchaseMan.inquiry.enterprise.enName">{{[purchaseMan.inquiry.enterprise.enName, user] | enterpriseFilter}}</span>
  30. <span :title="user.logged ? purchaseMan.userName : null" v-else>{{[purchaseMan.userName, user] | userNameFilter}}</span>
  31. </div>
  32. <div :title="purchaseMan.inbrand">{{purchaseMan.inbrand || '-'}}</div>
  33. <div :title="purchaseMan.prodTitle">{{purchaseMan.prodTitle || '-'}}</div>
  34. <div :title="purchaseMan.cmpCode">{{purchaseMan.cmpCode || '-'}}</div>
  35. <div :title="purchaseMan.spec">{{purchaseMan.spec || '-'}}</div>
  36. <div>
  37. <div class="is-say-price" v-if="purchaseMan.remainingTime > 0 && purchaseMan.quoted == 1">已报价 <img src="/images/applyPurchase/green-check.png" alt=""></div>
  38. <div v-else>
  39. <a title="该求购已截止" v-if="!purchaseMan.remainingTime || purchaseMan.remainingTime <= 0" class="is-same" @click="sayPriceStop">我要报价</a>
  40. <a title="此为贵公司的求购" v-if="purchaseMan.remainingTime > 0 && (!purchaseMan.quoted || purchaseMan.quoted != 1) && (user.logged && ((purchaseMan.inquiry.enterprise && user.data.enterprise && (purchaseMan.inquiry.enterprise.uu === user.data.enterprise.uu)) || (!user.data.enterprise.uu && purchaseMan.userUU == user.data.userUU && !purchaseMan.inquiry.enterprise)))" class="is-same" @click="sayPriceSeft">我要报价</a>
  41. <a v-if="purchaseMan.remainingTime > 0 && (!purchaseMan.quoted || purchaseMan.quoted != 1) && !(user.logged && ((purchaseMan.inquiry.enterprise && user.data.enterprise && (purchaseMan.inquiry.enterprise.uu === user.data.enterprise.uu)) || (!user.data.enterprise.uu && purchaseMan.userUU == user.data.userUU && !purchaseMan.inquiry.enterprise)))" @click="sayPrice(purchaseMan, index)">我要报价</a>
  42. </div>
  43. </div>
  44. </li>
  45. </ul>
  46. </div>
  47. <nuxt-link to="/applyPurchase" class="purchase">我要求购</nuxt-link>
  48. </div>
  49. </li>
  50. </ul>
  51. </div>
  52. <floor :floor="defaultFloors[0]" :isDefault="true" v-if="!isEmpty"></floor>
  53. <floor :floor="defaultFloors[1]" :isDefault="true" v-if="!isEmpty"></floor>
  54. <floor v-for="(floor, index) in floorsList" :floor="floor" :isDefault="false" :key="index"></floor>
  55. </div>
  56. <span v-if="expandFloors && false">floor</span>
  57. <say-price :current="currentSayPriceIndex"
  58. :purchase="purchaseManListData || {}"
  59. @cancelSayPriceAction="cancelSayPrice"
  60. @resetListAction="resetList"
  61. @sayPriceIndexAction="setIndex(index)"
  62. ></say-price>
  63. </div>
  64. </template>
  65. <script>
  66. import Floor from './Floor.vue'
  67. import FloorBar from './FloorBar.vue'
  68. import SayPrice from '~components/applyPurchase/SayPrice.vue'
  69. import baseUtils from '~utils/baseUtils'
  70. export default {
  71. name: 'floor-list',
  72. components: {
  73. Floor,
  74. FloorBar,
  75. SayPrice
  76. },
  77. data () {
  78. return {
  79. defaultFloors: [
  80. {
  81. items: [
  82. {
  83. backGroundColor: '',
  84. body: '',
  85. hrefUrl: '/store/33069557578d44e69bd91ad12d28a8d4',
  86. pictureUrl: '/images/floor/banner01.jpg',
  87. size: 'large'
  88. }
  89. ]
  90. },
  91. {
  92. items: [
  93. {
  94. backGroundColor: '',
  95. body: '',
  96. hrefUrl: '/store/33069557578d44e69bd91ad12d28a8d4',
  97. pictureUrl: '/images/floor/banner02.jpg',
  98. size: 'large'
  99. }
  100. ]
  101. }
  102. ],
  103. timerIndex: 0,
  104. pageSize: 50,
  105. nowPage: 1,
  106. currentSayPriceIndex: -1,
  107. // purchaseManList: {
  108. // content: []
  109. // },
  110. // listTemplate: [],
  111. isChange: false,
  112. isTop: false, // 判断是否滚动至顶,
  113. timer: {} // 定时器实体
  114. }
  115. },
  116. mounted () {
  117. this.$nextTick(() => {
  118. this.changeInterval(true)
  119. })
  120. },
  121. filters: {
  122. date: function (date) {
  123. const now = baseUtils.formatDate('yyyy-MM-dd', Date.now())
  124. const day = Math.floor((now - date) / (1000 * 60 * 60 * 24))
  125. return day <= 0 ? '今天' : day + '天前'
  126. },
  127. enterpriseFilter ([str, user]) {
  128. if (!user.logged) {
  129. return str ? str.length > 4 ? str.substring(0, 2) + '**' + str.substring(str.length - 2, str.length) : str : '-'
  130. } else {
  131. return str || '-'
  132. }
  133. },
  134. userNameFilter ([str, user]) {
  135. if (!user.logged) {
  136. return str ? str.substring(0, 1) + '**' : '-'
  137. } else {
  138. return str || '-'
  139. }
  140. }
  141. },
  142. computed: {
  143. floorsF1 () {
  144. return this.$store.state.floor.listF1.data
  145. },
  146. floorsF2 () {
  147. return this.$store.state.floor.listF2.data
  148. },
  149. floorsF3 () {
  150. return this.$store.state.floor.listF3.data
  151. },
  152. floorsF4 () {
  153. return this.$store.state.floor.listF4.data
  154. },
  155. floorsF5 () {
  156. return this.$store.state.floor.listF5.data
  157. },
  158. floorsList () {
  159. let lists = []
  160. let floorName = ['传感器件', '连接器件', '分立器件', '被动器件', '电源产品']
  161. for (let i = 0; i < floorName.length; i++) {
  162. lists.push({'floorNumber': i + 1, 'name': floorName[i]})
  163. }
  164. lists[0].items = this.floorsF1.data
  165. lists[1].items = this.floorsF2.data
  166. lists[2].items = this.floorsF3.data
  167. lists[3].items = this.floorsF4.data
  168. lists[4].items = this.floorsF5.data
  169. lists.slice().forEach(function(value) {
  170. let lengs = value.items.length
  171. for (let j = 0; j < lengs; j++) {
  172. value.items[j].backGroundColor = value.items[j].metadatas.contExp_select
  173. value.items[j].body = value.items[j].metadatas.contExp_remark
  174. value.items[j].name = value.items[j].metadatas.contExp_abstract
  175. value.items[j].size = value.items[j].metadatas.contExp_spec
  176. value.items[j].hrefUrl = value.items[j].detailsLink
  177. value.items[j].pictureUrl = value.items[j].pictureLink
  178. }
  179. })
  180. return lists
  181. },
  182. isProd () {
  183. return this.$store.state.option.url === 'http://www.usoftmall.com'
  184. },
  185. expandFloors () {
  186. let data = this.$store.state.floor.list_expand.data
  187. let _this = this
  188. for (let i = 0; i < data.length; i++) {
  189. let obj = {
  190. backGroundColor: '',
  191. body: '',
  192. hrefUrl: '',
  193. name: '',
  194. pictureUrl: '',
  195. size: '',
  196. price: '',
  197. currency: 'RMB'
  198. }
  199. if (data[i]) {
  200. obj.name = data[i].code
  201. obj.body = data[i].brandNameEn + '<br/>' + (data[i].kindNameCn || '其他')
  202. obj.hrefUrl = '/store/productDetail/' + data[i].batchCode
  203. obj.pictureUrl = '/images/floor/' + (this.isProd ? data[i].code : '2SD2704KT146') + '.png'
  204. obj.currency = data[i].currencyName
  205. obj.price = _this.getMinPrice(data[i].prices, data[i].currencyName)
  206. } else {
  207. // 如果是空数据
  208. obj.isNull = true
  209. }
  210. obj.size = i % 3 === 0 ? 'medium' : 'small'
  211. _this.defaultFloors[i < 6 ? 0 : 1].items.push(obj)
  212. }
  213. return data
  214. },
  215. isEmpty () {
  216. let data = this.$store.state.floor.list_expand.data
  217. if (!data.length) {
  218. return true
  219. } else {
  220. for (let i = 0; i < data.length; i++) {
  221. if (!(data[0] && data[0] !== null)) {
  222. return true
  223. }
  224. }
  225. }
  226. return false
  227. },
  228. purchaseManListData () {
  229. // let list = this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  230. // if (this.isChange) {
  231. // this.purchaseManList.content = []
  232. // this.listTemplate = list
  233. // this.isChange = false
  234. // } else if (list.content) {
  235. // for (let i = 0; i < list.content.length; i++) {
  236. // this.purchaseManList.content.push(list.content[i])
  237. // }
  238. // this.listTemplate = list
  239. // }
  240. return this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  241. },
  242. user () {
  243. return this.$store.state.option.user
  244. }
  245. },
  246. methods: {
  247. getMinPrice: function (prices, currency) {
  248. for (let i = 0; i < prices.length; i++) {
  249. if (i === prices.length - 1) {
  250. return currency === 'RMB' ? prices[i].rMBPrice : prices[i].uSDPrice
  251. }
  252. }
  253. },
  254. setIndex: function (index) {
  255. this.currentSayPriceIndex = index
  256. },
  257. sayPriceStop: function () {
  258. this.$message.error('该求购已截止')
  259. },
  260. sayPriceSeft: function () {
  261. this.$message.error('此为贵公司的求购')
  262. },
  263. sayPrice: function (purchaseMan, index) {
  264. if (this.user.logged) {
  265. if (this.user.data.enterprise.uu) {
  266. if (this.user.data.enterprise.isVendor && this.user.data.enterprise.isVendor !== '1690') {
  267. // purchaseMan.active = true
  268. this.authorityInterceptor(this.baseUrls.vendorBusinessSayPrice, () => {
  269. this.changeInterval(false)
  270. this.currentSayPriceIndex = index
  271. })
  272. } else {
  273. this.$message.error('抱歉,您需开通卖家功能才可报价')
  274. }
  275. } else {
  276. this.$message.error('个人账户暂不可报价')
  277. }
  278. } else {
  279. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  280. }
  281. },
  282. resetList: function () {
  283. this.currentSayPriceIndex = -1
  284. this.timerIndex = 0
  285. this.isChange = true
  286. this.$store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: this.nowPage, pageSize: this.pageSize, enUU: this.user.data.enterprise ? this.user.data.enterprise.uu : null})
  287. },
  288. cancelSayPrice: function () {
  289. // this.purchaseManList.content[this.currentSayPriceIndex].active = false
  290. this.currentSayPriceIndex = -1
  291. this.changeInterval(true)
  292. },
  293. changeInterval: function (flag) {
  294. if (flag) {
  295. this.timer = setInterval(() => {
  296. this.timerIndex ++
  297. this.isTop = (this.timerIndex % 45 === 0)
  298. if (this.isTop) {
  299. // for (let i = 0; i < _this.listTemplate.content.length; i++) {
  300. // this.purchaseManList.content.push(_this.listTemplate.content[i])
  301. // }
  302. this.timerIndex = 0
  303. }
  304. }, 3000)
  305. } else {
  306. clearInterval(this.timer)
  307. }
  308. }
  309. }
  310. }
  311. </script>
  312. <style lang="scss" scoped>
  313. @import '~assets/scss/variables';
  314. /*add*/
  315. .floor-list .container{
  316. padding: 0;
  317. }
  318. .floor-list {
  319. margin-bottom: $xlg-pad;
  320. }
  321. .floor-list .container > a > img {
  322. margin-top: 30px;
  323. }
  324. .banner{
  325. width:1190px;
  326. height: 253px;
  327. margin-top: 20px;
  328. .seek-banner {
  329. > li{
  330. /*float: left;*/
  331. /*padding-left: 14px;*/
  332. position: relative;
  333. /*&:first-child{*/
  334. /*padding-left: 0;*/
  335. /*}*/
  336. }
  337. }
  338. .banner-cuxiao {
  339. width: 1190px;
  340. height: 253px;
  341. background: url('/images/all/home-apply.jpg') no-repeat;
  342. /*background-size: 1190px auto;*/
  343. .wrap {
  344. width: 874px;
  345. .title {
  346. color: #f57a2e;
  347. font-size: 20px;
  348. font-weight: bold;
  349. padding: 10px 30px;
  350. margin: 0;
  351. a {
  352. font-size: 14px;
  353. color: #f57a2e;
  354. float: right;
  355. margin-top: 7px;
  356. }
  357. }
  358. .list-head {
  359. height: 30px;
  360. line-height: 30px;
  361. color: #fff;
  362. font-size: 14px;
  363. background-color: #f57a2e;
  364. text-align: center;
  365. span {
  366. display: inline-block;
  367. &:nth-child(1) {
  368. width: 97px;
  369. }
  370. &:nth-child(2) {
  371. width: 164px;
  372. }
  373. &:nth-child(3) {
  374. width: 139px;
  375. }
  376. &:nth-child(4) {
  377. width: 115px;
  378. }
  379. &:nth-child(5) {
  380. width: 160px;
  381. }
  382. &:nth-child(6) {
  383. width: 99px;
  384. }
  385. &:nth-child(7) {
  386. width: 91px;
  387. }
  388. }
  389. }
  390. ul {
  391. max-height: 160px;
  392. overflow: hidden;
  393. position: relative;
  394. li {
  395. height: 32px;
  396. line-height: 32px;
  397. position: relative;
  398. top: 0;
  399. transition: top 1s;
  400. -moz-transition: top 1s; /* Firefox 4 */
  401. -webkit-transition: top 1s; /* Safari and Chrome */
  402. -o-transition: top 1s; /* Opera */
  403. &.top {
  404. transition: top 0s;
  405. -moz-transition: top 0s; /* Firefox 4 */
  406. -webkit-transition: top 0s; /* Safari and Chrome */
  407. -o-transition: top 0s; /* Opera */
  408. }
  409. > div {
  410. overflow: hidden;
  411. text-overflow: ellipsis;
  412. white-space: nowrap;
  413. display: inline-block;
  414. text-align: center;
  415. padding: 0px 10px;
  416. &:first-child {
  417. color: #f57a2e;
  418. }
  419. &:nth-child(1) {
  420. width: 97px;
  421. }
  422. &:nth-child(2) {
  423. width: 164px;
  424. }
  425. &:nth-child(3) {
  426. width: 139px;
  427. }
  428. &:nth-child(4) {
  429. width: 115px;
  430. }
  431. &:nth-child(5) {
  432. width: 160px;
  433. }
  434. &:nth-child(6) {
  435. width: 99px;
  436. }
  437. &:nth-child(7) {
  438. width: 91px;
  439. }
  440. a {
  441. width: 64px;
  442. height: 22px;
  443. line-height: 22px;
  444. text-align: center;
  445. padding: 3px 5px;
  446. color: #fd3904;
  447. font-size: 12px;
  448. border-radius: 2px;
  449. border: 1px solid #fd3904;
  450. &:hover {
  451. border: 1px solid #fd3904;
  452. background-color: #fd3904;
  453. color: #fff;
  454. -moz-box-shadow: 0 3px 5px #f57a2e; /* 老的 Firefox */
  455. box-shadow: 0 3px 10px #f57a2e;
  456. }
  457. &.is-same {
  458. background: #cccbcb;
  459. border: none;
  460. color: #fff;
  461. -webkit-box-shadow: none;
  462. -moz-box-shadow: none;
  463. box-shadow: none;
  464. }
  465. }
  466. .is-say-price {
  467. color: #39ae05;
  468. img {
  469. margin-bottom: 2px;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. }
  476. .purchase {
  477. position: absolute;
  478. right: 88px;
  479. top: 170px;
  480. width: 114px;
  481. height: 32px;
  482. font-size: 16px;
  483. line-height: 32px;
  484. background-color: rgba(255, 255, 255, 0.98);
  485. box-shadow: 0px 1px 1px 1px rgba(244, 94, 2, 0.8);
  486. border-radius: 14px;
  487. opacity: 0.98;
  488. background-color: #fff;
  489. color: #f57a2e;
  490. text-align: center;
  491. font-weight: bold;
  492. &:hover{
  493. background-color: #FB6102;
  494. color: #fff;
  495. box-shadow: 0px 3px 10px #fd863d;
  496. }
  497. }
  498. }
  499. }
  500. </style>