import { Image, Text, View } from "@tarojs/components"; import Taro, { useEffect, useState, pxTransform } from "@tarojs/taro"; import { BG_COLOR_LIST } from "../../lib/model"; import { IProps } from "../../../@types/loading"; import { classNames } from "../../lib"; import ClText from "../../components/text"; export default function ClLoading(props: IProps) { const [loadProgress, setLoadProgress] = useState(0); const loadProgressFn = () => { setLoadProgress(100); }; const contentViewStyle = { position: props.content ? "relative" : "inherit" }; const contentLoadingStyle = { display: props.show ? "flex" : "none", flexDirection: "column", position: props.content ? "absolute" : "fixed", width: props.content ? "100%" : "100vw", height: props.content ? "100%" : "100vh" }; useEffect(() => { if (props.show) { loadProgressFn(); } }, []); useEffect(() => { if (props.show) loadProgressFn(); else { setLoadProgress(0); } }, [props.show]); const bgColorClassName = () => props.bgColor ? BG_COLOR_LIST[props.bgColor] : "bg-blue"; const commonComponent = ( {this.props.children} { e.stopPropagation(); }} > ); const modalComponent = ( { e.stopPropagation(); }} > {props.modalText} ); const imageComponent = ( {this.props.children} ); const lineComponent = ( ); const barComponent = ( {this.props.children} ); return props.content || props.show ? ( props.type === "bar" ? ( barComponent ) : props.type === "line" ? ( lineComponent ) : props.type === "modal" ? ( modalComponent ) : props.type === "image" ? ( imageComponent ) : ( commonComponent ) ) : ( ); } ClLoading.options = { addGlobalClass: true }; ClLoading.defaultProps = { type: "bar", bgColor: "blue", modalText: "加载中...", loadingError: false, noMore: false, show: false } as IProps;