imgCardLv1.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="mta-card-lv1">
  3. <div class="mta-card-content-pc mta-hidden-xs" :class="[img.order>contentOrder ? 'img-left': 'img-right']">
  4. <img :style="`order:${img.order}`" :src="img.url">
  5. <div class="card-info" :style="`order: ${contentOrder}`">
  6. <h5>{{title}}</h5>
  7. <p class="card-des">{{description}}</p>
  8. <div class="mta-card-row" v-for="(rowList,index) in tagesPc" :key="`pc-${index}`">
  9. <template v-for="(des,ind) in rowList">
  10. <!-- 站位div -->
  11. <span class="mta-card-row-item" v-if="des.type == 'empty'" :key="ind"></span>
  12. <span v-else class="mta-card-row-item" :key="ind"><i></i><span>{{des.value}}</span></span>
  13. </template>
  14. </div>
  15. <slot></slot>
  16. </div>
  17. </div>
  18. <div class="mta-card-content-h5 mta-hidden-sm">
  19. <img :src="img.url">
  20. <div class="card-info">
  21. <h5>{{title}}</h5>
  22. <p v-if="description">{{description}}</p>
  23. <div class="mta-card-row" v-for="(rowList,index) in tagesH5" :key="`h5-${index}`">
  24. <template v-for="(des,ind) in rowList">
  25. <!-- 站位div -->
  26. <span v-if="des.empty" :key="ind"></span>
  27. <span :key="ind"><i></i><span>{{des.value}}</span></span>
  28. </template>
  29. </div>
  30. <slot></slot>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. export default {
  37. name: "imgCardLv1",
  38. props: {
  39. option: {
  40. type: Object,
  41. required: true,
  42. },
  43. colPc: {
  44. type: Number,
  45. default: 3
  46. },
  47. colH5: {
  48. type: Number,
  49. default: 3
  50. }
  51. },
  52. computed: {
  53. img() {
  54. return {url: this.option.img.url, order: this.option.img.order}
  55. },
  56. title() {
  57. return this.option.content.title;
  58. },
  59. description() {
  60. return this.option.content.des;
  61. },
  62. contentOrder() {
  63. return this.option.content.order;
  64. },
  65. tagesPc() {
  66. const count = this.colPc;
  67. const list = this.option.content.list;
  68. const row = Math.ceil(list.length / count);
  69. const result = [];
  70. for (let i = 1; i <= row; i++) {
  71. const start = (i - 1) * count;
  72. const end = (i * count)
  73. const curList = list.slice(start, end);
  74. if (curList.length < count) {
  75. curList.push({type: 'empty'});
  76. }
  77. result.push(curList)
  78. }
  79. return result;
  80. },
  81. tagesH5() {
  82. const count = this.colH5;
  83. const list = this.option.content.list;
  84. const row = Math.ceil(list.length / count);
  85. const result = [];
  86. for (let i = 1; i <= row; i++) {
  87. const start = (i - 1) * count;
  88. const end = (i * count)
  89. const curList = list.slice(start, end);
  90. if (curList.length < count) {
  91. curList.push({type: 'empty'});
  92. }
  93. result.push(curList)
  94. }
  95. return result;
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .mta-card-lv1 {
  102. margin: 0 auto 120px;
  103. .mta-card-content-pc {
  104. display: flex;
  105. img {
  106. width: 480px;
  107. height: 370px;
  108. }
  109. }
  110. .img-left {
  111. img {
  112. margin-left: 100px;
  113. }
  114. }
  115. .img-right {
  116. img {
  117. margin-right: 100px;
  118. }
  119. }
  120. .card-info {
  121. h5 {
  122. font-size: 24px;
  123. font-weight: 800;
  124. text-align: left;
  125. color: #333;
  126. margin-top: 40px;
  127. margin-bottom: 30px;
  128. }
  129. .card-des {
  130. font-size: 14px;
  131. color: #333;
  132. font-weight: 500;
  133. text-align: left;
  134. margin-bottom: 30px;
  135. }
  136. }
  137. .mta-card-row-item {
  138. font-size: 14px;
  139. font-weight: 500;
  140. color: #333;
  141. width: 160px;
  142. margin-bottom: 24px;
  143. i {
  144. display: inline-block;
  145. width:13px;
  146. height: 13px;
  147. background: #00b96b;
  148. margin-right: 13px;
  149. border-radius: 50%;
  150. }
  151. span {
  152. line-height: 24px;
  153. }
  154. }
  155. .mta-card-row {
  156. display: flex;
  157. }
  158. }
  159. </style>