|
@@ -1,5 +1,5 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react'
|
2
|
|
-import Taro from '@tarojs/taro'
|
|
2
|
+import Taro, { useDidShow } from '@tarojs/taro'
|
3
|
3
|
import { useModel } from '@/store'
|
4
|
4
|
import Spin from '@/components/Spin'
|
5
|
5
|
import GetUserPhone from '@/components/GetUserPhone/index'
|
|
@@ -21,20 +21,38 @@ const showError = err => {
|
21
|
21
|
}
|
22
|
22
|
|
23
|
23
|
export default function (props) {
|
|
24
|
+ const { user } = useModel('user')
|
|
25
|
+
|
|
26
|
+ const [page, setPage] = useState({})
|
|
27
|
+ const [loading, setLoading] = useState(true)
|
24
|
28
|
const [showAuthBasic, setShowAuthBasic] = useState(false)
|
25
|
29
|
const [showAuthYeZhu, setShowAuthYeZhu] = useState(false)
|
26
|
30
|
const [showAuthPhone, setShowAuthPhone] = useState(false)
|
27
|
|
- const { user } = useModel('user')
|
28
|
31
|
|
29
|
|
- const loading = !user || !user.personId
|
30
|
|
- const isAuthedBasic = user && user.avatarurl && user.nickname
|
31
|
|
- const isAuthedPhone = user && user.phone
|
32
|
|
- const isAuthedYeZhu = user && user.verifyStatus === 'certified'
|
|
32
|
+ const [isAuthedBasic, setIsAuthedBasic] = useState(false)
|
|
33
|
+ const [isAuthedPhone, setIsAuthedPhone] = useState(false)
|
|
34
|
+ const [isAuthedYeZhu, setIsAuthedYeZhu] = useState(false)
|
|
35
|
+
|
|
36
|
+ const [needAuthBasic, setNeedAuthBasic] = useState(false)
|
|
37
|
+ const [needAuthPhone, setNeedAuthPhone] = useState(false)
|
|
38
|
+ const [needAuthYeZhu, setNeedAuthYeZhu] = useState(false)
|
33
|
39
|
|
34
|
|
- const page = getPage()
|
35
|
|
- const needAuthBasic = (page.auth || []).indexOf('avatar') > -1
|
36
|
|
- const needAuthYeZhu = (page.auth || []).indexOf('yezhu') > -1
|
37
|
|
- const needAuthPhone = (page.auth || []).indexOf('phone') > -1
|
|
40
|
+ useDidShow(() => {
|
|
41
|
+ setPage(getPage())
|
|
42
|
+ })
|
|
43
|
+
|
|
44
|
+ useEffect(() => {
|
|
45
|
+ setLoading(!user || !user.personId)
|
|
46
|
+ setIsAuthedBasic(user && user.avatarurl && user.nickname)
|
|
47
|
+ setIsAuthedPhone(user && user.phone)
|
|
48
|
+ setIsAuthedYeZhu(user && user.verifyStatus === 'certified')
|
|
49
|
+ }, [user])
|
|
50
|
+
|
|
51
|
+ useEffect(() => {
|
|
52
|
+ setNeedAuthBasic((page.auth || []).indexOf('avatar') > -1)
|
|
53
|
+ setNeedAuthPhone((page.auth || []).indexOf('phone') > -1)
|
|
54
|
+ setNeedAuthYeZhu((page.auth || []).indexOf('yezhu') > -1)
|
|
55
|
+ }, [page])
|
38
|
56
|
|
39
|
57
|
// 埋点
|
40
|
58
|
useMountTrack()
|