张延森 3 년 전
부모
커밋
7d06479b6a
7개의 변경된 파일106개의 추가작업 그리고 44개의 파일을 삭제
  1. 2
    1
      src/app.config.js
  2. 2
    1
      src/components/barcode/index.jsx
  3. 2
    2
      src/components/barcode/style.less
  4. 41
    11
      src/pages/index/index.jsx
  5. 29
    5
      src/pages/index/style.less
  6. 3
    2
      src/pages/setUserInfo/index.jsx
  7. 27
    22
      src/store/userData.js

+ 2
- 1
src/app.config.js 파일 보기

9
     navigationBarBackgroundColor: '#fff',
9
     navigationBarBackgroundColor: '#fff',
10
     navigationBarTitleText: 'WeChat',
10
     navigationBarTitleText: 'WeChat',
11
     navigationBarTextStyle: 'black'
11
     navigationBarTextStyle: 'black'
12
-  }
12
+  },
13
+  lazyCodeLoading: 'requiredComponents'
13
 }
14
 }

+ 2
- 1
src/components/barcode/index.jsx 파일 보기

23
 
23
 
24
     const pxStyle = {
24
     const pxStyle = {
25
       width: `${safeArea.width * ratio}px`,
25
       width: `${safeArea.width * ratio}px`,
26
-      height: `${height}px`
26
+      height: `${height}px`,
27
+      zIndex: 0,
27
     }
28
     }
28
 
29
 
