Эх сурвалжийг харах

【功能修复】修复用户卡券装修背景图片问题

卢越 1 жил өмнө
parent
commit
438897b9d3

+ 1 - 1
sheep/components/s-block-item/s-block-item.vue

@@ -53,7 +53,7 @@
     <!-- 用户组件:用户资产 -->
     <s-wallet-card v-if="type === 'UserWallet'" :data="data" :styles="styles" />
     <!-- 用户组件:用户卡券 -->
-    <s-coupon-card v-if="type === 'UserCoupon'" />
+    <s-coupon-card v-if="type === 'UserCoupon'" :data="data" :styles="styles" />
   </view>
 </template>
 

+ 24 - 1
sheep/components/s-coupon-card/s-coupon-card.vue

@@ -1,6 +1,6 @@
 <!-- 装修用户组件:用户卡券 -->
 <template>
-	<view class="ss-coupon-menu-wrap ss-flex ss-col-center">
+	<view class="ss-coupon-menu-wrap ss-flex ss-col-center" :style="[style, { marginLeft: `${data.space}px` }]">
 		<view class="menu-item ss-flex-col ss-row-center ss-col-center" v-for="item in props.list" :key="item.title"
 			@tap="sheep.$router.go(item.path, { type: item.type })"
 			:class="item.type === 'all' ? 'menu-wallet' : 'ss-flex-1'">
@@ -15,6 +15,7 @@
 	 * 装修组件 - 优惠券菜单
 	 */
 	import sheep from '@/sheep';
+	import { computed } from 'vue';
 
 	// 接收参数
 	const props = defineProps({
@@ -52,6 +53,28 @@
 				];
 			},
 		},
+		// 装修数据
+		data: {
+		  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>