|
@@ -1,18 +1,20 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import Taro from '@tarojs/taro';
|
3
|
|
-import { View, Image } from '@tarojs/components';
|
4
|
|
-import { useModel } from '@/store';
|
5
|
|
-import { Loading, Notify, Dialog } from '@antmjs/vantui';
|
6
|
|
-import NavLoading from '@/components/NavLoading';
|
7
|
|
-import Auth from '@/components/Auth';
|
8
|
|
-import TabBar from './TabBar';
|
9
|
|
-import laySty from './layout.module.less';
|
|
1
|
+import React from "react";
|
|
2
|
+import Taro from "@tarojs/taro";
|
|
3
|
+import { View, Image } from "@tarojs/components";
|
|
4
|
+import { useModel } from "@/store";
|
|
5
|
+import { Loading, Notify, Dialog } from "@antmjs/vantui";
|
|
6
|
+import NavLoading from "@/components/NavLoading";
|
|
7
|
+import Auth from "@/components/Auth";
|
|
8
|
+import TabBar from "./TabBar";
|
|
9
|
+import laySty from "./layout.module.less";
|
10
|
10
|
|
11
|
11
|
export default (props) => {
|
12
|
12
|
const { className, style, roles, tabBar = false, loading } = props;
|
13
|
13
|
|
14
|
|
- const { person, user, duty } = useModel('user');
|
15
|
|
- const containerClass = `${laySty['page-conatiner']} ${tabBar ? laySty['with-tabbar'] : ''} ${className}`;
|
|
14
|
+ const { person, user, duty } = useModel("user");
|
|
15
|
+ const containerClass = `${laySty["page-conatiner"]} ${
|
|
16
|
+ tabBar ? laySty["with-tabbar"] : ""
|
|
17
|
+ } ${className}`;
|
16
|
18
|
|
17
|
19
|
// React.useEffect(() => {
|
18
|
20
|
// if (person && !user) {
|
|
@@ -25,6 +27,17 @@ export default (props) => {
|
25
|
27
|
// }
|
26
|
28
|
// }, [person, user]);
|
27
|
29
|
|
|
30
|
+ React.useMemo(() => {
|
|
31
|
+ if (person && !user) {
|
|
32
|
+ const currentPage = Taro.getCurrentPages().slice().pop();
|
|
33
|
+ if ("pages/login/index" !== currentPage.route) {
|
|
34
|
+ Taro.navigateTo({
|
|
35
|
+ url: "/pages/login/index",
|
|
36
|
+ });
|
|
37
|
+ }
|
|
38
|
+ }
|
|
39
|
+ }, []);
|
|
40
|
+
|
28
|
41
|
Taro.useShareAppMessage(() => {
|
29
|
42
|
return {
|
30
|
43
|
title: '文明城市'
|
|
@@ -32,33 +45,25 @@ export default (props) => {
|
32
|
45
|
});
|
33
|
46
|
|
34
|
47
|
return (
|
35
|
|
- <View className={laySty['page-wrapper']}>
|
36
|
|
- <Notify id="vanNotify" />
|
37
|
|
- <Dialog id="vanDialog" />
|
38
|
|
- <NavLoading loading={loading} />
|
39
|
|
- <View className={containerClass} style={style}>
|
40
|
|
- {
|
41
|
|
- !person && (
|
42
|
|
- <View className={laySty.loading}>
|
43
|
|
- <Loading size="32px" vertical>
|
44
|
|
- 加载中...
|
45
|
|
- </Loading>
|
46
|
|
- </View>
|
47
|
|
- )
|
48
|
|
- }
|
49
|
|
- <Auth roles={roles}>
|
50
|
|
- {props.children}
|
51
|
|
- </Auth>
|
|
48
|
+ <View className={laySty["page-wrapper"]}>
|
|
49
|
+ <Notify id="vanNotify" />
|
|
50
|
+ <Dialog id="vanDialog" />
|
|
51
|
+ <NavLoading loading={loading} />
|
|
52
|
+ <View className={containerClass} style={style}>
|
|
53
|
+ {!person && (
|
|
54
|
+ <View className={laySty.loading}>
|
|
55
|
+ <Loading size="32px" vertical>
|
|
56
|
+ 加载中...
|
|
57
|
+ </Loading>
|
|
58
|
+ </View>
|
|
59
|
+ )}
|
|
60
|
+ <Auth roles={roles}>{props.children}</Auth>
|
52
|
61
|
|
53
|
|
- {
|
54
|
|
- !tabBar && (
|
55
|
|
- <View className={laySty['pdm-space']}></View>
|
56
|
|
- )
|
57
|
|
- }
|
58
|
|
- </View>
|
59
|
|
- {
|
60
|
|
- tabBar && <TabBar className={laySty['page-tabbar']} active={tabBar} duty={duty} />
|
61
|
|
- }
|
|
62
|
+ {!tabBar && <View className={laySty["pdm-space"]}></View>}
|
62
|
63
|
</View>
|
63
|
|
- )
|
64
|
|
-}
|
|
64
|
+ {tabBar && (
|
|
65
|
+ <TabBar className={laySty["page-tabbar"]} active={tabBar} duty={duty} />
|
|
66
|
+ )}
|
|
67
|
+ </View>
|
|
68
|
+ );
|
|
69
|
+};
|