gangweiList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="client-gangwei-box">
  3. <h4 class="gangwei-label" v-if="label">{{label}}</h4>
  4. <div class="gangwei-row mta-hidden-xs" v-for="(rowList,index) in myListPc" :key="`pc-${index}`">
  5. <template v-for="(des,ind) in rowList">
  6. <!-- 站位div -->
  7. <div v-if="des.type === 'empty'"></div>
  8. <iconGangwei v-else class="my-icon" :key="ind" :des="des" :style="iconStylePc"></iconGangwei>
  9. </template>
  10. </div>
  11. <div class="gangwei-row mta-hidden-sm cur-h5" v-for="(rowList,index) in myListH5" :key="`h5${index}`">
  12. <template v-for="(des,ind) in rowList">
  13. <!-- 站位div -->
  14. <div v-if="des.type === 'empty'"></div>
  15. <iconGangwei v-else class="my-icon" :key="ind" :des="des" :style="iconStyleH5"></iconGangwei>
  16. </template>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import iconGangwei from "@/components/common/iconGangwei";
  22. export default {
  23. name: "gangweiList",
  24. props: {
  25. label: {
  26. type: String,
  27. },
  28. list: {
  29. type: Array,
  30. default: () => ([])
  31. },
  32. pcNum: {
  33. type: Number,
  34. default: 4
  35. },
  36. h5Num: {
  37. type: Number,
  38. default: 2
  39. },
  40. PcMargin: {
  41. type: Number,
  42. default: 308
  43. },
  44. H5Margin: {
  45. type: Number,
  46. default: 120
  47. }
  48. },
  49. computed: {
  50. myListPc() {
  51. const count = this.pcNum;
  52. const row = Math.ceil(this.list.length / count);
  53. const result = [];
  54. for (let i = 1; i <= row; i++) {
  55. const start = (i - 1) * count;
  56. const end = (i * count)
  57. const curList = this.list.slice(start, end);
  58. if (curList.length < count) {
  59. curList.push({type: 'empty'});
  60. }
  61. result.push(curList)
  62. }
  63. return result;
  64. },
  65. myListH5() {
  66. const count = this.h5Num;
  67. const row = Math.ceil(this.list.length / count);
  68. const result = [];
  69. for (let i = 1; i <= row; i++) {
  70. const start = (i - 1) * count;
  71. const end = (i * count)
  72. const curList = this.list.slice(start, end)
  73. if (curList.length < count) {
  74. curList.push({type: 'empty'});
  75. }
  76. result.push(curList)
  77. }
  78. return result;
  79. },
  80. iconStylePc() {
  81. return `margin-right: ${this.PcMargin}px`
  82. },
  83. iconStyleH5() {
  84. return `margin-right: ${this.H5Margin}%`
  85. }
  86. },
  87. components: {
  88. iconGangwei
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .client-gangwei-box {
  94. margin: 0 auto;
  95. .gangwei-row {
  96. width: 98%;
  97. display: flex;
  98. flex-direction: row;
  99. justify-content: center;
  100. margin-bottom: 119px;
  101. .my-icon {
  102. &:last-child {
  103. margin-right: 0 !important;
  104. }
  105. }
  106. }
  107. .gangwei-label {
  108. text-align: center;
  109. font-size: 30px;
  110. color: #333;
  111. margin-bottom: 160px;
  112. margin-top: 90px;
  113. font-weight: 800;
  114. }
  115. }
  116. .client-gangwei-box {
  117. @media (max-width: 768px){
  118. .gangwei-label {
  119. margin-bottom: 60px;
  120. }
  121. .gangwei-row {
  122. margin-bottom: 60px;
  123. }
  124. }
  125. }
  126. </style>