李志伟 3 years ago
parent
commit
a828bb2ea8
3 changed files with 12 additions and 6 deletions
  1. 7
    2
      src/layouts/index.jsx
  2. 1
    1
      src/pages/index/index.jsx
  3. 4
    3
      src/pages/login/index.jsx

+ 7
- 2
src/layouts/index.jsx View File

10
   const router = useRouter()
10
   const router = useRouter()
11
   
11
   
12
   const location = Taro.getStorageSync('location')
12
   const location = Taro.getStorageSync('location')
13
+
13
   useEffect(()=>{
14
   useEffect(()=>{
15
+    if (router.path==='/pages/login/index') {
16
+      return
17
+    }
14
     if (router.path!=='/pages/index/index'&&!person?.phone) {
18
     if (router.path!=='/pages/index/index'&&!person?.phone) {
15
-      Taro.reLaunch({ url: '/pages/login/index' });
19
+      Taro.navigateTo({ url: '/pages/login/index' });
16
     }
20
     }
17
-  },[router.path])
21
+  },[person?.phone, router?.path])
22
+
18
   return <Child {...props} router={router} location={location} />
23
   return <Child {...props} router={router} location={location} />
19
 }
24
 }

+ 1
- 1
src/pages/index/index.jsx View File

24
   const [currentTab, setCurrentTab] = useState(0);
24
   const [currentTab, setCurrentTab] = useState(0);
25
   const handleClick = (val) => {
25
   const handleClick = (val) => {
26
     if (!person.phone) {
26
     if (!person.phone) {
27
-      Taro.reLaunch({ url: '/pages/login/index' });
27
+      Taro.navigateTo({ url: '/pages/login/index' });
28
     }      
28
     }      
29
     setCurrentTab(val);
29
     setCurrentTab(val);
30
   };
30
   };

+ 4
- 3
src/pages/login/index.jsx View File

3
 import { useModel } from '@/store'
3
 import { useModel } from '@/store'
4
 import { View, Image, Input, Text, Checkbox, Label, Button } from "@tarojs/components"
4
 import { View, Image, Input, Text, Checkbox, Label, Button } from "@tarojs/components"
5
 import CustomNav from "@/components/CustomNav"
5
 import CustomNav from "@/components/CustomNav"
6
+import withLayout from '@/layouts'
6
 import MyButton from "@/components/MyButton"
7
 import MyButton from "@/components/MyButton"
7
 import {updatePhone, setQcode } from '@/services/login'
8
 import {updatePhone, setQcode } from '@/services/login'
8
 import bgi from '@/assets/login/loginImg.png'
9
 import bgi from '@/assets/login/loginImg.png'
12
 
13
 
13
 import './style.less'
14
 import './style.less'
14
 
15
 
15
-export default (props) => {
16
+export default withLayout((props) => {
16
   const { person,setPerson } = useModel('person')
17
   const { person,setPerson } = useModel('person')
17
 
18
 
18
   const [agreement,setAgreement]=useState(false)
19
   const [agreement,setAgreement]=useState(false)
89
           icon: 'none',
90
           icon: 'none',
90
           duration: 1000
91
           duration: 1000
91
         })
92
         })
92
-        Taro.reLaunch({ url: '/pages/index/index?tab=2' });
93
+        Taro.navigateBack({ detail:1 });
93
       }).catch((e) => {
94
       }).catch((e) => {
94
         Taro.showToast({
95
         Taro.showToast({
95
           title: '手机号或者验证码不正确',
96
           title: '手机号或者验证码不正确',
134
       </View>
135
       </View>
135
     </View>
136
     </View>
136
   )
137
   )
137
-}
138
+})