广州矛调粤政易端
xusd
7 days ago d27794814b69d18aeb8ee96a46cae91d5613570c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-08-08 19:57:35
 * @LastEditTime: 2023-05-19 09:21:07
 * @LastEditors: lwh
 * @Version: 1.0.0
 * @Description: 底部操作栏页面
 */
import React, { useState } from 'react';
import { useLocation, useHistory } from 'react-router-dom';
import { WorkOutlined, MeOutlined, HomeOutlined, CloseOutlined } from 'dd-icons';
import './index.less';
import Overlay from '../Overlay';
import { tabBar_img_1, tabBar_img_2, tabBar_img_3, tabBar_img_8, tabBar_img_9, tabBar_img_11 } from '../../assets/img';
import { tabBar_img_10 } from '../../assets/icon';
 
const TabBarPage = ({ children }) => {
  const location = useLocation();
 
  const history = useHistory();
 
  const pathName = location?.pathname;
 
  // 更多操作显示
  const [moreFunctionVisible, setMoreFunctionVisible] = useState(false);
 
  // 更多操作
  const moreFunctionList = [
    // {
    //   title: '查人查房',
    //   subTitle: '通过关键字筛选人房信息',
    //   icon: tabBar_img_2,
    //   url: '/hztGrid/searchPersonRoom',
    //   key: '1',
    // },
    // {
    //   title: '工作日志',
    //   subTitle: '填写网格工作日志',
    //   icon: tabBar_img_8,
    //   url: '/hztGrid/workLog',
    //   key: '2',
    // },
    // {
    //   title: '网格概况',
    //   subTitle: '管辖网格整体情况',
    //   icon: tabBar_img_9,
    //   url: '/hztGrid/surveyGrid',
    //   key: '3',
    // },
    {
      title: '工作统计',
      subTitle: '个人网格工作统计',
      icon: tabBar_img_3,
      url: '/hztGrid/WorkStatistics',
      key: '4',
    },
    // {
    //   title: '迁出查询',
    //   subTitle: '查询本网格已迁出的居民',
    //   icon: tabBar_img_10,
    //   url: '/hztGrid/moveOut',
    //   key: '10',
    // },
    // {
    //   title: '房间走访',
    //   subTitle: '网格员上门走访房间并拍照',
    //   icon: tabBar_img_11,
    //   url: '/hztGrid/visitList',
    //   key: '11',
    // },
    // {
    //     title: '我的任务',
    //     subTitle: '显示个人相关的网格工作',
    //     icon: tabBar_img_1,
    //     url: '/hztGrid/task',
    //     key: '5',
    // },
    // {
    //     title: '事件上报',
    //     subTitle: '上报网格内的各类事件',
    //     icon: tabBar_img_6,
    //     url: '/hztGrid/eventInit?type=register',
    //     key: '6',
    // },
    // {
    //     title: '上报查询',
    //     subTitle: '查询已上报的网格事件进展',
    //     icon: tabBar_img_7,
    //     url: '/hztGrid/eventInit?type=search',
    //     key: '7',
    // },
    // {
    //   title: '我的消息',
    //   subTitle: '网格公告与系统通知',
    //   icon: tabBar_img_4,
    //   url: '/hztGrid/message',
    //   key: '8',
    // },
    // TODO:暂无扫一扫功能
    // {
    //     title: '扫一扫',
    //     subTitle: '扫描椰居码查看居民信息',
    //     icon: tabBar_img_5,
    //     url: '',
    //     key: '9',
    // },
  ];
 
  // 更多操作跳转
  function handleGoPage(item) {
    if (item.url) {
      history.push(item.url);
    }
    // 扫码TODO:暂无扫一扫功能
    // if (item.key === '5') {
    //     dd.scan({ type: 'all' })
    //         .then((res) => {})
    //         .catch(() => {
    //             showToast({ type: 'fail', content: '扫码失败' });
    //         });
    // }
  }
 
  // 切换tab
  function handleChangeTab(key) {
    if (key === location.pathname) return;
    history.push(key);
  }
 
  return (
    <>
      {children}
      <div className="tabBarPage-tabBar-height" />
      <div className="tabBarPage-tabBar">
        <div
          onClick={() => handleChangeTab('/hztGrid/homePage')}
          className={`tabBarPage-tabBar-item ${pathName === '/hztGrid/homePage' && 'tabBarPage-tabBar-itemActive'}`}
        >
          <HomeOutlined className="tabBarPage-tabBar-item-icon" />
          <div>首页</div>
        </div>
        <div className="tabBarPage-tabBar-item">
          <div className="tabBarPage-tabBar-more" onClick={() => setMoreFunctionVisible(true)}>
            <WorkOutlined />
          </div>
        </div>
        <div
          onClick={() => handleChangeTab('/hztGrid/me')}
          className={`tabBarPage-tabBar-item ${pathName === '/hztGrid/me' && 'tabBarPage-tabBar-itemActive'}`}
        >
          <MeOutlined className="tabBarPage-tabBar-item-icon" />
          <div>我的</div>
        </div>
      </div>
      {/* 更多操作 */}
      <>
        <div className="tabBarPage-function" style={{ transform: moreFunctionVisible ? 'translate3d(0, 0, 0)' : 'translate3d(0, 1000px, 0)' }}>
          {moreFunctionList.map((x) => {
            return (
              <div key={x.key} onClick={() => handleGoPage(x)} className="tabBarPage-function-item">
                <img src={x.icon} alt="" className="tabBarPage-function-img" />
                <div>
                  <div className="tabBarPage-function-title">{x.title}</div>
                  <div className="tabBarPage-function-text">{x.subTitle}</div>
                </div>
              </div>
            );
          })}
        </div>
        <div
          style={{ display: moreFunctionVisible ? 'flex' : 'none' }}
          className="tabBarPage-function-close"
          onClick={() => setMoreFunctionVisible(false)}
        >
          <CloseOutlined />
        </div>
        <Overlay show={moreFunctionVisible} onOverlay={() => setMoreFunctionVisible(false)} bgColor="#333333" />
      </>
    </>
  );
};
 
export default TabBarPage;