53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { Image, View, Text } from "@tarojs/components";
|
|
import styles from "./index.module.scss";
|
|
import img from "@/config/images";
|
|
|
|
interface IProps {
|
|
reload?: () => void;
|
|
text?: string;
|
|
errorImg?: string;
|
|
btnText?: string;
|
|
btnImg?: string;
|
|
wrapperHeight?: string;
|
|
width?: string;
|
|
height?: string;
|
|
scale?: string;
|
|
}
|
|
|
|
const ListLoadError = (props: IProps) => {
|
|
const {
|
|
reload,
|
|
text,
|
|
errorImg,
|
|
btnText,
|
|
btnImg,
|
|
wrapperHeight = "",
|
|
width = "",
|
|
height = "",
|
|
} = props;
|
|
const handleReload = () => {
|
|
reload && typeof reload === "function" && reload();
|
|
};
|
|
|
|
return (
|
|
<View className={styles.listLoadError} style={{ height: wrapperHeight }}>
|
|
<Image
|
|
className={styles.listLoadErrorImg}
|
|
style={{ width, height }}
|
|
src={errorImg ? img[errorImg] : img.ICON_LIST_LOAD_ERROR}
|
|
/>
|
|
{text && <Text className={styles.listLoadErrorText}>{text}</Text>}
|
|
{reload && (
|
|
<View className={styles.listLoadErrorBtn} onClick={handleReload}>
|
|
<Image
|
|
src={btnImg ? img[btnImg] : img?.ICON_LIST_RELOAD}
|
|
className={styles.reloadIcon}
|
|
/>
|
|
{btnText ? " " + btnText : "重试"}
|
|
</View>
|
|
)}
|
|
</View>
|
|
);
|
|
};
|
|
export default ListLoadError;
|