custom.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="custom" :class="'terminal' + terminal">
  3. <div class="rowLayout" v-if="componentContent.layoutType ==='L1' || componentContent.layoutType ==='L2' || componentContent.layoutType ==='L3' || componentContent.layoutType ==='L4'">
  4. <div class="customLayout" :style="{'padding':'0 ' + componentContent.pageSpacing + 'px','marginLeft':(-componentContent.imgClearance) +'px'}">
  5. <ul class="clearfix" :class="'layout'+componentContent.layoutType">
  6. <li v-for="(item,index) of componentContent.imgData" :key="index" :style="{'width':getItemValue(item.width) + '%','height':getItemValue(item.height) + '%','left':getItemValue(item.left) + '%','top':getItemValue(item.top) + '%','paddingLeft':componentContent.imgClearance +'px'}">
  7. <a class="a-link" @click="jumpLink(item.linkObj)"><img class="img" :src="item.src" v-if="item.src"></a>
  8. </li>
  9. </ul>
  10. </div>
  11. </div>
  12. <div v-else :style="{'padding':'0 ' + componentContent.pageSpacing + 'px'}">
  13. <div class="boxLayout" :style="{'paddingBottom':componentContent.maxH !== 0?getItemValue(componentContent.maxH) + '%': '100%'}">
  14. <div class="boxLayoutInner">
  15. <div class="boxWarp">
  16. <div class="customLayout" :style="{'marginLeft':(-componentContent.imgClearance) +'px','top':(-componentContent.imgClearance) +'px'}">
  17. <ul class="clearfix" :class="'layout'+componentContent.layoutType">
  18. <li v-for="(item,index) of componentContent.imgData" :key="index" :style="{'width':getItemValue(item.width) + '%','height':getItemValue(item.height) + '%','left':getItemValue(item.left) + '%','top':getItemValue(item.top) + '%','padding':componentContent.imgClearance +'px 0 0 ' + componentContent.imgClearance +'px'}">
  19. <a class="a-link" @click="jumpLink(item.linkObj)"><img class="img" :src="item.src" v-if="item.src"></a>
  20. </li>
  21. </ul>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import {funMixin} from '../config/mixin'
  31. export default {
  32. name: 'customComponent',
  33. mixins: [funMixin],
  34. data () {
  35. return {
  36. }
  37. },
  38. props: {
  39. terminal: {
  40. type: Number,
  41. default: 4
  42. },
  43. componentContent: {
  44. type: Object
  45. }
  46. },
  47. methods: {
  48. // 计算生成格子百分比
  49. getItemValue (val) {
  50. const density = parseInt(this.componentContent.density)
  51. if (val === 0 || density === 0) {
  52. return 0
  53. }
  54. return (val / density * 10000 / 100.00)// 小数点后两位百分比
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .custom{
  61. .boxLayout{
  62. position: relative;
  63. .boxLayoutInner{
  64. padding-bottom: 100%;
  65. position: absolute;
  66. width: 100%;
  67. left: 0;
  68. top: 0;
  69. }
  70. .boxWarp{
  71. position: absolute;
  72. width: 100%;
  73. height: 100%;
  74. left: 0;
  75. top: 0;
  76. overflow: hidden;
  77. }
  78. }
  79. .customLayout{
  80. position: relative;
  81. ul{
  82. display: flex;
  83. flex-wrap: wrap;
  84. position: relative;
  85. }
  86. li{
  87. .img{
  88. width: 100%;
  89. display: block;
  90. }
  91. }
  92. .layoutL1 li{
  93. flex: 0 0 100%;
  94. }
  95. .layoutL2 li{
  96. flex: 0 0 50%;
  97. }
  98. .layoutL3 li{
  99. flex: 0 0 33.3%;
  100. }
  101. .layoutL4 li{
  102. flex: 0 0 25%;
  103. }
  104. .layoutT2B2{
  105. padding-bottom: 100%;
  106. li{
  107. width: 50%;
  108. height: 50%;
  109. position: absolute;
  110. .img{
  111. width: 100%;
  112. height: 100%;
  113. }
  114. &:nth-child(1){
  115. left: 0;
  116. top: 0;
  117. }
  118. &:nth-child(2){
  119. right: 0;
  120. top: 0;
  121. }
  122. &:nth-child(3){
  123. left: 0;
  124. bottom: 0;
  125. }
  126. &:nth-child(4){
  127. right: 0;
  128. bottom: 0;
  129. }
  130. }
  131. }
  132. .layoutL1R2{
  133. padding-bottom: 100%;
  134. li{
  135. width: 50%;
  136. height: 50%;
  137. position: absolute;
  138. .img{
  139. width: 100%;
  140. height: 100%;
  141. }
  142. &:nth-child(1){
  143. height: 100%;
  144. left: 0;
  145. top: 0;
  146. }
  147. &:nth-child(2){
  148. right: 0;
  149. top: 0;
  150. }
  151. &:nth-child(3){
  152. right: 0;
  153. bottom: 0;
  154. }
  155. }
  156. }
  157. .layoutT1B2{
  158. padding-bottom: 100%;
  159. li{
  160. width: 50%;
  161. height: 50%;
  162. position: absolute;
  163. .img{
  164. width: 100%;
  165. height: 100%;
  166. }
  167. &:nth-child(1){
  168. width: 100%;
  169. left: 0;
  170. top: 0;
  171. }
  172. &:nth-child(2){
  173. left: 0;
  174. bottom: 0;
  175. }
  176. &:nth-child(3){
  177. right: 0;
  178. bottom: 0;
  179. }
  180. }
  181. }
  182. .layoutL1T1B2{
  183. padding-bottom: 50%;
  184. li{
  185. position: absolute;
  186. .img{
  187. width: 100%;
  188. height: 100%;
  189. }
  190. &:nth-child(1){
  191. width: 50%;
  192. height: 100%;
  193. left: 0;
  194. top: 0;
  195. }
  196. &:nth-child(2){
  197. right: 0;
  198. top: 0;
  199. width: 50%;
  200. height: 50%;
  201. }
  202. &:nth-child(3){
  203. left: 50%;
  204. bottom: 0;
  205. width: 25%;
  206. height: 50%;
  207. }
  208. &:nth-child(4){
  209. right: 0;
  210. bottom: 0;
  211. width: 25%;
  212. height: 50%;
  213. }
  214. }
  215. }
  216. .layoutaverage{
  217. padding-bottom: 100%;
  218. li{
  219. position: absolute;
  220. .img{
  221. width: 100%;
  222. height: 100%;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. </style>