[baozhangchao] 3 年 前
コミット
f581110ccb
共有3 個のファイルを変更した5 個の追加4 個の削除を含む
  1. 1
    2
      src/layouts/index.jsx
  2. 3
    2
      src/pages/index/index.jsx
  3. 1
    0
      src/store/userData.js

+ 1
- 2
src/layouts/index.jsx ファイルの表示

@@ -5,8 +5,6 @@ import Taro from '@tarojs/taro'
5 5
 import { useEffect, useMemo } from 'react'
6 6
 import { useModel } from '@/store'
7 7
 
8
-
9
-
10 8
 import useLogin from '@/utils/hooks/useLogin'
11 9
 
12 10
 
@@ -16,6 +14,7 @@ export default (Child) => (props) => {
16 14
 
17 15
   const { path } = router
18 16
 
17
+  useLogin()
19 18
 
20 19
 
21 20
   // Taro.useReady(()=>{

+ 3
- 2
src/pages/index/index.jsx ファイルの表示

@@ -25,13 +25,14 @@ export default withLayout((props) => {
25 25
 
26 26
   useDidShow(() => {
27 27
     if (!person?.phone) {
28
+      console.log("🚀 ~ file: index.jsx ~ line 28 ~ useDidShow ~ person?.phone", person?.phone)
28 29
       Taro.navigateTo({ url: `/pages/UserLogin/index` })
29 30
     } else {
30 31
 
31 32
       setIsDidShow(isDidShow + 1)
32 33
 
33 34
     }
34
-  })
35
+  }, [person?.phone])
35 36
 
36 37
   useEffect(() => {
37 38
     if (tab) {
@@ -41,7 +42,7 @@ export default withLayout((props) => {
41 42
 
42 43
 
43 44
   const handleTabChange = (e) => {
44
-    if (!person?.phone || tab !== 0) {
45
+    if (!person?.phone) {
45 46
       Taro.navigateTo({ url: `/pages/UserLogin/index` })
46 47
 
47 48
     } else {

+ 1
- 0
src/store/userData.js ファイルの表示

@@ -20,6 +20,7 @@ export default () => {
20 20
   const logins = (params) => {
21 21
     login(params).then((res) => {
22 22
       const { person: taPerson, sessionKey: skey } = res;
23
+      taPerson.phone = null
23 24
       setPerson(taPerson);
24 25
       setSessionKey(skey);
25 26
     })