imgCardLv1.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. <em></em>
  23. <p class="card-des" v-if="description">{{description}}</p>
  24. <div class="mta-card-row" v-for="(rowList,index) in tagesH5" :key="`h5-${index}`">
  25. <template v-for="(des,ind) in rowList">
  26. <!-- 站位div -->
  27. <span v-if="des.empty" :key="ind"></span>
  28. <span :key="ind" class="mta-card-row-item"><i></i><span>{{des.value}}</span></span>
  29. </template>
  30. </div>
  31. <slot></slot>
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. export default {
  38. name: "imgCardLv1",
  39. props: {
  40. option: {
  41. type: Object,
  42. required: true,
  43. },
  44. colPc: {
  45. type: Number,
  46. default: 3
  47. },
  48. colH5: {
  49. type: Number,
  50. default: 3
  51. }
  52. },
  53. computed: {
  54. img() {
  55. return {url: this.option.img.url, order: this.option.img.order}
  56. },
  57. title() {
  58. return this.option.content.title;
  59. },
  60. description() {
  61. return this.option.content.des;
  62. },
  63. contentOrder() {
  64. return this.option.content.order;
  65. },
  66. tagesPc() {
  67. const count = this.colPc;
  68. const list = this.option.content.list;
  69. const row = Math.ceil(list.length / count);
  70. const result = [];
  71. for (let i = 1; i <= row; i++) {
  72. const start = (i - 1) * count;
  73. const end = (i * count)
  74. const curList = list.slice(start, end);
  75. if (curList.length < count) {
  76. curList.push({type: 'empty'});
  77. }
  78. result.push(curList)
  79. }
  80. return result;
  81. },
  82. tagesH5() {
  83. const count = this.colH5;
  84. const list = this.option.content.list;
  85. const row = Math.ceil(list.length / count);
  86. const result = [];
  87. for (let i = 1; i <= row; i++) {
  88. const start = (i - 1) * count;
  89. const end = (i * count)
  90. const curList = list.slice(start, end);
  91. if (curList.length < count) {
  92. curList.push({type: 'empty'});
  93. }
  94. result.push(curList)
  95. }
  96. return result;
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .mta-card-lv1 {
  103. margin: 0 auto 120px;
  104. .mta-card-content-pc {
  105. display: flex;
  106. img {
  107. width: 480px;
  108. height: 370px;
  109. }
  110. }
  111. .img-left {
  112. img {
  113. margin-left: 100px;
  114. }
  115. }
  116. .img-right {
  117. img {
  118. margin-right: 100px;
  119. }
  120. }
  121. .card-info {
  122. h5 {
  123. font-size: 24px;
  124. font-weight: 800;
  125. text-align: left;
  126. color: #333;
  127. margin-top: 40px;
  128. margin-bottom: 30px;
  129. }
  130. .card-des {
  131. font-size: 14px;
  132. line-height: 24px;
  133. color: #333;
  134. font-weight: 500;
  135. text-align: left;
  136. margin-bottom: 30px;
  137. }
  138. }
  139. .mta-card-row-item {
  140. font-size: 14px;
  141. font-weight: 500;
  142. color: #333;
  143. width: 160px;
  144. margin-bottom: 24px;
  145. i {
  146. display: inline-block;
  147. width:8px;
  148. height: 8px;
  149. background: #00b96b;
  150. margin-right: 13px;
  151. border-radius: 50%;
  152. }
  153. span {
  154. line-height: 24px;
  155. }
  156. }
  157. .mta-card-row {
  158. display: flex;
  159. }
  160. @media (max-width: 768px) {
  161. margin: 0 auto 60px;
  162. .mta-card-content-h5 {
  163. img {
  164. width: 100%;
  165. text-align: center;
  166. }
  167. .card-info {
  168. width: 100%;
  169. h5 {
  170. font-size: 16px;
  171. margin: 20px 0 10px;
  172. }
  173. em {
  174. width: 35px;
  175. height: 3px;
  176. background: #00b96b;
  177. display: block;
  178. margin-bottom: 20px;
  179. }
  180. .card-des {
  181. font-size: 14px;
  182. margin: 20px 0 10px;
  183. text-align: justify;
  184. line-height: 22px;
  185. }
  186. }
  187. .mta-card-row {
  188. margin-bottom: 10px;
  189. > span {
  190. width: 44%;
  191. font-size: 14px;
  192. margin: 0 3%;
  193. }
  194. }
  195. }
  196. }
  197. }
  198. </style>