|
@@ -1,29 +1,44 @@
|
1
|
|
-import React, { useState, useEffect } from 'react'
|
|
1
|
+import React, { useState, useEffect, useMemo } from 'react'
|
2
|
2
|
import NavHeader from '@/components/NavHeader/index'
|
3
|
3
|
import Taro from '@tarojs/taro'
|
|
4
|
+import { Block } from '@tarojs/components'
|
4
|
5
|
import request, { apis } from '@/utils/request'
|
5
|
6
|
import { useModel } from '@/store'
|
6
|
7
|
import Page from '@/layouts'
|
|
8
|
+import { PERSON_TYPE } from '@/utils/constants'
|
7
|
9
|
import '@/assets/css/reset.less'
|
8
|
10
|
import '@/assets/css/iconfont.less'
|
9
|
11
|
import './index.less'
|
10
|
12
|
|
11
|
|
-export default function WoDe () {
|
12
|
|
-
|
13
|
|
- const { user, setUser } = useModel('user')
|
14
|
|
- const [UserTab] = useState([
|
|
13
|
+// 二维数组用于页面美化加分隔栏
|
|
14
|
+// personTypes 用于指定人员身份
|
|
15
|
+const menuGroup = [
|
|
16
|
+ [
|
15
|
17
|
{ icon: 'iconrenzheng1', name: '业主认证', id: 1, router: '/pages/WoDe/WoDeRenZheng/index' },
|
16
|
18
|
{ icon: 'iconjifenguize', name: '积分明细', id: 2, router: '/pages/FuLi/JiFenMingXi/index' },
|
17
|
19
|
{ icon: 'iconjiaofei', name: '物业缴费', id: 3, router: '/pages/WoDe/WoDeJiaoFei/index' },
|
18
|
|
- { icon: 'iconfuwu1', name: '物业报修', id: 4, router: '/pages/WoDe/WoDeGongDan/index' }
|
19
|
|
- ])
|
20
|
|
- const [MoreUserTab] = useState([
|
|
20
|
+ { icon: 'iconfuwu1', name: '物业报修', id: 4, router: '/pages/WoDe/WoDeGongDan/index' },
|
|
21
|
+ // { icon: 'iconfuwu1', name: '业主工单', id: 4, router: '/pages/WoDe/WoDeGongDan/index', personTypes: [PERSON_TYPE.LIFE_CONSULTANT] },
|
|
22
|
+ { icon: 'iconfuwu1', name: '业主报修', id: 4, router: '/pages/WoDe/WoDeGongDan/index' },
|
|
23
|
+ ],
|
|
24
|
+ [
|
21
|
25
|
{ icon: 'iconerweima', name: '推荐二维码', id: 5, router: '/pages/WoDe/TuiJianErWeiMa/index' },
|
22
|
26
|
// { icon: 'iconfenxiang', name: '推荐分享', id: 6, router: '/pages/WoDe/TuiJianFenXiang/index' },
|
23
|
27
|
{ icon: 'iconhuodong', name: '参与活动', id: 7, router: '/pages/WoDe/WoDeHuoDong/index' }
|
24
|
|
- ])
|
|
28
|
+ ]
|
|
29
|
+]
|
|
30
|
+
|
|
31
|
+export default function WoDe () {
|
|
32
|
+
|
|
33
|
+ const { user, setUser } = useModel('user')
|
25
|
34
|
const [DataLock, setDataLock] = useState(false)
|
26
|
35
|
|
|
36
|
+ const menuList = useMemo(() => {
|
|
37
|
+ return menuGroup.map(menus => menus.filter(menu => {
|
|
38
|
+ return (!menu.personTypes || !menu.personTypes.length || menu.personTypes.indexOf(user.personType) > -1)
|
|
39
|
+ })).filter(menus => menus && menus.length)
|
|
40
|
+ }, [user.personType])
|
|
41
|
+
|
27
|
42
|
useEffect(() => {
|
28
|
43
|
if (user !== null) {
|
29
|
44
|
request({ ...apis.getUserInfo }).then((res) => {
|
|
@@ -74,27 +89,26 @@ export default function WoDe () {
|
74
|
89
|
{/* 用户选项 */}
|
75
|
90
|
<view className='UserTab'>
|
76
|
91
|
{
|
77
|
|
- UserTab.map((item, index) => (
|
78
|
|
- <view key={`UserTab-${index}`} className='flex-h' onClick={() => { Taro.navigateTo({ url: item.router }) }}>
|
79
|
|
- <text className={`iconfont ${item.icon}`}></text>
|
80
|
|
- <view className='flex-h flex-item'>
|
81
|
|
- <text className='flex-item'>{item.name}</text>
|
82
|
|
- <text className='iconfont iconjiantouright'></text>
|
83
|
|
- </view>
|
84
|
|
- </view>
|
85
|
|
- ))
|
86
|
|
- }
|
87
|
|
- <view className='Line'></view>
|
88
|
|
- {
|
89
|
|
- MoreUserTab.map((item, index) => (
|
90
|
|
- <view key={`UserTab-${index}`} className='flex-h' onClick={() => { Taro.navigateTo({ url: item.router }) }}>
|
91
|
|
- <text className={`iconfont ${item.icon}`}></text>
|
92
|
|
- <view className='flex-h flex-item'>
|
93
|
|
- <text className='flex-item'>{item.name}</text>
|
94
|
|
- <text className='iconfont iconjiantouright'></text>
|
95
|
|
- </view>
|
96
|
|
- </view>
|
97
|
|
- ))
|
|
92
|
+ menuList.map((menus, inx) => {
|
|
93
|
+ return (
|
|
94
|
+ <Block key={inx}>
|
|
95
|
+ {
|
|
96
|
+ inx > 0 && <view className='Line'></view>
|
|
97
|
+ }
|
|
98
|
+ {
|
|
99
|
+ menus.map((item, index) => (
|
|
100
|
+ <view key={`UserTab-${index}`} className='flex-h' onClick={() => { Taro.navigateTo({ url: item.router }) }}>
|
|
101
|
+ <text className={`iconfont ${item.icon}`}></text>
|
|
102
|
+ <view className='flex-h flex-item'>
|
|
103
|
+ <text className='flex-item'>{item.name}</text>
|
|
104
|
+ <text className='iconfont iconjiantouright'></text>
|
|
105
|
+ </view>
|
|
106
|
+ </view>
|
|
107
|
+ ))
|
|
108
|
+ }
|
|
109
|
+ </Block>
|
|
110
|
+ )
|
|
111
|
+ })
|
98
|
112
|
}
|
99
|
113
|
</view>
|
100
|
114
|
|