Your Name il y a 2 ans
Parent
révision
20630cdb63

+ 1
- 0
config/index.js Voir le fichier

16
   },
16
   },
17
   copy: {
17
   copy: {
18
     patterns: [
18
     patterns: [
19
+      { from: 'src/assets/tabbar/', to: 'dist/assets/tabbar/' },
19
     ],
20
     ],
20
     options: {
21
     options: {
21
     }
22
     }

+ 21
- 10
src/app.config.js Voir le fichier

7
     'pages/index5/index',
7
     'pages/index5/index',
8
     'pages/reporting/index',
8
     'pages/reporting/index',
9
     'pages/reporting/detail/index',
9
     'pages/reporting/detail/index',
10
+    'pages/reset-password/index',
10
   ],
11
   ],
11
   tabBar: {
12
   tabBar: {
12
     list: [
13
     list: [
13
       {
14
       {
14
-        "pagePath": "pages/home/index",
15
-        "text": "首页"
15
+        pagePath: "pages/home/index",
16
+        text: "首页",
17
+        iconPath: "/assets/tabbar/page.png",
18
+        selectedIconPath: "/assets/tabbar/page click.png"
16
       },
19
       },
17
       {
20
       {
18
-        "pagePath": "pages/reporting/index",
19
-        "text": "公告"
21
+        pagePath: "pages/reporting/index",
22
+        text: "公告",
23
+        iconPath: "/assets/tabbar/notice.png",
24
+        selectedIconPath: "/assets/tabbar/notice click.png"
20
       },
25
       },
21
       {
26
       {
22
-        "pagePath": "pages/index3/index",
23
-        "text": "发布"
27
+        pagePath: "pages/index3/index",
28
+        text: "发布",
29
+        iconPath: "/assets/tabbar/release.png",
30
+        selectedIconPath: "/assets/tabbar/release click.png"
24
       },
31
       },
25
       {
32
       {
26
-        "pagePath": "pages/index4/index",
27
-        "text": "测评标准"
33
+        pagePath: "pages/index4/index",
34
+        text: "测评标准",
35
+        iconPath: "/assets/tabbar/evaluation.png",
36
+        selectedIconPath: "/assets/tabbar/evaluation click.png"
28
       },
37
       },
29
       {
38
       {
30
-        "pagePath": "pages/index5/index",
31
-        "text": "我的"
39
+        pagePath: "pages/index5/index",
40
+        text: "我的",
41
+        iconPath: "/assets/tabbar/my.png",
42
+        selectedIconPath: "/assets/tabbar/my click.png"
32
       },
43
       },
33
     ],
44
     ],
34
   },
45
   },

+ 0
- 1
src/layouts/index.jsx Voir le fichier

22
   }, [showTabBar]);
22
   }, [showTabBar]);
23
 
23
 
