gangweiList.vue 3.1 KB

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