275 lines
6.1 KiB
Vue
275 lines
6.1 KiB
Vue
<template>
|
|
<view :style="componentStyle">
|
|
<scroll-view :class="['image-nav', value.showStyle == 'fixed' ? 'fixed-layout' : value.showStyle]"
|
|
:scroll-x="value.showStyle == 'singleSlide'">
|
|
<view class="uni-scroll-view-content">
|
|
<view v-for="(item, index) in value.list" :key="index" :class="['image-nav-item', value.mode]"
|
|
style="margin-right: 28rpx;">
|
|
<!-- 图片部分 -->
|
|
<view v-if="value.mode != 'text'" class="image-img" :style="{
|
|
'font-size': (value.imageSize * 2 + 'rpx') + ';',
|
|
'width': (item.imgWidth / 2 + 'rpx') + ';',
|
|
'height': (item.imgHeight / 2 + 'rpx') + ';'
|
|
}">
|
|
<image v-if="item.link.wap_url" :style="{
|
|
'width': (item.imgWidth / 2 + 'rpx') + ';',
|
|
'height': (item.imgHeight / 2 + 'rpx') + ';'
|
|
}" :src="$util.img(item.imageUrl) || $util.img('public/uniapp/default_img/goods.png')"
|
|
:show-menu-by-longpress="true" @tap="redirectTo(item.link)"></image>
|
|
<image v-else :style="{
|
|
'width': (item.imgWidth / 2 + 'rpx') + ';',
|
|
'height': (item.imgHeight / 2 + 'rpx') + ';'
|
|
}" :src="$util.img(item.imageUrl) || $util.img('public/uniapp/default_img/goods.png')"
|
|
:show-menu-by-longpress="true" @tap="previewImg(item.imageUrl)"></image>
|
|
</view>
|
|
|
|
<!-- 文字部分 -->
|
|
<text class="image-text" :style="{
|
|
'width': (item.imgWidth / 2 + 'rpx') + ';',
|
|
'font-size': (value.font.size * 2 + 'rpx') + ';',
|
|
'font-weight': value.font.weight + ';',
|
|
'color': value.font.color + ';'
|
|
}">{{ item.title }}</text>
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
<ns-login ref="login"></ns-login>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import DiyMinx from './minx.js'
|
|
|
|
export default {
|
|
name: 'diy-image-nav',
|
|
components: {
|
|
nsLogin: () => import('@/components/ns-login/ns-login.vue'),
|
|
},
|
|
props: {
|
|
value: {
|
|
type: Object,
|
|
default: () => ({})
|
|
}
|
|
},
|
|
mixins: [DiyMinx],
|
|
data() {
|
|
return {
|
|
pageWidth: '',
|
|
indicatorDots: false,
|
|
swiperCurrent: 0
|
|
}
|
|
},
|
|
created() {
|
|
// 组件创建时的逻辑
|
|
},
|
|
watch: {
|
|
componentRefresh(newValue) {
|
|
// 监听组件刷新
|
|
}
|
|
},
|
|
computed: {
|
|
componentStyle() {
|
|
let style = '';
|
|
style += 'background-color:' + this.value.componentBgColor + ';';
|
|
|
|
if (this.value.componentAngle == 'round') {
|
|
style += 'border-top-left-radius:' + (2 * this.value.topAroundRadius) + 'rpx;';
|
|
style += 'border-top-right-radius:' + (2 * this.value.topAroundRadius) + 'rpx;';
|
|
style += 'border-bottom-left-radius:' + (2 * this.value.bottomAroundRadius) + 'rpx;';
|
|
style += 'border-bottom-right-radius:' + (2 * this.value.bottomAroundRadius) + 'rpx;';
|
|
}
|
|
|
|
style += 'box-shadow:' + (this.value.ornament.type == 'shadow' ? '0 0 10rpx ' + this.value.ornament.color : '') + ';';
|
|
style += 'border:' + (this.value.ornament.type == 'stroke' ? '2rpx solid ' + this.value.ornament.color : '') + ';';
|
|
|
|
return style;
|
|
},
|
|
|
|
swiperHeight() {
|
|
let height = 0;
|
|
|
|
if (this.value.mode == 'graphic') {
|
|
height = (49 + this.value.imageSize) * this.value.pageCount;
|
|
} else if (this.value.mode == 'img') {
|
|
height = (22 + this.value.imageSize) * this.value.pageCount;
|
|
} else if (this.value.mode == 'text') {
|
|
height = 43 * this.value.pageCount;
|
|
}
|
|
|
|
return 'height:' + (2 * height) + 'rpx';
|
|
},
|
|
|
|
isIndicatorDots() {
|
|
return this.value.carousel.type != 'hide' &&
|
|
1 != Math.ceil(this.value.list.length / (this.value.pageCount * this.value.rowCount));
|
|
}
|
|
},
|
|
methods: {
|
|
// 预览图片
|
|
previewImg(imageUrl) {
|
|
uni.previewImage({
|
|
current: 0,
|
|
urls: [this.$util.img(imageUrl)],
|
|
success: (res) => { },
|
|
fail: (res) => { },
|
|
complete: (res) => { }
|
|
});
|
|
},
|
|
|
|
// 页面跳转
|
|
redirectTo(link) {
|
|
if (!link.wap_url || this.$util.getCurrRoute() != 'pages/member/index' || this.storeToken) {
|
|
this.$util.diyRedirectTo(link);
|
|
} else {
|
|
this.$refs.login.open(link.wap_url);
|
|
}
|
|
},
|
|
|
|
// 轮播切换
|
|
swiperChange(event) {
|
|
this.swiperCurrent = event.detail.current;
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.image-nav {
|
|
padding: 16rpx;
|
|
box-sizing: border-box;
|
|
|
|
&.fixed-layout {
|
|
.uni-scroll-view-content {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
}
|
|
}
|
|
|
|
&.singleSlide {
|
|
.uni-scroll-view-content {
|
|
display: flex;
|
|
}
|
|
|
|
.image-nav-item {
|
|
flex-shrink: 0;
|
|
}
|
|
}
|
|
|
|
&.pageSlide {
|
|
position: relative;
|
|
|
|
.uni-swiper-dots-horizontal {
|
|
bottom: 0rpx;
|
|
}
|
|
|
|
&.straightLine {
|
|
.uni-swiper-dot {
|
|
width: 30rpx;
|
|
border-radius: 0;
|
|
height: 8rpx;
|
|
}
|
|
}
|
|
|
|
&.circle {
|
|
.uni-swiper-dot {
|
|
width: 14rpx;
|
|
height: 14rpx;
|
|
}
|
|
}
|
|
}
|
|
|
|
.image-nav-wrap {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.image-nav-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
padding: 14rpx 0;
|
|
box-sizing: border-box;
|
|
|
|
.image-text {
|
|
padding-top: 12rpx;
|
|
line-height: 1.5;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
text-align: center;
|
|
|
|
&.alone {
|
|
padding-top: 0;
|
|
}
|
|
}
|
|
|
|
&.text {
|
|
.image-text {
|
|
padding-top: 0;
|
|
}
|
|
}
|
|
|
|
.image-img {
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 90rpx;
|
|
|
|
.tag {
|
|
position: absolute;
|
|
top: -10rpx;
|
|
right: -24rpx;
|
|
color: #fff;
|
|
border-radius: 24rpx;
|
|
border-bottom-left-radius: 0;
|
|
-webkit-transform: scale(0.8);
|
|
transform: scale(0.8);
|
|
padding: 8rpx 16rpx;
|
|
line-height: 1;
|
|
font-size: 24rpx;
|
|
}
|
|
|
|
.icon {
|
|
font-size: 50rpx;
|
|
color: #606266;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.swiper-dot-box {
|
|
width: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-top: -20rpx;
|
|
padding-bottom: 8rpx;
|
|
|
|
.swiper-dot {
|
|
background-color: rgba(0, 0, 0, 0.3);
|
|
margin: 8rpx;
|
|
|
|
&.active {
|
|
background-color: #000;
|
|
}
|
|
}
|
|
|
|
&.straightLine {
|
|
.swiper-dot {
|
|
width: 30rpx;
|
|
border-radius: 0;
|
|
height: 8rpx;
|
|
}
|
|
}
|
|
|
|
&.circle {
|
|
.swiper-dot {
|
|
width: 15rpx;
|
|
border-radius: 50%;
|
|
height: 15rpx;
|
|
}
|
|
}
|
|
}
|
|
</style> |