Yansen 2 yıl önce
ebeveyn
işleme
c9a6a70868

+ 3
- 2
config/dev.js Dosyayı Görüntüle

@@ -3,8 +3,9 @@ module.exports = {
3 3
     NODE_ENV: '"development"'
4 4
   },
5 5
   defineConstants: {
6
-    HOST: '"http://127.0.0.1:9087"'
7
-    // HOST: '"http://192.168.1.2:9087"'
6
+    HOST: '"http://127.0.0.1:9087"',
7
+    // HOST: '"http://192.168.1.2:9087"',
8
+    AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
8 9
   },
9 10
   mini: {},
10 11
   h5: {}

+ 2
- 1
config/prod.js Dosyayı Görüntüle

@@ -3,7 +3,8 @@ module.exports = {
3 3
     NODE_ENV: '"production"'
4 4
   },
5 5
   defineConstants: {
6
-    HOST: '"https://t.njyz.tech"'
6
+    HOST: '"https://t.njyz.tech"',
7
+    AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
7 8
   },
8 9
   mini: {},
9 10
   h5: {

+ 15
- 0
src/layouts/TabBar.jsx Dosyayı Görüntüle

@@ -42,6 +42,13 @@ const issue = {
42 42
   activeIcon: issueActiveIcon,
43 43
   page: '/pages/issue/edit/index'
44 44
 }
45
+const feedback = {
46
+  name: 'feedback',
47
+  label: '发布',
48
+  icon: issueIcon,
49
+  activeIcon: issueActiveIcon,
50
+  page: '/pages/issue/edit/index'
51
+}
45 52
 const check = {
46 53
   name: 'check',
47 54
   label: '测评标准',
@@ -83,6 +90,14 @@ export default (props) => {
83 90
       ]
84 91
     }
85 92
 
93
+    if (duty == ROLE_CITIZEN) {
94
+      return [
95
+        home,
96
+        feedback,
97
+        mine,
98
+      ]
99
+    }
100
+
86 101
     return [];
87 102
   }, [duty]);
88 103
 

+ 21
- 0
src/pages/home/components/Banner.jsx Dosyayı Görüntüle

@@ -0,0 +1,21 @@
1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { Image } from '@tarojs/components';
4
+import { ROLE_CITIZEN } from '@/utils/user';
5
+
6
+const style = {
7
+  width: 'calc(100% - var(--main-space) * 2)',
8
+  margin: 'var(--main-space)',
9
+  borderRadius: '6px',
10
+  overfollow: 'hidden',
11
+}
12
+
13
+export default (props) => { 
14
+  
15
+  const { duty } = props;
16
+  
17
+  return !duty || duty == ROLE_CITIZEN ? (
18
+    // eslint-disable-next-line no-undef
19
+    <Image mode="widthFix" src={AD_IMAGE} style={style}></Image>
20
+  ) : null;
21
+}

+ 0
- 24
src/pages/home/components/BannerCard.jsx Dosyayı Görüntüle

@@ -1,24 +0,0 @@
1
-import React from 'react';
2
-import { View } from '@tarojs/components';
3
-import style from './banner-card.module.less';
4
-
5
-export default (props) => {
6
-  return (
7
-    <View className={style['banner-card-box']}>
8
-      <View className={style['banner-card']}>
9
-        <View className={style.item}>
10
-          <View>12</View>
11
-          <View className={style.sub}>已上报</View>
12
-        </View>
13
-        <View className={style.item}>
14
-          <View>8</View>
15
-          <View className={style.sub}>已交办</View>
16
-        </View>
17
-        <View className={style.item}>
18
-          <View>6</View>
19
-          <View className={style.sub}>未交办</View>
20
-        </View>
21
-      </View>
22
-    </View>
23
-  )
24
-}

+ 13
- 6
src/pages/home/components/Head.jsx Dosyayı Görüntüle

@@ -3,16 +3,23 @@ import { View, Image } from '@tarojs/components';
3 3
 import { ActionSheet, Cell } from '@antmjs/vantui';
4 4
 import { ROLES, ROLE_CITIZEN } from '@/utils/user';
5 5
 import logo from '@/assets/image/logo.png';
6
-import avatar from '@/assets/icons/avatar.png';
6
+import Icon from '@/assets/icons/avatar.png';
7 7
 import style from './head.module.less';
