123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <template>
- <div class="custom" :class="'terminal' + terminal">
- <div class="rowLayout" v-if="componentContent.layoutType ==='L1' || componentContent.layoutType ==='L2' || componentContent.layoutType ==='L3' || componentContent.layoutType ==='L4'">
- <div class="customLayout" :style="{'padding':'0 ' + componentContent.pageSpacing + 'px','marginLeft':(-componentContent.imgClearance) +'px'}">
- <div class="ul clearfix" :class="'layout'+componentContent.layoutType">
- <div class='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'}">
- <a class="a-link" @click="jumpLink(item.linkObj)"><img class="img" :src="item.src" v-if="item.src" mode="widthFix"></a>
- </div>
- </div>
- </div>
- </div>
- <div v-else :style="{'padding':'0 ' + componentContent.pageSpacing + 'upx'}">
- <div class="boxLayout" :style="{'paddingBottom':componentContent.maxH !== 0?getItemValue(componentContent.maxH) + '%': '100%'}">
- <div class="boxLayoutInner">
- <div class="boxWarp">
- <div class="customLayout" :style="{'marginLeft':(-componentContent.imgClearance) +'px','top':(-componentContent.imgClearance) +'px'}">
- <div class="ul clearfix" :class="'layout'+componentContent.layoutType">
- <div class='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'}">
- <a class="a-link" @click="jumpLink(item.linkObj)"><img class="img" :src="item.src" v-if="item.src" mode="widthFix"></a>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import {funMixin} from '../config/mixin'
- export default {
- name: 'customComponent',
- mixins: [funMixin],
- data () {
- return {
- }
- },
- props: {
- terminal: {
- type: Number,
- default: 4
- },
- componentContent: {
- type: Object
- }
- },
- methods: {
- // 计算生成格子百分比
- getItemValue (val) {
- const density = parseInt(this.componentContent.density)
- if (val === 0 || density === 0) {
- return 0
- }
- return (val / density * 10000 / 100.00)// 小数点后两位百分比
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .custom{
- //width: 710upx;
- //margin: 0 auto;
- .boxLayout{
- position: relative;
- .boxLayoutInner{
- padding-bottom: 100%;
- position: absolute;
- width: 100%;
- left: 0;
- top: 0;
- }
- .boxWarp{
- position: absolute;
- width: 100%;
- height: 100%;
- left: 0;
- top: 0;
- overflow: hidden;
- }
- }
- .customLayout{
- position: relative;
- .ul{
- display: flex;
- flex-wrap: wrap;
- position: relative;
- }
- .li{
- box-sizing: border-box;
- .img{
- width: 100%;
- display: block;
- }
- }
- .layoutL1 .li{
- flex: 0 0 100%;
- }
- .layoutL2 .li{
- flex: 0 0 50%;
- }
- .layoutL3 .li{
- flex: 0 0 33.3%;
- }
- .layoutL4 .li{
- flex: 0 0 25%;
- }
- .layoutT2B2{
- padding-bottom: 100%;
- .li{
- width: 50%;
- height: 50%;
- position: absolute;
- .img{
- width: 100%;
- height: 100%;
- }
- &:nth-child(1){
- left: 0;
- top: 0;
- }
- &:nth-child(2){
- right: 0;
- top: 0;
- }
- &:nth-child(3){
- left: 0;
- bottom: 0;
- }
- &:nth-child(4){
- right: 0;
- bottom: 0;
- }
- }
- }
- .layoutL1R2{
- padding-bottom: 100%;
- .li{
- width: 50%;
- height: 50%;
- position: absolute;
- .img{
- width: 100%;
- height: 100%;
- }
- &:nth-child(1){
- height: 100%;
- left: 0;
- top: 0;
- }
- &:nth-child(2){
- right: 0;
- top: 0;
- }
- &:nth-child(3){
- right: 0;
- bottom: 0;
- }
- }
- }
- .layoutT1B2{
- padding-bottom: 100%;
- .li{
- width: 50%;
- height: 50%;
- position: absolute;
- .img{
- width: 100%;
- height: 100%;
- }
- &:nth-child(1){
- width: 100%;
- left: 0;
- top: 0;
- }
- &:nth-child(2){
- left: 0;
- bottom: 0;
- }
- &:nth-child(3){
- right: 0;
- bottom: 0;
- }
- }
- }
- .layoutL1T1B2{
- padding-bottom: 50%;
- .li{
- position: absolute;
- .img{
- width: 100%;
- height: 100%;
- }
- &:nth-child(1){
- width: 50%;
- height: 100%;
- left: 0;
- top: 0;
- }
- &:nth-child(2){
- right: 0;
- top: 0;
- width: 50%;
- height: 50%;
- }
- &:nth-child(3){
- left: 50%;
- bottom: 0;
- width: 25%;
- height: 50%;
- }
- &:nth-child(4){
- right: 0;
- bottom: 0;
- width: 25%;
- height: 50%;
- }
- }
- }
- .layoutaverage{
- padding-bottom: 100%;
- .li{
- position: absolute;
- .img{
- width: 100%;
- height: 100%;
- }
- }
- }
- // #ifdef MP
- .layoutaverage{
- padding-bottom: 91%;
- }
- // #endif
- }
- }
- </style>
|