267 lines
5.6 KiB
Vue
267 lines
5.6 KiB
Vue
<template>
|
|
<view :style="componentStyle">
|
|
<scroll-view :class="['graphic-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="['graphic-nav-item', value.mode, value.mode === 'text' ? 'newright' : '']"
|
|
:style="{ width: (100 / value.rowCount + '%') + ';' }">
|
|
<view style="display:flex;">
|
|
<view :style="{
|
|
'line-height': '1.2;',
|
|
'font-size': (value.font.titlesize * 2 + 'rpx') + ';',
|
|
'font-weight': '600;',
|
|
'color': value.font.titlecolor + ';'
|
|
}">
|
|
<uv-count-to :ref="`countTo-${index}`" :autoplay="true" :startVal="30" :endVal="item.title"
|
|
:decimals="getvalue(item.title)" decimal="."></uv-count-to>
|
|
<text :style="{
|
|
'margin-left': '4rpx;',
|
|
'font-size': (value.font.unitsize * 2 + 'rpx') + ';',
|
|
'font-weight': value.font.weight + ';',
|
|
'color': value.font.unitcolor + ';'
|
|
}">{{ item.unit }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="graphic-text">
|
|
<text :style="{
|
|
'font-size': (value.font.descsize * 2 + 'rpx') + ';',
|
|
'font-weight': value.font.weight + ';',
|
|
'color': value.font.desccolor + ';'
|
|
}">{{ item.desc }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
<ns-login ref="login"></ns-login>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import uvCountTo from '@/components/uv-count-to/uv-count-to.vue'
|
|
import nsLogin from '@/components/ns-login/ns-login.vue'
|
|
import DiyMinx from './minx.js'
|
|
// 自定义数字展示
|
|
export default {
|
|
name: 'diy-digit',
|
|
components: {
|
|
uvCountTo,
|
|
nsLogin
|
|
},
|
|
props: {
|
|
value: {
|
|
type: Object,
|
|
default: () => ({})
|
|
}
|
|
},
|
|
mixins: [DiyMinx],
|
|
data() {
|
|
return {
|
|
pageWidth: '',
|
|
indicatorDots: false,
|
|
swiperCurrent: 0
|
|
}
|
|
},
|
|
created() {
|
|
// 组件创建时的逻辑
|
|
},
|
|
watch: {
|
|
componentRefresh(newValue) {
|
|
// 监听组件刷新
|
|
}
|
|
},
|
|
computed: {
|
|
componentStyle() {
|
|
let style = '';
|
|
style += 'background-image:url(' + this.$util.img(this.value.imageUrl) + ');background-size:100% 100%;';
|
|
|
|
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;
|
|
}
|
|
},
|
|
methods: {
|
|
// 获取小数位数
|
|
getvalue(value) {
|
|
return value % 1 !== 0 ? 2 : 0;
|
|
},
|
|
|
|
// 页面跳转
|
|
redirectTo(item) {
|
|
if (!item.wap_url || this.$util.getCurrRoute() != 'pages/member/index' || this.storeToken) {
|
|
console.log(item);
|
|
this.$util.diyRedirectTo(item);
|
|
} else {
|
|
this.$refs.login.open(item.wap_url);
|
|
}
|
|
},
|
|
|
|
// 轮播切换
|
|
swiperChange(event) {
|
|
this.swiperCurrent = event.detail.current;
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.graphic-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;
|
|
}
|
|
|
|
.graphic-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;
|
|
}
|
|
}
|
|
}
|
|
|
|
.graphic-nav-wrap {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.graphic-nav-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
padding: 14rpx 0;
|
|
box-sizing: border-box;
|
|
|
|
.graphic-text {
|
|
line-height: 1.3;
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
width: 100%;
|
|
text-align: center;
|
|
|
|
&.alone {
|
|
padding-top: 0;
|
|
}
|
|
}
|
|
|
|
&.text {
|
|
.graphic-text {
|
|
padding-top: 0;
|
|
}
|
|
}
|
|
|
|
.graphic-img {
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 100rpx;
|
|
height: 100rpx;
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
&.pageSlide {
|
|
.graphic-nav-item {
|
|
flex-shrink: 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
.newright {
|
|
margin-right: 16rpx;
|
|
}
|
|
|
|
.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> |