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

【功能修复】修复用户资产装修背景图片问题

卢越 1 жил өмнө
parent
commit
58af434a90

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

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

+ 1 - 1
sheep/components/s-user-card/s-user-card.vue

@@ -1,6 +1,6 @@
 <!-- 装修用户组件:用户卡片 -->
 <template>
-	<view class="ss-user-info-wrap ss-p-t-50"  :style="[style, { marginLeft: `${data.space}px` }]">
+	<view class="ss-user-info-wrap ss-p-t-50" :style="[style, { marginLeft: `${data.space}px` }]">
 		<view class="ss-flex ss-col-center ss-row-between ss-m-b-20">
 			<view class="left-box ss-flex ss-col-center ss-m-l-36">
 				<view class="avatar-box ss-m-r-24">

+ 28 - 2
sheep/components/s-wallet-card/s-wallet-card.vue

@@ -1,6 +1,6 @@
 <!-- 装修用户组件:用户资产 -->
 <template>
-	<view class="ss-wallet-menu-wrap ss-flex ss-col-center">
+	<view class="ss-wallet-menu-wrap ss-flex ss-col-center" :style="[style, { marginLeft: `${data.space}px` }]">
 		<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
 			@tap="sheep.$router.go('/pages/user/wallet/money')">
 			<view class="value-box ss-flex ss-col-bottom">
@@ -42,8 +42,34 @@
 	 */
 	import { computed } from 'vue';
 	import sheep from '@/sheep';
-  import { fen2yuan } from '../../hooks/useGoods';
+	import { fen2yuan } from '../../hooks/useGoods';
 
+	// 接收参数
+	const props = defineProps({
+		// 装修数据
+		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
+		};
+	});
+	
 	const userWallet = computed(() => sheep.$store('user').userWallet);
 	const userInfo = computed(() => sheep.$store('user').userInfo);
 	const numData = computed(() => sheep.$store('user').numData);