8 8
 
9 9
 export default (props) => {
10
-  const { user = {}, duty, onDutyChange } = props;
11
-  const { dutyList = [] } = user;
10
+  const { user, person, duty, onDutyChange } = props;
11
+  const { dutyList = [] } = user || {};
12 12
   const role = ROLES[duty || ROLE_CITIZEN];
13 13
 
14 14
   const [show, setShow] = React.useState(false);
15 15
 
16
+  const [name, avatar] = React.useMemo(() => {
17
+    return [
18
+      user?.name || person?.name || '市民先生',
19
+      user?.avatar || person?.avatar || logo,
20
+    ];
21
+  }, [user, person]);
22
+
16 23
   const actions = React.useMemo(() => {
17 24
     return dutyList.map(x => ({name: ROLES[x], value: x}));
18 25
   }, [dutyList]);
@@ -29,10 +36,10 @@ export default (props) => {
29 36
   return (
30 37
     <View className={style.head}>
31 38
       <View className={style.profile}>
32
-        <View style={{ letterSpacing: '2px' }}>Hi, {user.name}!</View>
39
+        <View style={{ letterSpacing: '2px' }}>Hi, {name}!</View>
33 40
         <View className={style.badge} onClick={onClick}>
34 41
           <View className={style.icon}>
35
-            <Image src={avatar} />
42
+            <Image src={Icon} />
36 43
           </View>
37 44
           <View>{role}</View>
38 45
         </View>
@@ -46,7 +53,7 @@ export default (props) => {
46 53
         />
47 54
       </View>
48 55
       <View className={style.avatar}>
49
-        <Image src={user.avatar || logo}></Image>
56
+        <Image src={avatar}></Image>
50 57
       </View>
51 58
     </View>
52 59
   )

+ 38
- 0
src/pages/home/components/StatCard.jsx Dosyayı Görüntüle

@@ -0,0 +1,38 @@
1
+import React from 'react';
2
+import { View } from '@tarojs/components';
3
+import { ROLE_CITIZEN } from '@/utils/user';
4
+import { getIndexData } from '@/services/stat';
5
+import style from './stat-card.module.less';
6
+
7
+export default (props) => {
8
+  const { duty } = props;
9
+
10
+  const [list, setList] = React.useState([]);
11
+
12
+  const classNames = React.useMemo(() => {
13
+    return [
14
+      style['stat-card-box'],
15
+      !duty || duty == ROLE_CITIZEN ? style['no-bg-effect'] : false
16
+    ].filter(Boolean).join(' ');
17
+  }, [duty])
18
+
19
+  React.useEffect(() => {
20
+    const du = duty || ROLE_CITIZEN
21
+    getIndexData(du).then(setList);
22
+  }, [duty]);
23
+
24
+  return (
25
+    <View className={classNames}>
26
+      <View className={style['stat-card']}>
27
+        {
28
+          list.map(x => (
29
+            <View key={x.name} className={style.item}>
30
+              <View>{x.value}</View>
31
+              <View className={style.sub}>{x.name}</View>
32
+            </View>
33
+          ))
34
+        }
35
+      </View>
36
+    </View>
37
+  )
38
+}

src/pages/home/components/banner-card.module.less → src/pages/home/components/stat-card.module.less Dosyayı Görüntüle

@@ -1,5 +1,5 @@
1 1
 
2
-.banner-card-box {
2
+.stat-card-box {
3 3
   width: 100%;
4 4
   position: relative;
5 5
   padding: 0 var(--main-space);
@@ -15,7 +15,13 @@
15 15
     z-index: 0;
16 16
   }
17 17
 
18
-  .banner-card {
18
+  &.no-bg-effect {
19
+    &::before {
20
+      display: none;
21
+    }
22
+  }
23
+
24
+  .stat-card {
19 25
     position: relative;
20 26
     background: #FFFFFF;
21 27
     box-shadow: 0px 18px 22px 0px rgba(0,0,0,0.04);

+ 15
- 6
src/pages/home/index.jsx Dosyayı Görüntüle

@@ -3,9 +3,10 @@ import { View, Text, Image } from '@tarojs/components'
3 3
 import Page from '@/layouts/index';
4 4
 import { useModel } from '@/store';
5 5
 import MenuIcon from '@/components/MenuIcon';
6
-import { ROLE_INSPECTOR, ROLE_MANAGER, ROLE_ORG_USER, ROLE_QUERY_PERSON } from '@/utils/user';
6
+import { ROLE_CITIZEN, ROLE_INSPECTOR, ROLE_MANAGER, ROLE_ORG_USER, ROLE_QUERY_PERSON } from '@/utils/user';
7 7
 import Head from './components/Head';
8
-import BannerCard from './components/BannerCard';
8
+import Banner from './components/Banner';
9
+import StatCard from './components/StatCard';
9 10
 import './index.less';
10 11
 
11 12
 const menus = {
@@ -45,11 +46,18 @@ const menus = {
45 46
     { icon: 'icon3', text: '已 办 结', link: '/pages/issue/list2/index?title=已办结&bizStatus=end' },
46 47
     { icon: 'icon7', text: '统计查询', link: '' },
47 48
   ],
49
+  
50
+  // 督察员
51
+  [ROLE_CITIZEN]: [
52
+    { icon: 'icon1', text: '未 处 理', link: '/pages/issue/list2/index?title=未处理&bizStatus=start' },
53
+    { icon: 'icon2', text: '处 理 中', link: '/pages/issue/list2/index?title=处理中&bizStatus=assigned' },
54
+    { icon: 'icon7', text: '已 打 回', link: '' },
55
+  ],
48 56
 }
49 57
 
50 58
 export default (props) => {
51 59
 
52
-  const { user, duty, updateDuty } = useModel('user');
60
+  const { user, person, duty, updateDuty } = useModel('user');
53 61
 
54 62
   const menuArr = React.useMemo(() => {
55 63
     if (!duty) return [];
@@ -58,9 +66,10 @@ export default (props) => {
58 66
   }, [duty])
59 67
 
60 68
   return (
61
-    <Page tabBar="home" className='home-page'>
62
-      <Head user={user} duty={duty} onDutyChange={updateDuty} />
63
-      <BannerCard />
69
+    <Page tabBar="home" className="home-page">
70
+      <Head user={user} person={person} duty={duty} onDutyChange={updateDuty} />
71
+      <Banner  duty={duty} />
72
+      <StatCard duty={duty} />
64 73
 
65 74
       <View className="menu-icons">
66 75
         {

+ 17
- 6
src/pages/login/components/Bottom.jsx Dosyayı Görüntüle

@@ -1,16 +1,27 @@
1 1
 import React from 'react';
2
-import { View, Image } from '@tarojs/components';
3
-import WeChat from '../../../assets/image/WeChat.png';
2
+import { View, Image, Button } from '@tarojs/components';
3
+import Icon from '@/assets/image/WeChat.png';
4
+import { useModel } from '@/store';
4 5
 import style from './bottom.module.less';
5 6
 
6 7
 export default (props) => {
8
+
9
+  const { signinByPhone } = useModel('user');
10
+
11
+  const onGetPhoneNumber = (e) => {
12
+    const code = e.detail.code;
13
+    signinByPhone(code).then(props.onSuccess);
14
+  }
15
+
7 16
   return (
8 17
     <View>
9
-      <View className={style['txt-box2']}>——其他登录方式——</View>
18
+      <View className={style['txt-box2']}>—— 没有账号?微信登录 ——</View>
10 19
       <View className={style['img-box2']}>
11
-        <Image className={style['img-wechat']}
12
-          src={WeChat}
13
-        />
20
+        <Button openType="getPhoneNumber" onGetPhoneNumber={onGetPhoneNumber}>
21
+          <Image className={style['img-wechat']}
22
+            src={Icon}
23
+          />
24
+        </Button>
14 25
       </View>
15 26
       <View className={style['wechat-login']}>微信登录</View>
16 27
     </View>

+ 11
- 0
src/pages/login/components/bottom.module.less Dosyayı Görüntüle

@@ -9,6 +9,17 @@
9 9
   width: 100px;
10 10
   height: 100px;
11 11
   margin: 0 auto;
12
+
13
+  button {
14
+    padding: 0;
15
+    line-height: 1em;
16
+    background: transparent;
17
+
18
+    &::after {
19
+      border: none;
20
+    }
21
+  }
22
+
12 23
   .img-wechat {
13 24
     width: 100px;
14 25
     height: 100px;

+ 4
- 9
src/pages/login/index.jsx Dosyayı Görüntüle

@@ -10,14 +10,9 @@ import './index.less'
10 10
 export default (props) => {
11 11
 
12 12
   const onSuccess = () => {
13
-    Taro.navigateBack({
14
-      delta: 1,
15
-      fail: () => {
16
-        Taro.reLaunch({
17
-          url: '/pages/home/index'
18
-        })
19
-      }
20
-    });
13
+    Taro.reLaunch({
14
+      url: '/pages/home/index'
15
+    })
21 16
   }
22 17
 
23 18
   return (
@@ -25,7 +20,7 @@ export default (props) => {
25 20
       <View className="login-box">
26 21
         <Head />
27 22
         <Form onSuccess={onSuccess} />
28
-        <Bottom />
23
+        <Bottom onSuccess={onSuccess} />
29 24
       </View>
30 25
     </Page>
31 26
   )

+ 2
- 3
src/pages/reset-password/index.jsx Dosyayı Görüntüle

@@ -1,7 +1,6 @@
1 1
 import React from 'react';
2 2
 import Taro from '@tarojs/taro';
3 3
 import { View } from '@tarojs/components';
4
-import Page from '@/layouts/index';
5 4
 import { changePwd } from '@/services/wxma'; 
6 5
 import Captcha from './components/Captcha';
7 6
 import ResetPwd from './components/ResetPwd';
@@ -28,7 +27,7 @@ export default (props) => {
28 27
   }
29 28
   
30 29
   return (
31
-    <Page>
30
+    <View>
32 31
       <View className="reset-password-box">
33 32
         <View className={transClass}>
34 33
           <View>
@@ -39,6 +38,6 @@ export default (props) => {
39 38
           </View>
40 39
         </View>
41 40
       </View>
42
-    </Page>
41
+    </View>
43 42
   )
44 43
 }

+ 8
- 0
src/services/stat.js Dosyayı Görüntüle

@@ -0,0 +1,8 @@
1
+import request from "@/utils/request";
2
+
3
+/**
4
+ * 首页统计
5
+ * @param {*} duty 
6
+ * @returns 
7
+ */
8
+export const getIndexData = duty => request('/api/ma/index-stat', { params: { duty } })

+ 1
- 1
src/services/wxma.js Dosyayı Görüntüle

@@ -3,7 +3,7 @@ import request from '@/utils/request';
3 3
 /*
4 4
  * 授权手机
5 5
  */
6
-export const authPhone = (id, data) => request(`/api/ma/auth-phone`, { data, method: 'put' });
6
+export const authPhone = (code) => request(`/api/ma/auth-phone`, { params: { code }, method: 'put' });
7 7
 
8 8
 /*
9 9
  * 授权头像

+ 12
- 2
src/store/user.js Dosyayı Görüntüle

@@ -1,7 +1,8 @@
1 1
 import React from 'react';
2 2
 import Taro from '@tarojs/taro';
3 3
 import md5 from 'md5';
4
-import { login, signin, currentUser } from '@/services/wxma';
4
+import { login, signin, currentUser, authPhone } from '@/services/wxma';
5
+import { ROLE_CITIZEN } from '@/utils/user';
5 6
 
6 7
 export default function useUser() {
7 8
   const [person, setPerson] = React.useState();
@@ -16,7 +17,7 @@ export default function useUser() {
16 17
     });
17 18
   }
18 19
 
19
-  const updateDuty = (d) => {
20
+  const updateDuty = (d = ROLE_CITIZEN) => {
20 21
     setDuty(d);
21 22
     Taro.setStorageSync('duty', d);
22 23
   }
@@ -54,6 +55,14 @@ export default function useUser() {
54 55
     })
55 56
   }
56 57
 
58
+  const signinByPhone = (code) => {
59
+    return authPhone(code).then(res => {
60
+      setUser(res.user);
61
+      initDuty(res.user);
62
+      setPerson(res.person);
63
+    })
64
+  }
65
+
57 66
   return {
58 67
     user,
59 68
     person,
@@ -62,5 +71,6 @@ export default function useUser() {
62 71
     signin: maSignIn,
63 72
     login: maLogin,
64 73
     updateDuty,
74
+    signinByPhone,
65 75
   }
66 76
 }