张延森 3 vuotta sitten
vanhempi
commit
7d06479b6a

+ 2
- 1
src/app.config.js Näytä tiedosto

@@ -9,5 +9,6 @@ export default {
9 9
     navigationBarBackgroundColor: '#fff',
10 10
     navigationBarTitleText: 'WeChat',
11 11
     navigationBarTextStyle: 'black'
12
-  }
12
+  },
13
+  lazyCodeLoading: 'requiredComponents'
13 14
 }

+ 2
- 1
src/components/barcode/index.jsx Näytä tiedosto

@@ -23,7 +23,8 @@ export default (props) => {
23 23
 
24 24
     const pxStyle = {
25 25
       width: `${safeArea.width * ratio}px`,
26
-      height: `${height}px`
26
+      height: `${height}px`,
27
+      zIndex: 0,
27 28
     }
28 29
 
29 30
     return {

+ 2
- 2
src/components/barcode/style.less Näytä tiedosto

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

+ 41
- 11
src/pages/index/index.jsx Näytä tiedosto

@@ -1,7 +1,7 @@
1 1
 import { View, Text, Image } from '@tarojs/components'
2 2
 import { useEffect, useMemo, useRef, useState } from 'react'
3 3
 import dayjs from 'dayjs'
4
-import { Button, Icon } from "@antmjs/vantui";
4
+import { Button, Icon, Dialog } from "@antmjs/vantui";
5 5
 import Taro from '@tarojs/taro';
6 6
 import BarCode from '@/components/barcode'
7 7
 import logo from '@/assets/water_logo.png'
@@ -11,21 +11,41 @@ import './style.less'
11 11
 import { getBarcode } from '../../services/user';
12 12
 
13 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 18
   const today = useMemo(() => dayjs().format('YYYY-MM-DD'))
17 19
   const goUserInfo = () => {
18
-    Taro.redirectTo({
20
+    Taro.navigateTo({
19 21
       url: '/pages/setUserInfo/index'
20 22
     })
21 23
   }
24
+
25
+  const handleShowEditor = () => {
26
+    setIdCardVisible(false)
27
+    goUserInfo()
28
+  }
29
+
22 30
   useEffect(() => {
31
+    console.log('============>', user, person, !person || !person.idNo)
23 32
     if (person && person.personId) {
24 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 50
   return (
31 51
     <View className='index-UserQRcode'>
@@ -41,15 +61,25 @@ export default (props) => {
41 61
       </View>
42 62
       <View className='index-UserQRcode-cententQR'>
43 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 65
         </View>
49 66
       </View>
50 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 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 83
     </View>
54 84
   )
55 85
 }

+ 29
- 5
src/pages/index/style.less Näytä tiedosto

@@ -9,7 +9,7 @@
9 9
     height: 35vh;
10 10
     background: no-repeat, center center;
11 11
     background-size: 100% 100%;
12
-    background-color: #009fab;
12
+    background-color: #03737b;
13 13
     padding: 0 7vw 0 7vw;
14 14
 
15 15
     &-User {
@@ -29,23 +29,24 @@
29 29
 
30 30
       &-NameInfo {
31 31
         font-weight: 600;
32
-        font-size: 40px;
32
+        font-size: 48px;
33 33
         margin: 5vw 0 3vw 0;
34 34
       }
35 35
       &-setNameInfo {
36 36
         margin: 5vw 0 3vw 0;
37 37
         z-index: 10;
38
+        font-size: 36px;
38 39
       }
39 40
     }
40 41
     &-UserID {
41 42
       letter-spacing: 0.3vw;
42
-      font-size: 30px;
43
+      font-size: 40px;
43 44
     }
44 45
   }
45 46
 
46 47
   &-cententQR {
47 48
     box-sizing: border-box;
48
-    width: 90%;
49
+    width: 90vw;
49 50
     // box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
50 51
     border-radius: 15px;
51 52
     background-color: white;
@@ -62,7 +63,7 @@
62 63
       font-size: 1.8em;
63 64
     }
64 65
     &-Barcode {
65
-      height: 20vh;
66
+      height: 40vh;
66 67
       margin: 0 auto;
67 68
       position: relative;
68 69
       display: flex;
@@ -81,5 +82,28 @@
81 82
     justify-content: center;
82 83
     align-items: center;
83 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 Näytä tiedosto

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

+ 27
- 22
src/store/userData.js Näytä tiedosto

@@ -5,6 +5,7 @@ import { login } from "../services/user"
5 5
 
6 6
 
7 7
 export default () => {
8
+  const [user, setUser] = useState()
8 9
   const [person, setPerson] = useState()
9 10
   const [sessionKey, setSessionKey] = useState()
10 11
   const [userPhoneInfo, setUserPhoneInfo] = useState()
@@ -22,39 +23,43 @@ export default () => {
22 23
 
23 24
     login(params).then((res) => {
24 25
 
25
-      const { person: taPerson, sessionKey: skey } = res;
26
+      const { person: taPerson, sessionKey: skey, user: taUser } = res;
26 27
       // taPerson.phone = null
27 28
 
28 29
       setPerson(taPerson);
30
+      setUser(taUser);
29 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 53
   console.log("🚀 来自store的打印 person数据formValue", person, formValue)
52 54
 
53 55
   return {
54
-    person,
55
-    sessionKey,
56
+    user,
57
+    setUser,
56 58
 
59
+    person,
57 60
     setPerson,
61
+
62
+    sessionKey,
58 63
     setSessionKey,
59 64
 
60 65
     userPhoneInfo,