24
   React.useEffect(() => {
24
   React.useEffect(() => {
25
-    console.log('----------->', person, user);
26
     if (person && !user) {
25
     if (person && !user) {
27
       const currentPage = Taro.getCurrentPages().slice().pop();      
26
       const currentPage = Taro.getCurrentPages().slice().pop();      
28
       if ('pages/login/index' !== currentPage.route) {
27
       if ('pages/login/index' !== currentPage.route) {

+ 3
- 2
src/pages/home/components/Head.jsx Voir le fichier

1
 import React from 'react';
1
 import React from 'react';
2
-import { View } from '@tarojs/components';
2
+import { View, Image } from '@tarojs/components';
3
 import { ROLES, ROLE_CITIZEN } from '@/utils/user';
3
 import { ROLES, ROLE_CITIZEN } from '@/utils/user';
4
+import logo from '@/assets/image/logo.png';
4
 import style from './head.module.less';
5
 import style from './head.module.less';
5
 
6
 
6
 export default (props) => {
7
 export default (props) => {
18
         </View>
19
         </View>
19
       </View>
20
       </View>
20
       <View className={style.avatar}>
21
       <View className={style.avatar}>
21
-
22
+        <Image src={user.avatar || logo}></Image>
22
       </View>
23
       </View>
23
     </View>
24
     </View>
24
   )
25
   )

+ 5
- 0
src/pages/home/components/head.module.less Voir le fichier

57
     height: 16vw;
57
     height: 16vw;
58
     border-radius: 50%;
58
     border-radius: 50%;
59
     border: 4px solid #fff;
59
     border: 4px solid #fff;
60
+
61
+    image {
62
+      width: 100%;
63
+      height: 100%;
64
+    }
60
   }
65
   }
61
 }
66
 }

+ 102
- 0
src/pages/reset-password/components/Captcha.jsx Voir le fichier

1
+import React from 'react';
2
+import { View } from '@tarojs/components';
3
+import { Field, Button } from '@antmjs/vantui';
4
+import { getCaptcha } from '@/services/comm';
5
+
6
+export default (props) => {
7
+  const { onNext } = props;
8
+
9
+  const [loading, setLoading] = React.useState(false);
10
+  const [phone, setPhone] = React.useState();
11
+  const [phoneErr, setPhoneErr] = React.useState();
12
+  const [captcha, setCaptcha] = React.useState();
13
+  const [captchaErr, setCaptchaErr] = React.useState();
14
+  const [disabled, setDisabled] = React.useState(false);
15
+  const [sec, setSec] = React.useState(0);
16
+
17
+  const btnText = disabled ? `剩余 ${sec} 秒` : '获取验证码';
18
+
19
+  const onCaptcha = () => {
20
+    if (!phone || phone.length != 11) {
21
+      setPhoneErr('请输入正确的手机号')
22
+      return;
23
+    } else {
24
+      setPhoneErr();
25
+    }
26
+    
27
+    setLoading(true);
28
+    getCaptcha(phone).then(() => {
29
+      setLoading(false);
30
+      let left = 60;
31
+      
32
+      setDisabled(true);
33
+      setSec(left --);
34
+      const ticker = setInterval(() => {
35
+        left -= 1;
36
+        setSec(left);
37
+  
38
+        if (left <= 1) {
39
+          setDisabled(false);
40
+          clearInterval(ticker);
41
+        }
42
+      }, 1000);
43
+    }).catch(() => {
44
+      setLoading(false);
45
+    });
46
+  }
47
+
48
+  const handleNext = () => {
49
+    if (!phone) {
50
+      setPhoneErr('请输入手机号');
51
+    }
52
+
53
+    if (!captcha) {
54
+      setCaptchaErr('请输入验证码')
55
+    }
56
+
57
+    if (!phone || !captcha) {
58
+      return;
59
+    }
60
+
61
+    onNext({phone, captcha});
62
+  }
63
+  
64
+  return (
65
+    <View>
66
+      <View className="title">找回密码</View>
67
+      <View className="form-box">
68
+        <Field
69
+          value={phone}
70
+          loading={loading}
71
+          placeholder="请输入注册手机号"
72
+          onChange={e => setPhone(e.detail)}
73
+          errorMessage={phoneErr}
74
+          renderButton={
75
+            <Button
76
+              round
77
+              size="small"
78
+              type="primary"
79
+              disabled={disabled}
80
+              onClick={onCaptcha}
81
+            >
82
+              {btnText}
83
+            </Button>
84
+          }
85
+        ></Field>
86
+        <Field
87
+          value={captcha}
88
+          placeholder="请输入验证码"
89
+          errorMessage={captchaErr}
90
+          onChange={e => setCaptcha(e.detail)}
91
+        ></Field>
92
+      </View>
93
+      <View className="form-act">
94
+        <View>
95
+        </View>
96
+        <View>
97
+          <Button block type="primary" size="small" onClick={handleNext}>下一步</Button>
98
+        </View>
99
+      </View>
100
+    </View>
101
+  )
102
+}

+ 87
- 0
src/pages/reset-password/components/ResetPwd.jsx Voir le fichier

1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View } from '@tarojs/components';
4
+import { Field, Button } from '@antmjs/vantui';
5
+import md5 from 'md5';
6
+
7
+export default (props) => {
8
+  const { onPrev, onSubmit } = props;
9
+
10
+  const [loading, setLoading] = React.useState(false);
11
+  const [pwd1, setPwd1] = React.useState();
12
+  const [pwd1Err, setPwd1Err] = React.useState();
13
+  const [pwd2, setPwd2] = React.useState();
14
+  const [pwd2Err, setPwd2Err] = React.useState();
15
+  
16
+  const handlePrev = () => {
17
+    onPrev();
18
+  }
19
+
20
+  const handleSubmit = () => {
21
+    if (!pwd1) {
22
+      setPwd1Err('请输入密码');
23
+    } else{
24
+      setPwd1Err();
25
+    }
26
+    if (!pwd2) {
27
+      setPwd2Err('请确认密码');
28
+    } else {
29
+      setPwd2Err();
30
+    }
31
+
32
+    if (!pwd1 || !pwd2) {
33
+      return;
34
+    }
35
+
36
+    if (pwd1 != pwd2) {
37
+      setPwd2Err('两次密码不一致');
38
+      return;
39
+    } else {
40
+      setPwd2Err();
41
+    }
42
+
43
+    setLoading(true)
44
+    onSubmit({ password: md5(pwd1) }).then(() => {
45
+      setLoading(false);
46
+
47
+      Taro.navigateBack({
48
+        delta: 1,
49
+        fail: () => {
50
+          Taro.reLaunch({
51
+            url: '/pages/home/index',
52
+          })
53
+        }
54
+      })
55
+    }).catch(() => {
56
+      setLoading(false);
57
+    });
58
+  }
59
+  
60
+  return (
61
+    <View>
62
+      <View className="title">重置密码</View>
63
+      <View className="form-box">
64
+        <Field
65
+          value={pwd1}
66
+          placeholder="请设置新密码"
67
+          errorMessage={pwd1Err}
68
+          onChange={e => setPwd1(e.detail)}
69
+        ></Field>
70
+        <Field
71
+          value={pwd2}
72
+          placeholder="再次确认新密码"
73
+          errorMessage={pwd2Err}
74
+          onChange={e => setPwd2(e.detail)}
75
+        ></Field>
76
+      </View>
77
+      <View className="form-act">
78
+        <View>
79
+          <Button block hairline plain type="primary" size="small" onClick={handlePrev}>上一步</Button>
80
+        </View>
81
+        <View>
82
+          <Button block type="primary" size="small" loading={loading} onClick={handleSubmit}>确定</Button>
83
+        </View>
84
+      </View>
85
+    </View>
86
+  )
87
+}

+ 3
- 0
src/pages/reset-password/index.config.js Voir le fichier

1
+export default definePageConfig({
2
+  navigationBarTitleText: '找回密码'
3
+})

+ 43
- 0
src/pages/reset-password/index.jsx Voir le fichier

1
+import React from 'react';
2
+import { View } from '@tarojs/components';
3
+import Page from '@/layouts/index';
4
+import { changePwd } from '@/services/wxma'; 
5
+import Captcha from './components/Captcha';
6
+import ResetPwd from './components/ResetPwd';
7
+import './index.less';
8
+
9
+export default (props) => {
10
+
11
+  const [direct, setDirect] = React.useState();
12
+  const transClass = direct == 'right' ? 'form-wrapper to-right' : 'form-wrapper';
13
+  const formData = React.useRef();
14
+
15
+  const onNext = (data) => {
16
+    formData.current = data;
17
+    setDirect('right');
18
+  }
19
+
20
+  const onSubmit = (data) => {
21
+    formData.current = {
22
+      ...formData.current,
23
+      ...data,
24
+    }
25
+
26
+    return changePwd(formData.current);
27
+  }
28
+  
29
+  return (
30
+    <Page>
31
+      <View className="reset-password-box">
32
+        <View className={transClass}>
33
+          <View>
34
+            <Captcha onNext={onNext} />
35
+          </View>
36
+          <View>
37
+            <ResetPwd onPrev={() => setDirect()} onSubmit={onSubmit} />
38
+          </View>
39
+        </View>
40
+      </View>
41
+    </Page>
42
+  )
43
+}

+ 50
- 0
src/pages/reset-password/index.less Voir le fichier

1
+.reset-password-box {
2
+  width: 100%;
3
+  padding: 80px 0;
4
+  overflow: hidden;
5
+
6
+  .title {
7
+    font-size: 36px;
8
+    font-weight: 500;
9
+    color: #000000;
10
+  }
11
+
12
+  .form-box {
13
+    margin-top: 80px;
14
+
15
+    .van-cell {
16
+      background: transparent;
17
+
18
+      &::after {
19
+        border-bottom-color: rgba(0, 0, 0, 0.12);
20
+      }
21
+    }
22
+  }
23
+
24
+  .form-act {
25
+    margin-top: 80px;
26
+    display: flex;
27
+    align-items: center;
28
+    justify-content: space-between;
29
+
30
+    & > view {
31
+      width: 180px;
32
+      flex: none;
33
+    }
34
+  }
35
+
36
+  .form-wrapper {
37
+    width: 200%;
38
+    transition: transform 200ms;
39
+
40
+    & > view {
41
+      padding: 0 60px;
42
+      display: inline-block;
43
+      width: 50%;
44
+    }
45
+
46
+    &.to-right {
47
+      transform: translate(-50%, 0);
48
+    }
49
+  }
50
+}

+ 6
- 0
src/services/comm.js Voir le fichier

1
+import request from '@/utils/request';
2
+
3
+/*
4
+ * 获取验证码
5
+ */
6
+export const getCaptcha = (phone) => request(`/api/ma/captcha?phone=${phone}`);

+ 7
- 1
src/services/wxma.js Voir le fichier

23
 /*
23
 /*
24
  * 获取当前人员
24
  * 获取当前人员
25
  */
25
  */
26
-export const currentUser = () => request(`/api/ma/current`);
26
+export const currentUser = () => request(`/api/ma/current`);
27
+
28
+
29
+/*
30
+ * 修改密码
31
+ */
32
+export const changePwd = (data) => request(`/api/ma/change-password`, { method: 'post', data });