custom.vue 6.3 KB

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