FloorList.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="floor-list">
  3. <div class="container">
  4. <floor-bar :floors="floors"></floor-bar>
  5. <floor :floor="defaultFloors[0]" :isDefault="true"></floor>
  6. <floor :floor="defaultFloors[1]" :isDefault="true"></floor>
  7. <floor v-for="(floor, index) in floors.data" :floor="floor" :isDefault="false" :key="index"></floor>
  8. </div>
  9. <span v-text="expandFloors"></span>
  10. </div>
  11. </template>
  12. <script>
  13. import Floor from './Floor.vue'
  14. import FloorBar from './FloorBar.vue'
  15. export default {
  16. name: 'floor-list',
  17. components: {
  18. Floor,
  19. FloorBar
  20. },
  21. data () {
  22. return {
  23. defaultFloors: [
  24. {
  25. items: [
  26. {
  27. backGroundColor: '',
  28. body: '',
  29. hrefUrl: '/store/33069557578d44e69bd91ad12d28a8d4',
  30. pictureUrl: '/images/floor/banner1.jpg',
  31. size: 'large'
  32. }
  33. ]
  34. },
  35. {
  36. items: [
  37. {
  38. backGroundColor: '',
  39. body: '',
  40. hrefUrl: '/store/33069557578d44e69bd91ad12d28a8d4',
  41. pictureUrl: '/images/floor/banner2.jpg',
  42. size: 'large'
  43. }
  44. ]
  45. }
  46. ]
  47. }
  48. },
  49. computed: {
  50. floors () {
  51. return this.$store.state.floor.list
  52. },
  53. isProd () {
  54. return this.$store.state.option.url === 'http://www.usoftmall.com'
  55. },
  56. expandFloors () {
  57. let data = this.$store.state.floor.list_expand.data
  58. let _this = this
  59. for (let i = 0; i < data.length; i++) {
  60. let obj = {
  61. backGroundColor: '',
  62. body: '',
  63. hrefUrl: '',
  64. name: '',
  65. pictureUrl: '',
  66. size: '',
  67. price: '',
  68. currency: 'RMB'
  69. }
  70. if (data[i]) {
  71. obj.name = data[i].code
  72. obj.body = data[i].brandNameEn + '<br/>' + (data[i].kindNameCn || '其他')
  73. obj.hrefUrl = '/store/productDetail/' + data[i].batchCode
  74. obj.pictureUrl = '/images/floor/' + (this.isProd ? data[i].code : '2SD2704KT146') + '.png'
  75. obj.size = i % 3 === 0 ? 'medium' : 'small'
  76. obj.currency = data[i].currencyName
  77. obj.price = _this.getMinPrice(data[i].prices, data[i].currencyName)
  78. _this.defaultFloors[i < 6 ? 0 : 1].items.push(obj)
  79. }
  80. }
  81. return data
  82. }
  83. },
  84. methods: {
  85. getMinPrice: function (prices, currency) {
  86. for (let i = 0; i < prices.length; i++) {
  87. if (i === prices.length - 1) {
  88. return currency === 'RMB' ? prices[i].rMBPrice : prices[i].uSDPrice
  89. }
  90. }
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. @import '~assets/scss/variables';
  97. /*add*/
  98. .floor-list .container{
  99. padding: 0;
  100. }
  101. .floor-list {
  102. margin-bottom: $xlg-pad;
  103. }
  104. </style>