WOrderHeader.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import styles from "./styles.module.scss";
  2. import SvgIcon from "@components/SvgIcon";
  3. import MXHeaderRight from "@widgets/WPaymentOrder/WOrderHeader/MXHeaderRight";
  4. import {ROUTE_PATH} from "@constants/routes";
  5. import {useEffect} from "react";
  6. const i18n=global.i18n;
  7. const objInfo={};
  8. const WOrderHeader = ({...props})=>{
  9. const route=props.route;
  10. const close=props.close;
  11. const renderRight=()=>{
  12. let areaItem=global.getLocalAreaItem();
  13. if (areaItem!=null){
  14. if (areaItem.code==="mx"){
  15. return <MXHeaderRight/>
  16. }
  17. }
  18. return (<></>);
  19. }
  20. const checkClose=()=>{
  21. close();
  22. if (objInfo.backTimer)clearTimeout(objInfo.backTimer);
  23. objInfo.backTimer=setTimeout(()=>{
  24. if (window.location.hash.indexOf(ROUTE_PATH.PAY_ORDER) !== -1){
  25. checkClose();
  26. }
  27. },10)
  28. }
  29. useEffect(() => {
  30. return () => {
  31. if (objInfo.backTimer){
  32. clearTimeout(objInfo.backTimer);
  33. objInfo.backTimer = null;
  34. }
  35. };
  36. }, []);
  37. const renderHeader=()=>{
  38. let title=route?route.title:"";
  39. return (
  40. <div className={styles.header}>
  41. <div className={styles.hcontent}>
  42. {i18n.t(title)}
  43. </div>
  44. <div className={styles.top}>
  45. <div className={styles.left}>
  46. <button className={styles.close} onClick={() => {
  47. checkClose();
  48. }}>
  49. <SvgIcon className={styles.arrow} herf={"icon_Arrow"}/>
  50. </button>
  51. </div>
  52. {renderRight()}
  53. </div>
  54. </div>
  55. )
  56. }
  57. return (
  58. <div id={props.id} className={props.className}>
  59. {renderHeader()}
  60. </div>
  61. )
  62. }
  63. export default WOrderHeader;