gangweiList.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="client-gangwei-box">
  3. <div class="client-container">
  4. <h4 class="gangwei-title" v-if="label">{{label}}</h4>
  5. <div class="gangwei-cp-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 :key="ind" :des="des" ></iconGangwei>
  10. </template>
  11. </div>
  12. <div class="gangwei-phone-row mta-hidden-sm" :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 :key="ind" :des="des" ></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">
  97. .client-gangwei-box {
  98. // 标题
  99. .gangwei-title {font-size: 30px;color: #333;font-weight: 800;text-align: center;margin: 92px 0 105px;}
  100. /**************** pc样式 ****************/
  101. .gangwei-cp-row{display: flex;flex-wrap: wrap;}
  102. // 图标列表
  103. .gangwei-icon-three,.gangwei-icon-four{
  104. text-align: center;
  105. .gangwei-icon{margin-bottom: 116px}
  106. .gangwei-icon-content{
  107. display: inline-block;margin: 0 auto;text-align: center;
  108. i{width:164px;height:164px;margin:0 auto 22px;display: block;
  109. background-repeat: no-repeat;background-position: center;background-size: contain;}
  110. p{font-size: 18px;font-weight: 800;color: #333333;}
  111. }
  112. }
  113. // 一行三个
  114. .gangwei-icon-three{
  115. .gangwei-icon{width: 33.33%;}
  116. }
  117. // 一行四个
  118. .gangwei-icon-four{
  119. .gangwei-icon{width: 25%;}
  120. }
  121. /**************** 手机样式 ****************/
  122. @media (max-width: 768px){
  123. // 标题
  124. .gangwei-title {font-size: 18px;margin: 50px 0 26px;}
  125. .gangwei-phone-row{display: flex;flex-wrap: wrap;}
  126. .gangwei-icon-two{
  127. text-align: center;
  128. .gangwei-icon{width: 50%;margin-bottom: 25px;}
  129. .gangwei-icon-content{
  130. display: inline-block;margin: 0 auto;text-align: center;
  131. i{width:75px;height:75px;margin:0 auto 10px;display: block;
  132. background-repeat: no-repeat;background-position: center;background-size: contain;}
  133. p{font-size: 16px;font-weight: normal;color: #333333;}
  134. }
  135. }
  136. }
  137. }
  138. </style>