【功能修复】修复标题栏装修背景图片问题

pull/76/head
卢越 2024-08-12 13:06:35 +08:00
parent 34274cbaa8
commit be5db900a0
1 changed files with 93 additions and 84 deletions

View File

@ -1,10 +1,6 @@
<!-- 装修商品组件标题栏 --> <!-- 装修商品组件标题栏 -->
<template> <template>
<view <view class="ss-title-wrap ss-flex ss-col-center" :class="[state.typeMap[data.textAlign]]" :style="[bgStyle, { marginLeft: `${data.space}px` }]">
class="ss-title-wrap ss-flex ss-col-center"
:class="[state.typeMap[data.textAlign]]"
:style="[elStyles]"
>
<view class="title-content"> <view class="title-content">
<!-- 主标题 --> <!-- 主标题 -->
<view v-if="data.title" class="title-text" :style="[titleStyles]">{{ data.title }}</view> <view v-if="data.title" class="title-text" :style="[titleStyles]">{{ data.title }}</view>
@ -24,7 +20,10 @@
/** /**
* 标题栏 * 标题栏
*/ */
import { reactive } from 'vue'; import {
reactive,
computed
} from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
// //
@ -37,22 +36,32 @@
// //
const props = defineProps({ const props = defineProps({
//
data: { data: {
type: Object, type: Object,
default() {}, default: () => ({}),
}, },
//
styles: { styles: {
type: Object, type: Object,
default() {}, default: () => ({}),
}, },
}); });
//
const bgStyle = computed(() => {
console.log(props.data)
// props.styles
const {
bgType,
bgImg,
bgColor
} = props.styles;
// // bgType
const elStyles = { return {
background: `url(${sheep.$url.cdn(props.data.bgImgUrl)}) no-repeat top center / 100% auto`, background: bgType === 'img' ? `url(${bgImg}) no-repeat top center / 100% 100%` : bgColor
fontSize: `${props.data.titleSize}px`,
fontWeight: `${props.data.titleWeight}px`,
}; };
});
// //
const titleStyles = { const titleStyles = {