29
     return {
30
     return {

+ 2
- 2
src/components/barcode/style.less 파일 보기

19
     position: absolute;
19
     position: absolute;
20
     width: 100%;
20
     width: 100%;
21
     height: 100%;
21
     height: 100%;
22
-    font-size: 2em;
22
+    font-size: 1.8em;
23
     color: rgba(0, 0, 0, .5);
23
     color: rgba(0, 0, 0, .5);
24
     line-height: 3em;
24
     line-height: 3em;
25
-    z-index: 100;
25
+    z-index: 1000;
26
     top: 0;
26
     top: 0;
27
     left: 0;
27
     left: 0;
28
     text-align: center;
28
     text-align: center;

+ 41
- 11
src/pages/index/index.jsx 파일 보기

1
 import { View, Text, Image } from '@tarojs/components'
1
 import { View, Text, Image } from '@tarojs/components'
2
 import { useEffect, useMemo, useRef, useState } from 'react'
2
 import { useEffect, useMemo, useRef, useState } from 'react'
3
 import dayjs from 'dayjs'
3
 import dayjs from 'dayjs'
4
-import { Button, Icon } from "@antmjs/vantui";
4
+import { Button, Icon, Dialog } from "@antmjs/vantui";
5
 import Taro from '@tarojs/taro';
5
 import Taro from '@tarojs/taro';
6
 import BarCode from '@/components/barcode'
6
 import BarCode from '@/components/barcode'
7
 import logo from '@/assets/water_logo.png'
7
 import logo from '@/assets/water_logo.png'
11
 import { getBarcode } from '../../services/user';
11
 import { getBarcode } from '../../services/user';
12
 
12
 
13
 export default (props) => {
13
 export default (props) => {
14
-  const { person, } = useModel('userData')
15
-  const [barCode, setBarCode] = useState()
14
+  const { person, user } = useModel('userData')
15
+  const [barData, setBarData] = useState({})
16
+  const [idCardVisible, setIdCardVisible] = useState(false)
17
+  const [idCardBarVisible, setIdCardBarVisible] = useState(false)
16
   const today = useMemo(() => dayjs().format('YYYY-MM-DD'))
18
   const today = useMemo(() => dayjs().format('YYYY-MM-DD'))
17
   const goUserInfo = () => {
19
   const goUserInfo = () => {
18
-    Taro.redirectTo({
20
+    Taro.navigateTo({
19
       url: '/pages/setUserInfo/index'
21
       url: '/pages/setUserInfo/index'
20
     })
22
     })
21
   }
23
   }
24
+
25
+  const handleShowEditor = () => {
26
+    setIdCardVisible(false)
27
+    goUserInfo()
28
+  }
29
+
22
   useEffect(() => {
30
   useEffect(() => {
31
+    console.log('============>', user, person, !person || !person.idNo)
23
     if (person && person.personId) {
32
     if (person && person.personId) {
24
       getBarcode(person.personId).then((res) => {
33
       getBarcode(person.personId).then((res) => {
25
-        setBarCode(res.barcode)
34
+        if (typeof res === 'string') {
35
+          const resp = JSON.parse(res) || {}
36
+          setBarData(resp)
37
+        } else {
38
+          setBarData(res || {})
39
+        }
26
       })
40
       })
27
     }
41
     }
28
-  }, [person])
42
+
43
+    if (user && user.userId) {
44
+      if (!person || !person.idNo) {
45
+        setIdCardVisible(true)
46
+      }
47
+    }
48
+  }, [person, user])
29
 
49
 
30
   return (
50
   return (
31
     <View className='index-UserQRcode'>
51
     <View className='index-UserQRcode'>
41
       </View>
61
       </View>
42
       <View className='index-UserQRcode-cententQR'>
62
       <View className='index-UserQRcode-cententQR'>
43
         <View className='index-UserQRcode-cententQR-Barcode'>
63
         <View className='index-UserQRcode-cententQR-Barcode'>
44
-          <BarCode ratio={0.7} height={80} code={barCode} />
45
-        </View>
46
-        <View className='index-UserQRcode-cententQR-Barcode'>
47
-          <BarCode ratio={0.7} height={80} code={person?.idNo} codeVisible />
64
+          <BarCode ratio={0.7} height={80} code={barData.barcode} />
48
         </View>
65
         </View>
49
       </View>
66
       </View>
50
       <View className='index-UserQRcode-footer'>
67
       <View className='index-UserQRcode-footer'>
51
-        {today}
68
+        <View>
69
+          <Button block plain hairline type='info' size='large' onClick={() => setIdCardBarVisible(true)}>
70
+            <View style={{ fontSize: '1.2em' }}>查看身份码</View>
71
+          </Button>
72
+          <View className='date-tip'>
73
+          {today}
74
+          </View>
75
+        </View>
52
       </View>
76
       </View>
77
+      <Dialog title='提示' message='未添加个人信息' show={idCardVisible} onConfirm={handleShowEditor} />
78
+      <Dialog show={idCardBarVisible} onConfirm={() => setIdCardBarVisible(false)}>
79
+        <View className='pop-idcard-bar'>
80
+          <BarCode ratio={0.7} height={80} code={barData.patIdcardno} codeVisible />
81
+        </View>
82
+      </Dialog>
53
     </View>
83
     </View>
54
   )
84
   )
55
 }
85
 }

+ 29
- 5
src/pages/index/style.less 파일 보기

9
     height: 35vh;
9
     height: 35vh;
10
     background: no-repeat, center center;
10
     background: no-repeat, center center;
11
     background-size: 100% 100%;
11
     background-size: 100% 100%;
12
-    background-color: #009fab;
12
+    background-color: #03737b;
13
     padding: 0 7vw 0 7vw;
13
     padding: 0 7vw 0 7vw;
14
 
14
 
15
     &-User {
15
     &-User {
29
 
29
 
30
       &-NameInfo {
30
       &-NameInfo {
31
         font-weight: 600;
31
         font-weight: 600;
32
-        font-size: 40px;
32
+        font-size: 48px;
33
         margin: 5vw 0 3vw 0;
33
         margin: 5vw 0 3vw 0;
34
       }
34
       }
35
       &-setNameInfo {
35
       &-setNameInfo {
36
         margin: 5vw 0 3vw 0;
36
         margin: 5vw 0 3vw 0;
37
         z-index: 10;
37
         z-index: 10;
38
+        font-size: 36px;
38
       }
39
       }
39
     }
40
     }
40
     &-UserID {
41
     &-UserID {
41
       letter-spacing: 0.3vw;
42
       letter-spacing: 0.3vw;
42
-      font-size: 30px;
43
+      font-size: 40px;
43
     }
44
     }
44
   }
45
   }
45
 
46
 
46
   &-cententQR {
47
   &-cententQR {
47
     box-sizing: border-box;
48
     box-sizing: border-box;
48
-    width: 90%;
49
+    width: 90vw;
49
     // box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
50
     // box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
50
     border-radius: 15px;
51
     border-radius: 15px;
51
     background-color: white;
52
     background-color: white;
62
       font-size: 1.8em;
63
       font-size: 1.8em;
63
     }
64
     }
