feat(user): 新增收货地址管理及售后申请页面
- 新增地址类型定义,增强前端地址数据结构 - 新增地址编辑页面,支持地址智能识别和定位选点功能 - 地址编辑支持省市区选择及默认地址设置 - 新增地址列表页面,支持地址展示、删除、编辑和选择功能 - 实现售后申请页面,支持选择售后类型和退款原因 - 售后申请支持商品选择、退款金额计算和凭证上传 - 新增售后详情页面,支持售后状态展示及申请取消 - 优化页面加载和用户交互体验,增加错误提示和权限处理
This commit is contained in:
57
src_bak/components/common/LazyImage/index.tsx
Normal file
57
src_bak/components/common/LazyImage/index.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import { View, Image, Text } from '@tarojs/components';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useIntersectionObserver } from '@tarojs/taro';
|
||||
|
||||
interface LazyImageProps {
|
||||
src: string;
|
||||
placeholder?: string;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
mode?: 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'center' | 'left' | 'right' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
|
||||
}
|
||||
|
||||
export default function LazyImage({ src, placeholder, className, style, mode = 'aspectFill' }: LazyImageProps) {
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [inView, setInView] = useState(false);
|
||||
const { intersectionObserver } = useIntersectionObserver();
|
||||
|
||||
useEffect(() => {
|
||||
if (!intersectionObserver) return;
|
||||
|
||||
intersectionObserver.relativeToViewport();
|
||||
intersectionObserver.observe({
|
||||
type: 'relativeToViewport',
|
||||
success: (res) => {
|
||||
if (res.intersectionRatio > 0) {
|
||||
setInView(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
intersectionObserver.disconnect();
|
||||
};
|
||||
}, [intersectionObserver]);
|
||||
|
||||
return (
|
||||
<View className={className} style={style}>
|
||||
{!loaded && (
|
||||
<View className="w-full h-full bg-gray-200 flex items-center justify-center">
|
||||
{placeholder ? (
|
||||
<Image src={placeholder} className="w-full h-full" mode={mode} />
|
||||
) : (
|
||||
<Text className="text-gray-400 text-sm">加载中...</Text>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
{(inView || loaded) && (
|
||||
<Image
|
||||
src={src}
|
||||
className={`w-full h-full ${loaded ? 'block' : 'hidden'}`}
|
||||
mode={mode}
|
||||
onLoad={() => setLoaded(true)}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user