浏览代码

Merge branch 'main' of http://git.ycjcjy.com/marketing/miniapp into main

1002884655 3 年前
父节点
当前提交
c43f9630f6

+ 0
- 10
src/components/Auth/AuthPage.jsx 查看文件

@@ -1,10 +0,0 @@
1
-import React from 'react'
2
-import './style.scss'
3
-
4
-export default (props) => {
5
-  return (
6
-    <View>
7
-
8
-    </View>
9
-  )
10
-}

+ 54
- 0
src/components/Auth/AuthPage/index.jsx 查看文件

@@ -0,0 +1,54 @@
1
+import React, { useState, useEffect } from 'react'
2
+import Taro from '@tarojs/taro'
3
+import { View, Image } from '@tarojs/components'
4
+import Disclaimer from '@/components/Disclaimer'
5
+import '@/assets/css/iconfont.css'
6
+import useAuth from '../useAuth'
7
+import './index.scss'
8
+
9
+export default (props) => {
10
+
11
+  const [loading, setLoading] = useState(false)
12
+  const { updateUserInfo } = useAuth()
13
+  
14
+  const handleGetUserInfo = () => {
15
+    Taro.getUserProfile({
16
+      lang: 'zh_CN',
17
+      desc: '用于完成平台注册',
18
+      success: (res) => {
19
+        const { errMsg, ...data } = res || {}
20
+        if (errMsg === 'getUserProfile:ok') {
21
+          setLoading(true)
22
+          updateUserInfo(data).then(() => {
23
+            setLoading(false)
24
+          }).catch((err) => {
25
+            console.error(err)
26
+            setLoading(false)
27
+          })
28
+        } else {
29
+          console.error(errMsg);
30
+          Taro.showToast({
31
+            title: '授权头像失败',
32
+            icon: 'none',
33
+            duration: 2000
34
+          })
35
+        }
36
+      }
37
+    })
38
+  }
39
+
40
+  return (
41
+    <View className='components NeedLogin flex-v'>
42
+      <View className='Logo'>
43
+        <Image mode='aspectFit' className='centerLabel' src={require('@/assets/logo.png')} />
44
+      </View>
45
+      <View className='LoginBtn'>
46
+        <button loading={loading} onClick={handleGetUserInfo}>微信登录</button>
47
+      </View>
48
+      <View className='flex-item'></View>
49
+      <View className='Bottom'>
50
+        <Disclaimer />
51
+      </View>
52
+    </View>
53
+  )
54
+}

src/pages/mine/components/NeedLogin/index.scss → src/components/Auth/AuthPage/index.scss 查看文件

@@ -19,7 +19,7 @@
19 19
     position: relative;
20 20
     overflow: hidden;
21 21
     margin-top: 195px;
