dl_mer_uniapp/components/homeIndex/hotSpot.vue

271 lines
7.8 KiB
Vue
Raw Permalink Normal View History

2025-03-04 16:03:38 +08:00
<template>
<!-- 热区+图片魔方 -->
<view class="mobile-page" v-if="dataConfig" :style="[boxStyle]">
<view class="advert">
<!-- 单图/热区布局 -->
<template v-if="style === 0">
<view class="advertItem01 acea-row hotspot" v-for="(item, index) in picList" :key="index">
<image :src="item.image" mode="widthFix" v-if="item.image"
@click="dataConfig.checkoutConfig.hotspot.length?'':goDetail(item)"
:style="{borderRadius: (dataConfig.bgStyle.val * 2)+'rpx'}"></image>
<view v-for="(item, index) in dataConfig.checkoutConfig.hotspot" :key="index" :style="{
top: `${item.starY}rpx`,
left: `${item.starX}rpx`,
width: `${item.areaWidth}rpx`,
height: `${item.areaHeight}rpx`,
}" class="area" @click="goDetail(item)"></view>
</view>
</template>
<!-- 两图布局 -->
<view class="advertItem02 acea-row" v-if="style === 1" :style="[imgBoxStyle]">
<view class="item" v-for="(item, index) in picList" :key="index" :style="[twoImgStyle]">
<image :src="item.image" v-if="item.image" @click="goDetail(item)"
:style="{borderRadius: (dataConfig.bgStyle.val * 2)+'rpx'}"></image>
<view class="empty-box" v-else></view>
</view>
</view>
<!-- 三图布局 -->
<view class="advertItem02 advertItem03 acea-row" v-if="style === 2" :style="[imgBoxStyle]">
<view class="item" v-for="(item, index) in picList" :key="index" :style="[thrOneImgStyle]">
<image :src="item.image" v-if="item.image" @click="goDetail(item)"
:style="{borderRadius: (dataConfig.bgStyle.val * 2)+'rpx'}"></image>
<view class="empty-box" v-else></view>
</view>
</view>
<!-- 第二种 三张图布局-->
<view class="advertItem04 acea-row" v-if="style === 3"
:style="{ display: 'flex' , 'justify-content': 'space-between' }">
<view class="item" :style="{ width: (750 - 2*igConfig - 4 * prConfig) / 2 + 'rpx'}">
<image :src="picList[0].image" v-if="picList[0].image" @click="goDetail(picList[0])"
:style="{borderRadius: (dataConfig.bgStyle.val * 2)+'rpx'}"></image>
<view class="empty-box" v-else></view>
</view>
<view class="item" :style="{ width: (750 - 2*igConfig - 4 * prConfig) / 2 + 'rpx'}">
<view class="pic" :style="{ height: (379 - 2*igConfig) / 2 + 'rpx',width:'100%'}">
<image :src="picList[1].image" v-if="picList[1].image" @click="goDetail(picList[1])"
:style="{borderRadius: (dataConfig.bgStyle.val * 2)+'rpx'}"></image>
<view class="empty-box" v-else></view>
</view>
<view class="pic"
:style="{ height: (379 - 2*igConfig) / 2 + 'rpx','margin-top':2*igConfig+'rpx',width:'100%'}">
<image :src="picList[2].image" v-if="picList[2].image" @click="goDetail(picList[2])"
:style="{borderRadius: (dataConfig.bgStyle.val * 2)+'rpx'}"></image>
<view class="empty-box" v-else></view>
</view>
</view>
</view>
<!-- 四图布局 -->
<view class="advertItem02 advertItem05 acea-row" v-if="style === 4" :style="[imgBoxStyle]">
<view class="item" v-for="(item, index) in picList" :key="index" :style="[forOneImgStyle]">
<image :src="item.image" mode="widthFix" v-if="item.image" @click="goDetail(item)"
:style="{borderRadius: (dataConfig.bgStyle.val * 2)+'rpx'}"></image>
<view class="empty-box" v-else></view>
</view>
</view>
<view class="advertItem06 acea-row" v-if="style === 5" :style="[imgBoxStyle]">
<view class="item" v-for="(item, index) in picList" :key="index"
:style="{ width: (750 - 2*igConfig - 4 * prConfig) / 2 + 'rpx' ,height:(750 - 2*igConfig - 4 * prConfig) / 2 + 'rpx','margin-top':index ===2||index===3? igConfig+'px':'0px'}">
<image :src="item.image" v-if="item.image"
:style="{borderRadius: (dataConfig.bgStyle.val * 2)+'rpx'}" @click="goDetail(item)"></image>
<view class="empty-box" v-else></view>
</view>
</view>
</view>
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
export default {
name: 'hotSpot',
props: {
dataConfig: {
type: Object,
default: () => {}
},
},
data() {
return {
picList: this.dataConfig.picStyle.picList,
style: this.dataConfig.tabConfig.tabVal,
prConfig: this.dataConfig.lrConfig.val,
igConfig: this.dataConfig.igConfig.val
};
},
computed: {
//最外层盒子的样式
boxStyle() {
return {
borderRadius: this.dataConfig.bgStyle.val * 2 + 'rpx',
backgroundImage: `linear-gradient(${this.dataConfig.bgColor.color[0].item}, ${this.dataConfig.bgColor.color[1].item})`,
margin: this.dataConfig.mbConfig.val * 2 + 'rpx' + ' ' + this.dataConfig.lrConfig.val * 2 + 'rpx' +
' ' + 0,
padding: this.dataConfig.upConfig.val * 2 + 'rpx' + ' ' + '0' + ' ' + this.dataConfig.downConfig.val *
2 + 'rpx'
}
},
// 两张图片 图片间距样式
twoImgStyle() {
return {
width: (750 - 2 * this.igConfig - 4 * this.prConfig) / 2 + 'rpx',
height: (750 - 2 * this.igConfig - 4 * this.prConfig) / 2 + 'rpx',
}
},
// 第一种 三张图片间距样式
thrOneImgStyle() {
return {
width: (750 - 4 * this.igConfig - 4 * this.prConfig) / 3 + 'rpx',
height: (750 - 4 * this.igConfig - 4 * this.prConfig) / 3 + 'rpx',
}
},
// 第一种四张图片布局
forOneImgStyle() {
return {
width: (750 - 6 * this.igConfig - 4 * this.prConfig) / 4 + 'rpx',
}
},
// 第二种四张图片布局
forTwoImgStyle() {
return {
width: (750 - 2 * this.igConfig - 4 * this.prConfig) / 2 + 'rpx',
height: (750 - 2 * this.igConfig - 4 * this.prConfig) / 2 + 'rpx',
}
},
imgBoxStyle() {
return {
display: this.igConfig ? 'flex' : '',
'justify-content': this.igConfig ? 'space-between' : ''
}
}
},
methods: {
//替换安全域名
setDomain: function(url) {
url = url ? url.toString() : '';
//本地调试打开,生产请注销
if (url.indexOf("https://") > -1) return url;
else return url.replace('http://', 'https://');
},
goDetail(item) {
this.$util.navigateTo(item.link);
}
}
}
</script>
<style lang="scss" scoped>
.mobile-page {
.advert {
.advertItem01 {
width: 100%;
height: 100%;
.empty-box {
width: 100%;
height: auto;
}
image {
width: 100%;
height: 100%;
}
}
.advertItem02 {
width: 100%;
.item {
width: 50%;
height: auto;
image {
width: 100%;
height: 100%;
}
.empty-box {
width: 100%;
height: auto;
}
}
}
.advertItem03 {
.item {
width: 33.3333%;
height: auto;
.empty-box {
width: 100%;
height: auto;
}
}
}
.advertItem04 {
.item {
width: 50%;
height: auto;
.empty-box {
width: 100%;
height: 100%;
}
image {
width: 100%;
height: 100%;
}
.pic {
width: 100%;
height: auto;
}
}
}
.advertItem05 {
.item {
width: 25%;
.empty-box {
width: 100%;
height: auto;
}
}
}
.advertItem06 {
.item {
width: 50%;
image {
width: 100%;
height: 100%;
}
.empty-box {
width: 100%;
height: 100%;
}
}
}
}
}
.hotspot {
position: relative;
.area {
position: absolute;
}
}
</style>