fix: privacy modal theme in RootPortal; image placeholders; coupon btn styles

- SpPrivacyModal: render via RootPortal on weapp; inject themeColor() on root so
  var(--color-primary) works outside SpPage; clean unused imports
- SpImage container and goods card image areas: white background for loading/empty
- WgtCouponCard: use camelCase inline style keys for receive button
- goods widget: list thumb background #fff instead of gray

Made-with: Cursor
This commit is contained in:
zhangjing1
2026-03-23 12:19:53 +08:00
parent d21b710af6
commit d375946b5f
7 changed files with 19 additions and 7 deletions

View File

@@ -5,7 +5,7 @@
.sp-image-container {
position: relative;
overflow: hidden; /* 防止圆角溢出 */
background-color: transparent;
background-color: #fff;
height: 100%;
display: flex;
align-items: center;

View File

@@ -4,13 +4,12 @@
*/
import React, { useState, useEffect } from 'react'
import Taro from '@tarojs/taro'
import { View, Image, Button, Text } from '@tarojs/components'
import { View, Text, RootPortal } from '@tarojs/components'
import { AtButton } from 'taro-ui'
import { useImmer } from 'use-immer'
import { SpImage } from '@/components'
import api from '@/api'
import { classNames, styleNames } from '@/utils'
import { useLogin } from '@/hooks'
import { useLogin, useThemsColor } from '@/hooks'
import './index.scss'
@@ -21,6 +20,7 @@ const initState = {
}
function SpPrivacyModal(props) {
const { themeColor } = useThemsColor()
const { login, updatePolicyTime, getUserInfoAuth } = useLogin()
const { open = false, onCancel = () => {}, onConfirm = () => {} } = props
const [info, setInfo] = useImmer(initState)
@@ -56,11 +56,13 @@ function SpPrivacyModal(props) {
onCancel()
}
return (
// RootPortal 脱离 SpPage根节点需注入 themeColor(),子树内 var(--color-primary) 才能生效
const modal = (
<View
className={classNames('sp-privacy-modal', {
'open': open
})}
style={styleNames(themeColor())}
>
<View className='sp-privacy-modal__overlay'></View>
<View className='modal-container'>
@@ -95,6 +97,13 @@ function SpPrivacyModal(props) {
</View>
</View>
)
// 微信小程序scroll-view 内图片等同层渲染节点可能盖住普通 fixed 层;挂到页面根节点保证最顶层
if (process.env.TARO_ENV === 'weapp') {
return <RootPortal>{modal}</RootPortal>
}
return modal
}
SpPrivacyModal.options = {

View File

@@ -8,6 +8,7 @@
&__image {
width: 100%;
position: relative;
background-color: #fff;
.soldout-mask {
position: absolute;

View File

@@ -7,6 +7,7 @@
width: 100%;
aspect-ratio: 1/1;
position: relative;
background-color: #fff;
.soldout-mask {
position: absolute;

View File

@@ -10,6 +10,7 @@
aspect-ratio: 1/1;
position: relative;
overflow: hidden;
background-color: #fff;
.soldout-mask {
position: absolute;

View File

@@ -67,7 +67,7 @@ function WgtCouponCard(props) {
const receiveBtnStyle = useMemo(() => {
const { color, textColor } = receiveBtn
return {
'background-color': color,
backgroundColor: color,
color: textColor
}
}, [receiveBtn])

View File

@@ -59,7 +59,7 @@
&-img {
width: 157px;
height: 157px;
background: #d6d6d6;
background: #fff;
overflow: hidden;
position: relative;