gangweiList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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" :class="rowClassPc" 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"></iconGangwei>
  9. </template>
  10. </div>
  11. <div class="gangwei-row mta-hidden-sm cur-h5" :class="rowClassH5" 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"></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. },
  41. computed: {
  42. myListPc() {
  43. const count = this.pcNum;
  44. const row = Math.ceil(this.list.length / count);
  45. const result = [];
  46. for (let i = 1; i <= row; i++) {
  47. const start = (i - 1) * count;
  48. const end = (i * count)
  49. const curList = this.list.slice(start, end);
  50. if (curList.length < count) {
  51. curList.push({type: 'empty'});
  52. }
  53. result.push(curList)
  54. }
  55. return result;
  56. },
  57. myListH5() {
  58. const count = this.h5Num;
  59. const row = Math.ceil(this.list.length / count);
  60. const result = [];
  61. for (let i = 1; i <= row; i++) {
  62. const start = (i - 1) * count;
  63. const end = (i * count)
  64. const curList = this.list.slice(start, end)
  65. if (curList.length < count) {
  66. curList.push({type: 'empty'});
  67. }
  68. result.push(curList)
  69. }
  70. return result;
  71. },
  72. rowClassPc() {
  73. const obj = {
  74. 4: 'four',
  75. 3: 'three',
  76. 2: 'two'
  77. }
  78. return [`gangwei-icon-${obj[this.pcNum]}`]
  79. },
  80. rowClassH5() {
  81. const obj = {
  82. 4: 'four',
  83. 3: 'three',
  84. 2: 'two'
  85. }
  86. return [`gangwei-icon-${obj[this.h5Num]}`]
  87. },
  88. },
  89. components: {
  90. iconGangwei
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .client-gangwei-box {
  96. margin: 0 auto;
  97. .gangwei-row {
  98. width: 98%;
  99. display: flex;
  100. flex-direction: row;
  101. justify-content: center;
  102. margin-bottom: 119px;
  103. .my-icon {
  104. &:last-child {
  105. margin-right: 0 !important;
  106. }
  107. }
  108. }
  109. .gangwei-label {
  110. text-align: center;
  111. font-size: 30px;
  112. color: #333;
  113. margin-bottom: 160px;
  114. margin-top: 90px;
  115. font-weight: 800;
  116. }
  117. }
  118. .client-gangwei-box {
  119. @media (max-width: 768px){
  120. .gangwei-label {
  121. margin-bottom: 60px;
  122. }
  123. .gangwei-row {
  124. margin-bottom: 60px;
  125. }
  126. }
  127. }
  128. </style>