You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
<!-- 装修基础组件 : 宫格导航 -- >
< template >
< view : style = "[bgStyle, { marginLeft: `${data.space}px` }]" >
< uni -grid :showBorder ="Boolean(data.border)" :column ="data.column" >
< uni -grid -item v-for ="(item, index) in data.list" :key="index" @tap="sheep.$router.go(item.url)">
<view class="grid-item-box ss-flex ss-flex-col ss-row-center ss-col-center">
<view class="img-box">
<view class="tag-box" v-if="item.badge.show"
:style="[{ background: item.badge.bgColor, color: item.badge.textColor }]">
{{ item.badge.text }}
</view>
<image class="menu-image" :src="sheep.$url.cdn(item.iconUrl)"></image>
</view>
<view class="title-box ss-flex ss-flex-col ss-row-center ss-col-center">
<view class="grid-text" :style="[{ color: item.titleColor }]">
{{ item.title }}
</view>
<view class="grid-tip" :style="[{ color: item.subtitleColor }]" >
{{ item.subtitle }}
< / view >
< / view >
< / view >
< / uni -grid -item >
< / u n i - g r i d >
< / view >
< / template >
< script setup >
import sheep from '@/sheep' ;
import {
computed
} from 'vue' ;
const props = defineProps ( {
// 装修数据
data : {
type : Object ,
default : ( ) => ( { } ) ,
} ,
// 装修样式
styles : {
type : Object ,
default : ( ) => ( { } ) ,
} ,
} ) ;
// 设置背景样式
const bgStyle = computed ( ( ) => {
// 直接从 props.styles 解构
const {
bgType ,
bgImg ,
bgColor
} = props . styles ;
// 根据 bgType 返回相应的样式
return {
background : bgType === 'img' ? ` url( ${ bgImg } ) no-repeat top center / 100% 100% ` : bgColor
} ;
} ) ;
< / script >
< style lang = "scss" scoped >
. menu - image {
width : 24 px ;
height : 24 px ;
}
. grid - item - box {
flex : 1 ;
display : flex ;
flex - direction : column ;
align - items : center ;
justify - content : center ;
height : 100 % ;
. img - box {
position : relative ;
. tag - box {
position : absolute ;
z - index : 2 ;
top : 0 ;
right : 0 ;
font - size : 2 em ;
line - height : 1 ;
padding : 0.4 em 0.6 em 0.3 em ;
transform : scale ( 0.4 ) translateX ( 0.5 em ) translatey ( - 0.6 em ) ;
transform - origin : 100 % 0 ;
border - radius : 200 rpx ;
white - space : nowrap ;
}
}
. title - box {
. grid - tip {
font - size : 24 rpx ;
white - space : nowrap ;
text - align : center ;
}
}
}
< / style >