FloorList.vue 15 KB

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