李志伟 3 gadus atpakaļ
vecāks
revīzija
a828bb2ea8
3 mainītis faili ar 12 papildinājumiem un 6 dzēšanām
  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 Parādīt failu

@@ -10,10 +10,15 @@ export default (Child) => (props) => {
10 10
   const router = useRouter()
11 11
   
12 12
   const location = Taro.getStorageSync('location')
13
+
13 14
   useEffect(()=>{
15
+    if (router.path==='/pages/login/index') {
16
+      return
17
+    }
14 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 23
   return <Child {...props} router={router} location={location} />
19 24
 }

+ 1
- 1
src/pages/index/index.jsx Parādīt failu

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

+ 4
- 3
src/pages/login/index.jsx Parādīt failu

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