22
-    >text {
22
+    >button {
23 23
       display: block;
24 24
       text-align: center;
25 25
       font-size: 32px;

+ 3
- 1
src/layout/index.js 查看文件

@@ -6,6 +6,7 @@ import Overlay from '@/components/Overlay'
6 6
 import Loading from '@/components/Loading'
7 7
 import AuthAvatar from '@/components/Auth/AuthAvatar'
8 8
 import AuthPhone from '@/components/Auth/AuthPhone'
9
+import AuthPage from '@/components/Auth/AuthPage'
9 10
 import Spin from '@/components/Spin/Spin2'
10 11
 import FixedConsultant from '@/components/FixedConsultant'
11 12
 import FirstScreen from '@/components/FirstScreen'
@@ -26,7 +27,7 @@ export default (ChildComponent) => (props) => {
26 27
   const router = useRouter()
27 28
   const page = routes.filter((r) => (router.path.indexOf(r.page) > -1))[0]
28 29
   const [loading, setLoading] = useState(false)
29
-  const [authPhone, authAvatar] = useAuth(person, page)
30
+  const [authPhone, authAvatar, authPage] = useAuth(person, page)
30 31
 
31 32
   const { id } = router.params
32 33
   const showConsultant = page.shortcut && page.shortcut.consultant
@@ -93,6 +94,7 @@ export default (ChildComponent) => (props) => {
93 94
           <AuthAvatar />
94 95
         </View>
95 96
       </Overlay>
97
+      { authPage && <AuthPage /> }
96 98
       <Spin size={32} spinning={spinning} />
97 99
       {
98 100
         person && !!person.personId && (

+ 12
- 1
src/layout/useAuth.js 查看文件

@@ -3,6 +3,7 @@ import { useState, useEffect } from 'react'
3 3
 export default function useAuth(person, page) {
4 4
   const [authPhone, setAuthPhone] = useState(false)
5 5
   const [authAvatar, setAuthAvatar] = useState(false)
6
+  const [authPage, setAuthPage] = useState(false)
6 7
 
7 8
   useEffect(() => {
8 9
     if (page && page.auth && page.auth.length) {
@@ -23,11 +24,21 @@ export default function useAuth(person, page) {
23 24
           setAuthAvatar(false)
24 25
         }
25 26
       }
27
+
28
+      // 如果需要授权头像
29
+      if (page.auth.indexOf('page') > -1) {
30
+        if (person.inited && (!person.avatarurl || person.avatarurl.indexOf('default_avatar') > -1)) {
31
+          setAuthPage(true)
32
+        } else {
33
+          setAuthPage(false)
34
+        }
35
+      }
26 36
     } else {
27 37
       setAuthPhone(false)
28 38
       setAuthAvatar(false)
39
+      setAuthPage(false)
29 40
     }
30 41
   }, [person, page])
31 42
 
32
-  return [authPhone, authAvatar]
43
+  return [authPhone, authAvatar, authPage]
33 44
 }

+ 0
- 30
src/pages/mine/components/NeedLogin/index.jsx 查看文件

@@ -1,30 +0,0 @@
1
-import React, { useState, useEffect } from 'react'
2
-import './index.scss'
3
-import { Image } from '@tarojs/components'
4
-import '@/assets/css/iconfont.css'
5
-
6
-export default function Banner (props) {
7
-  return (
8
-    <view className='components NeedLogin flex-v'>
9
-      <view className='Logo'>
10
-        <Image mode='aspectFit' className='centerLabel' src={require('@/assets/logo.png')} />
11
-      </view>
12
-      <view className='LoginBtn'>
13
-        <text>微信登录</text>
14
-      </view>
15
-      <view className='flex-item'></view>
16
-      <view className='Bottom'>
17
-        <view>
18
-          <view>
19
-            <text className='iconfont icon-shengming'></text>
20
-            <text>免责声明</text>
21
-          </view>
22
-          <view>
23
-            <text>以上价格仅供参考,具体一房一价的信息以售楼处展示为准。房屋位置交通、医疗、教育、商业等配套信息,来源于第三方不作为要约,仅供参考,双方具体权利义务应以法律规定及买卖合同约定为准。本平台对项目周边文化教育的介绍旨在提供相关信息1 意味着信息发布方对就学安排作出承诺。相关教育资首页信息存在调整的可能,应以政府教育主管部门门及办学颁布的政策规定为准。详情请仔细阅读</text>
24
-            <text className='active'>《新联家使用免责条款》</text>
25
-          </view>
26
-        </view>
27
-      </view>
28
-    </view>
29
-  )
30
-}

+ 0
- 14
src/pages/mine/index.jsx 查看文件

@@ -10,7 +10,6 @@ import { getImgURL } from '@/utils/image'
10 10
 import { UPDATE_USER_INFO, ROLE_CODE } from '@/constants/user'
11 11
 import store from '@/store'
12 12
 import './index.scss'
13
-import NeedLogin from './components/NeedLogin'
14 13
 import MineMenuList from './tabData'
15 14
 
16 15
 const defaultRuleImage = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon18.jpg'
@@ -23,11 +22,9 @@ export default withLayout(() => {
23 22
   const user = useSelector(state => state.user)
24 23
   const [UserRole, setUserRole] = useState(null) // 1-普通用户 2-经纪人 3-置业顾问 4-驻场管理
25 24
   const [MenuList, setMenuList] = useState([])
26
-  const [ShowLogin, setShowLogin] = useState(false)
27 25
   const { dispatch } = store
28 26
 
29 27
   useEffect(() => {
30
-    setShowLogin(false)
31 28
     if (user?.userInfo?.person?.personId) {
32 29
       const person = user.userInfo.person
33 30
       setUserRole(person.personType === ROLE_CODE.CUSTOMER || person.personType === ROLE_CODE.DRIFT ? 1 : person.personType === ROLE_CODE.CHANNEL_AGENT ? 2 : person.personType === ROLE_CODE.CONSULTANT ? 3 : 4)
@@ -70,16 +67,6 @@ export default withLayout(() => {
70 67
 
71 68
       <ScrollView scroll-y>
72 69
         <view className='PageContent'>
73
-
74
-          {/* 需要登录 */}
75
-          {
76
-            ShowLogin &&
77
-            <NeedLogin></NeedLogin>
78
-          }
79
-
80
-          {/* 登录后 */}
81
-          {
82
-            !ShowLogin &&
83 70
             <view className='Content'>
84 71
 
85 72
               {/* 用户信息 */}
@@ -127,7 +114,6 @@ export default withLayout(() => {
127 114
               </view>
128 115
 
129 116
             </view>
130
-          }
131 117
         </view>
132 118
 
133 119
         <view className='copyright'>

+ 17
- 0
src/routes.js 查看文件

@@ -36,6 +36,7 @@ const routes = [
36 36
     pkg: 'main',
37 37
     isTab: true,
38 38
     type: 'mine',
39
+    auth: ['page'],
39 40
   },
40 41
 
41 42
   // 聊天
@@ -254,6 +255,7 @@ const routes = [
254 255
     page: 'pages/mine/myRecommendCode/index',
255 256
     pkg: 'main',
256 257
     type: 'mine',
258
+    auth: ['phone'],
257 259
   },
258 260
   {
259 261
     name: '房贷计算器',
@@ -266,18 +268,21 @@ const routes = [
266 268
     page: 'pages/mine/userInfo/index',
267 269
     pkg: 'main',
268 270
     type: 'mine',
271
+    auth: ['phone', 'avatar'],
269 272
   },
270 273
   {
271 274
     name: '成为驻场管理',
272 275
     page: 'pages/mine/toBeManager/index',
273 276
     pkg: 'main',
274 277
     type: 'mine',
278
+    auth: ['phone'],
275 279
   },
276 280
   {
277 281
     name: '成为经纪人',
278 282
     page: 'pages/mine/toBeAgent/index',
279 283
     pkg: 'main',
280 284
     type: 'mine',
285
+    auth: ['phone'],
281 286
   },
282 287
   {
283 288
     name: '我的分享',
@@ -290,6 +295,7 @@ const routes = [
290 295
     page: 'pages/mine/myCourse/index',
291 296
     pkg: 'main',
292 297
     type: 'curriculum',
298
+    auth: ['phone'],
293 299
   },
294 300
   {
295 301
     name: '我的活动',
@@ -302,12 +308,14 @@ const routes = [
302 308
     page: 'pages/mine/myCustomer/index',
303 309
     pkg: 'main',
304 310
     type: 'mine',
311
+    auth: ['phone'],
305 312
   },
306 313
   {
307 314
     name: '客户详情',
308 315
     page: 'pages/mine/myCustomerDetail/index',
309 316
     pkg: 'main',
310 317
     type: 'mine',
318
+    auth: ['phone'],
311 319
   },
312 320
   {
313 321
     name: '我的收藏',
@@ -320,54 +328,63 @@ const routes = [
320 328
     page: 'pages/channel/partnerChannel/index',
321 329
     pkg: 'subpackages',
322 330
     type: 'mine',
331
+    auth: ['phone'],
323 332
   },
324 333
   {
325 334
     name: '添加客户',
326 335
     page: 'pages/mine/addCustomer/index',
327 336
     pkg: 'main',
328 337
     type: 'mine',
338
+    auth: ['phone'],
329 339
   },
330 340
   {
331 341
     name: '驻场管理',
332 342
     page: 'pages/marketing/residentManager/index',
333 343
     pkg: 'subpackages',
334 344
     type: 'mine',
345
+    auth: ['phone'],
335 346
   },
336 347
   {
337 348
     name: '确认到访',
338 349
     page: 'pages/marketing/sureVisit/index',
339 350
     pkg: 'subpackages',
340 351
     type: 'mine',
352
+    auth: ['phone'],
341 353
   },
342 354
   {
343 355
     name: '变更交易节点',
344 356
     page: 'pages/marketing/changeVisit/index',
345 357
     pkg: 'subpackages',
346 358
     type: 'mine',
359
+    auth: ['phone'],
347 360
   },
348 361
   {
349 362
     name: '盘客工具',
350 363
     page: 'pages/consultant/statCustomer/index',
351 364
     pkg: 'subpackages',
352 365
     type: 'mine',
366
+    auth: ['phone'],
353 367
   },
354 368
   {
355 369
     name: '客户信息',
356 370
     page: 'pages/mine/customerDetail/index',
357 371
     pkg: 'main',
358 372
     type: 'mine',
373
+    auth: ['phone'],
359 374
   },
360 375
   {
361 376
     name: '客户分析',
362 377
     page: 'pages/consultant/customerAnalyse/index',
363 378
     pkg: 'subpackages',
364 379
     type: 'mine',
380
+    auth: ['phone'],
365 381
   },
366 382
   {
367 383
     name: '个人主页',
368 384
     page: 'pages/consultant/myHomepage/index',
369 385
     pkg: 'subpackages',
370 386
     type: 'mine',
387
+    auth: ['phone'],
371 388
   },
372 389
   {
373 390
     name: '意见反馈',