FloorList.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. </div>
  10. </template>
  11. <script>
  12. import Floor from './Floor.vue'
  13. import FloorBar from './FloorBar.vue'
  14. export default {
  15. name: 'floor-list',
  16. components: {
  17. Floor,
  18. FloorBar
  19. },
  20. data () {
  21. return {
  22. defaultFloors: [
  23. {
  24. items: [
  25. {
  26. backGroundColor: '',
  27. body: '',
  28. hrefUrl: '',
  29. pictureUrl: '/images/floor/banner1.jpg',
  30. size: 'large'
  31. }
  32. ]
  33. },
  34. {
  35. items: [
  36. {
  37. backGroundColor: '',
  38. body: '',
  39. hrefUrl: 'https://www.usoftmall.com/product/kind/11',
  40. pictureUrl: '/images/floor/banner2.jpg',
  41. size: 'large'
  42. }
  43. ]
  44. }
  45. ]
  46. }
  47. },
  48. // mounted () {
  49. // this.$http.get('/api/floors/home')
  50. // .then(response => {
  51. // this.floors = response
  52. // })
  53. // }
  54. computed: {
  55. floors () {
  56. return this.$store.state.floor.list
  57. }
  58. },
  59. created () {
  60. let arr = []
  61. this.$http.post('api/commodity/detail', arr).then(response => {
  62. let data = response.data
  63. // {
  64. // backGroundColor: '',
  65. // body: 'Rohm<br>晶体管',
  66. // hrefUrl: 'https://www.usoftmall.com/store/33069557578d44e69bd91ad12d28a8d4/BT2018012500000141',
  67. // name: 'RHU002N06T106',
  68. // pictureUrl: '/images/floor/RHU002N06T106.png',
  69. // size: 'medium',
  70. // price: 1.111111,
  71. // currency: 'RMB'
  72. // }
  73. let obj = {
  74. backGroundColor: '',
  75. body: '',
  76. hrefUrl: '',
  77. name: '',
  78. pictureUrl: '',
  79. size: '',
  80. price: '',
  81. currency: 'RMB'
  82. }
  83. for (let i = 0; i < data.length; i++) {
  84. if (data[i]) {
  85. obj.name = data[i].code
  86. obj.body = data[i].brandNameEn + '<br/>' + data[i].kindNameCn
  87. obj.hrefUrl = 'https://www.usoftmall.com/store/productDetail/' + data[i].batchCode
  88. obj.pictureUrl = '/images/floor/' + data[i].code + '.png'
  89. obj.size = i % 3 === 0 ? 'medium' : 'small'
  90. obj.currency = data[i].currencyName
  91. obj.price = this.getMinPrice(data[i].prices, data[i].currencyName)
  92. this.defaultFloors.items[i < 6 ? 0 : 1].append(obj)
  93. }
  94. }
  95. })
  96. },
  97. methods: {
  98. getMinPrice: function (prices, currency) {
  99. for (let i = 0; i < prices.length; i++) {
  100. if (i === prices.length - 1) {
  101. return currency === 'RMB' ? prices[i].rMBPrice : prices[i].uSDPrice
  102. }
  103. }
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. @import '~assets/scss/variables';
  110. /*add*/
  111. .floor-list .container{
  112. padding: 0;
  113. }
  114. .floor-list {
  115. margin-bottom: $xlg-pad;
  116. }
  117. </style>