FloorList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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" v-if="!isEmpty"></floor>
  6. <floor :floor="defaultFloors[1]" :isDefault="true" v-if="!isEmpty"></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. isEmpty: false
  48. }
  49. },
  50. computed: {
  51. floors () {
  52. return this.$store.state.floor.list
  53. },
  54. isProd () {
  55. return this.$store.state.option.url === 'http://www.usoftmall.com'
  56. },
  57. expandFloors () {
  58. let data = this.$store.state.floor.list_expand.data
  59. let _this = this
  60. for (let i = 0; i < data.length; i++) {
  61. let obj = {
  62. backGroundColor: '',
  63. body: '',
  64. hrefUrl: '',
  65. name: '',
  66. pictureUrl: '',
  67. size: '',
  68. price: '',
  69. currency: 'RMB'
  70. }
  71. if (data[i]) {
  72. obj.name = data[i].code
  73. obj.body = data[i].brandNameEn + '<br/>' + (data[i].kindNameCn || '其他')
  74. obj.hrefUrl = '/store/productDetail/' + data[i].batchCode
  75. obj.pictureUrl = '/images/floor/' + (this.isProd ? data[i].code : '2SD2704KT146') + '.png'
  76. obj.size = i % 3 === 0 ? 'medium' : 'small'
  77. obj.currency = data[i].currencyName
  78. obj.price = _this.getMinPrice(data[i].prices, data[i].currencyName)
  79. _this.defaultFloors[i < 6 ? 0 : 1].items.push(obj)
  80. } else {
  81. _this.isEmpty = true
  82. break
  83. }
  84. }
  85. return data
  86. }
  87. },
  88. methods: {
  89. getMinPrice: function (prices, currency) {
  90. for (let i = 0; i < prices.length; i++) {
  91. if (i === prices.length - 1) {
  92. return currency === 'RMB' ? prices[i].rMBPrice : prices[i].uSDPrice
  93. }
  94. }
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. @import '~assets/scss/variables';
  101. /*add*/
  102. .floor-list .container{
  103. padding: 0;
  104. }
  105. .floor-list {
  106. margin-bottom: $xlg-pad;
  107. }
  108. </style>