64
     &-Barcode {
65
     &-Barcode {
65
-      height: 20vh;
66
+      height: 40vh;
66
       margin: 0 auto;
67
       margin: 0 auto;
67
       position: relative;
68
       position: relative;
68
       display: flex;
69
       display: flex;
81
     justify-content: center;
82
     justify-content: center;
82
     align-items: center;
83
     align-items: center;
83
     color: #888;
84
     color: #888;
85
+    padding: 0 5vw;
86
+    box-sizing: border-box;
87
+
88
+    & > view {
89
+      flex: 1;
90
+    }
91
+
92
+    .date-tip {
93
+      margin-top: 2em;
94
+      text-align: center;
95
+    }
96
+
97
+    .van-button {
98
+      background: transparent;
99
+    }
84
   }
100
   }
85
 }
101
 }
102
+
103
+.pop-idcard-bar {
104
+  display: flex;
105
+  align-items: center;
106
+  justify-content: center;
107
+  padding: 10vw 4vw;
108
+  box-sizing: border-box;
109
+}

+ 3
- 2
src/pages/setUserInfo/index.jsx 파일 보기

83
           validateTrigger='onBlur'
83
           validateTrigger='onBlur'
84
           valueFormat={(e) => e.detail.value}
84
           valueFormat={(e) => e.detail.value}
85
           renderRight={<Button
85
           renderRight={<Button
86
-            plain
86
+            // plain
87
             hairline
87
             hairline
88
+            square
88
             size='small'
89
             size='small'
89
             type='info'
90
             type='info'
90
             required
91
             required
91
             openType='getPhoneNumber'
92
             openType='getPhoneNumber'
92
             onGetPhoneNumber={getPhone}
93
             onGetPhoneNumber={getPhone}
93
           >
94
           >
94
-            授权手机
95
+            <View style={{ fontSize: '1.3em' }}>授权</View>
95
           </Button>}
96
           </Button>}
96
         >
97
         >
97
           <Input placeholder='请输入手机号' maxlength={11} disabled />
98
           <Input placeholder='请输入手机号' maxlength={11} disabled />

+ 27
- 22
src/store/userData.js 파일 보기

5
 
5
 
6
 
6
 
7
 export default () => {
7
 export default () => {
8
+  const [user, setUser] = useState()
8
   const [person, setPerson] = useState()
9
   const [person, setPerson] = useState()
9
   const [sessionKey, setSessionKey] = useState()
10
   const [sessionKey, setSessionKey] = useState()
10
   const [userPhoneInfo, setUserPhoneInfo] = useState()
11
   const [userPhoneInfo, setUserPhoneInfo] = useState()
22
 
23
 
23
     login(params).then((res) => {
24
     login(params).then((res) => {
24
 
25
 
25
-      const { person: taPerson, sessionKey: skey } = res;
26
+      const { person: taPerson, sessionKey: skey, user: taUser } = res;
26
       // taPerson.phone = null
27
       // taPerson.phone = null
27
 
28
 
28
       setPerson(taPerson);
29
       setPerson(taPerson);
30
+      setUser(taUser);
29
       setSessionKey(skey);
31
       setSessionKey(skey);
30
-      if (!res.person) {
31
-        console.log('没有身份证',);
32
-        Taro.showModal({
33
-          title: '提示',
34
-          content: '未添加个人信息!',
35
-          showCancel: false,
36
-          success: function (res) {
37
-            if (res.confirm) {
38
-              Taro.redirectTo({
39
-                url: '/pages/setUserInfo/index'
40
-              })
41
-
42
-            }
43
-          }
44
-        })
45
-
46
-      } else {
47
-        console.log('有身份证',);
48
-      }
32
+      // if (!res.person) {
33
+      //   console.log('没有身份证',);
34
+      //   Taro.showModal({
35
+      //     title: '提示',
36
+      //     content: '未添加个人信息!',
37
+      //     showCancel: false,
38
+      //     success: function (res) {
39
+      //       if (res.confirm) {
40
+      //         Taro.redirectTo({
41
+      //           url: '/pages/setUserInfo/index'
42
+      //         })
43
+
44
+      //       }
45
+      //     }
46
+      //   })
47
+
48
+      // } else {
49
+      //   console.log('有身份证',);
50
+      // }
49
     })
51
     })
50
   }
52
   }
51
   console.log("🚀 来自store的打印 person数据formValue", person, formValue)
53
   console.log("🚀 来自store的打印 person数据formValue", person, formValue)
52
 
54
 
53
   return {
55
   return {
54
-    person,
55
-    sessionKey,
56
+    user,
57
+    setUser,
56
 
58
 
59
+    person,
57
     setPerson,
60
     setPerson,
61
+
62
+    sessionKey,
58
     setSessionKey,
63
     setSessionKey,
59
 
64
 
60
     userPhoneInfo,
65
     userPhoneInfo,