app.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // import { Component, PropsWithChildren } from 'react'
  2. // class App extends Component<PropsWithChildren> {
  3. // componentDidMount () {}
  4. // componentDidShow () {}
  5. // componentDidHide () {}
  6. // render () {
  7. // // this.props.children 是将要会渲染的页面
  8. // return this.props.children
  9. // }
  10. // }
  11. // export default App
  12. import { PropsWithChildren } from "react";
  13. import { useRequest } from "ahooks";
  14. import { Provider as ReduxProvider } from "react-redux";
  15. import Taro, { useDidShow } from "@tarojs/taro";
  16. import { WebView } from "@tarojs/components";
  17. import StorageUtil, { EStorage } from "@/utils/storageUtil";
  18. import AppContext from "./context/appContext";
  19. import ReduxUtil from "./utils/reduxUtil";
  20. import RouteUtil from "./utils/routeUtil";
  21. import UserHelper from "./helper/userHelper";
  22. import "./app.scss";
  23. interface IAppProps {}
  24. const App = (props: PropsWithChildren<IAppProps>) => {
  25. const result = useRequest(Taro.getSystemInfo);
  26. useRequest(() => {
  27. return UserHelper.cacheTabMenu();
  28. });
  29. useDidShow((options: any) => {
  30. console.log('11111111111111111111111', options)
  31. if (options.query?.source === "app" && options.query?.platform) {
  32. let jumpUrls = "";
  33. switch (options.query?.platform) {
  34. case "cyqb":
  35. jumpUrls = "https://mp.weixin.qq.com/s/TBP2VhzYRaMWf_CWbo5mBA";
  36. break;
  37. case "hrqb":
  38. jumpUrls = "https://mp.weixin.qq.com/s/JJrWlgaA1lvIBAp7eNZjxg";
  39. break;
  40. default:
  41. // 默认惠融钱包的文章
  42. jumpUrls = "https://mp.weixin.qq.com/s/JJrWlgaA1lvIBAp7eNZjxg";
  43. break;
  44. }
  45. RouteUtil.toWebViewPage({
  46. url: jumpUrls,
  47. });
  48. }
  49. if (StorageUtil.get(EStorage.channelCode)) {
  50. StorageUtil.remove(EStorage.channelCode);
  51. }
  52. if (options.query?.channelCode) {
  53. StorageUtil.set(EStorage.channelCode, options.query?.channelCode);
  54. }
  55. });
  56. return (
  57. // (appContext.systemInfo?.screenHeight || 0) - (appContext.systemInfo?.safeArea?.bottom || 0);
  58. <AppContext.Provider
  59. value={{
  60. systemInfo: result.data,
  61. screenSize: {
  62. width: result.data?.screenWidth || 0,
  63. height: result.data?.screenHeight || 0,
  64. },
  65. padding: {
  66. // top: result.data?.safeArea?.top || 0,
  67. top: 0,
  68. bottom:
  69. (result.data?.screenHeight || 0) -
  70. (result.data?.safeArea?.bottom || 0),
  71. },
  72. }}
  73. >
  74. <WebView src="https://mp.weixin.qq.com/s/4umQqPbPGfCgXqCizeXqKA"></WebView>
  75. <ReduxProvider store={ReduxUtil.store}>{props.children}</ReduxProvider>
  76. </AppContext.Provider>
  77. );
  78. };
  79. export default App;