【功能修复】修复装修宫格导航背景图片问题

pull/76/head
卢越 2024-08-12 11:03:39 +08:00
parent 438897b9d3
commit 34274cbaa8
2 changed files with 94 additions and 72 deletions

View File

@ -9,7 +9,7 @@
<!-- 基础组件列表导航 --> <!-- 基础组件列表导航 -->
<s-menu-list v-if="type === 'MenuList'" :data="data" /> <s-menu-list v-if="type === 'MenuList'" :data="data" />
<!-- 基础组件宫格导航 --> <!-- 基础组件宫格导航 -->
<s-menu-grid v-if="type === 'MenuGrid'" :data="data" /> <s-menu-grid v-if="type === 'MenuGrid'" :data="data" :styles="styles" />
<!-- 基础组件弹窗广告 --> <!-- 基础组件弹窗广告 -->
<s-popup-image v-if="type === 'Popover'" :data="data" /> <s-popup-image v-if="type === 'Popover'" :data="data" />
<!-- 基础组件悬浮按钮 --> <!-- 基础组件悬浮按钮 -->

View File

@ -1,82 +1,104 @@
<!-- 装修基础组件宫格导航 --> <!-- 装修基础组件宫格导航 -->
<template> <template>
<uni-grid :showBorder="Boolean(data.border)" :column="data.column"> <view :style="[style, { marginLeft: `${data.space}px` }]">
<uni-grid-item <uni-grid :showBorder="Boolean(data.border)" :column="data.column">
v-for="(item, index) in data.list" <uni-grid-item v-for="(item, index) in data.list" :key="index" @tap="sheep.$router.go(item.url)">
:key="index" <view class="grid-item-box ss-flex ss-flex-col ss-row-center ss-col-center">
@tap="sheep.$router.go(item.url)" <view class="img-box">
> <view class="tag-box" v-if="item.badge.show"
<view class="grid-item-box ss-flex ss-flex-col ss-row-center ss-col-center"> :style="[{ background: item.badge.bgColor, color: item.badge.textColor }]">
<view class="img-box"> {{ item.badge.text }}
<view </view>
class="tag-box" <image class="menu-image" :src="sheep.$url.cdn(item.iconUrl)"></image>
v-if="item.badge.show" </view>
:style="[{ background: item.badge.bgColor, color: item.badge.textColor }]"
> <view class="title-box ss-flex ss-flex-col ss-row-center ss-col-center">
{{ item.badge.text }} <view class="grid-text" :style="[{ color: item.titleColor }]">
</view> {{ item.title }}
<image class="menu-image" :src="sheep.$url.cdn(item.iconUrl)"></image> </view>
</view> <view class="grid-tip" :style="[{ color: item.subtitleColor }]">
{{ item.subtitle }}
</view>
</view>
</view>
</uni-grid-item>
</uni-grid>
</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>
</uni-grid>
</template> </template>
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import {
computed
} from 'vue';
const props = defineProps({ const props = defineProps({
data: { //
type: Object, data: {
default() {}, type: Object,
}, default: () => ({}),
}); },
//
styles: {
type: Object,
default: () => ({}),
},
});
//
const style = computed(() => {
// props.styles
const {
bgType,
bgImg,
bgColor
} = props.styles;
// bgType
return {
background: bgType === 'img' ? `url(${bgImg}) no-repeat top center / 100% 100%` : bgColor
};
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.menu-image { .menu-image {
width: 24px; width: 24px;
height: 24px; height: 24px;
} }
.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: 2em;
line-height: 1;
padding: 0.4em 0.6em 0.3em;
transform: scale(0.4) translateX(0.5em) translatey(-0.6em);
transform-origin: 100% 0;
border-radius: 200rpx;
white-space: nowrap;
}
}
.title-box { .grid-item-box {
.grid-tip { flex: 1;
font-size: 24rpx; display: flex;
white-space: nowrap; flex-direction: column;
text-align: center; align-items: center;
} justify-content: center;
} height: 100%;
}
</style> .img-box {
position: relative;
.tag-box {
position: absolute;
z-index: 2;
top: 0;
right: 0;
font-size: 2em;
line-height: 1;
padding: 0.4em 0.6em 0.3em;
transform: scale(0.4) translateX(0.5em) translatey(-0.6em);
transform-origin: 100% 0;
border-radius: 200rpx;
white-space: nowrap;
}
}
.title-box {
.grid-tip {
font-size: 24rpx;
white-space: nowrap;
text-align: center;
}
}
}
</style>