张延森 3 gadus atpakaļ
vecāks
revīzija
3aeefd347d

+ 9
- 1
src/components/Auth/AuthAvatar.jsx Parādīt failu

6
 import './style.scss'
6
 import './style.scss'
7
 
7
 
8
 export default (props) => {
8
 export default (props) => {
9
+  const { onCancel = (x => x) } = props;
10
+
9
   const [loading, setLoading] = useState(false)
11
   const [loading, setLoading] = useState(false)
10
   const { updateUserInfo } = useAuth()
12
   const { updateUserInfo } = useAuth()
11
 
13
 
30
   }
32
   }
31
 
33
 
32
   return (
34
   return (
33
-    <AuthBox title='授权头像' openType='getUserInfo' loading={loading} onGetUserInfo={handleUserProfile}>
35
+    <AuthBox
36
+      title='授权头像'
37
+      openType='getUserInfo'
38
+      loading={loading}
39
+      onGetUserInfo={handleUserProfile}
40
+      onCancel={onCancel}
41
+    >
34
       <View className='auth-avatar'>
42
       <View className='auth-avatar'>
35
         <OpenData type='userAvatarUrl' />
43
         <OpenData type='userAvatarUrl' />
36
       </View>
44
       </View>

+ 2
- 2
src/components/Auth/AuthBox.jsx Parādīt failu

4
 import './style.scss'
4
 import './style.scss'
5
 
5
 
6
 export default (props) => {
6
 export default (props) => {
7
-  const { loading, title, openType, onGetUserInfo, onGetPhoneNumber } = props
7
+  const { loading, title, openType, onGetUserInfo, onGetPhoneNumber, onCancel = (x => x) } = props
8
 
8
 
9
   const handleGetUserInfo = () => {
9
   const handleGetUserInfo = () => {
10
     Taro.getUserProfile({
10
     Taro.getUserProfile({
30
         {props.children}
30
         {props.children}
31
       </View>
31
       </View>
32
       <View className='auth-footer'>
32
       <View className='auth-footer'>
33
-        <Button className='auth-btn' type='default' plain>取消</Button>
33
+        <Button className='auth-btn' type='default' plain onClick={onCancel}>取消</Button>
34
         {
34
         {
35
           openType === 'getUserInfo' ? (
35
           openType === 'getUserInfo' ? (
36
             <Button
36
             <Button

+ 10
- 0
src/components/Auth/AuthPage.jsx Parādīt failu

1
+import React from 'react'
2
+import './style.scss'
3
+
4
+export default (props) => {
5
+  return (
6
+    <View>
7
+
8
+    </View>
9
+  )
10
+}

+ 9
- 1
src/components/Auth/AuthPhone.jsx Parādīt failu

6
 import './style.scss'
6
 import './style.scss'
7
 
7
 
8
 export default (props) => {
8
 export default (props) => {
9
+  const { onCancel = (x => x) } = props;
10
+
9
   const [loading, setLoading] = useState(false)
11
   const [loading, setLoading] = useState(false)
10
   const { updatePhoneNumber } = useAuth()
12
   const { updatePhoneNumber } = useAuth()
11
 
13
 
30
   }
32
   }
31
 
33
 
32
   return (
34
   return (
33
-    <AuthBox title='授权手机' openType='getPhoneNumber' loading={loading} onGetPhoneNumber={handlePhoneNumber}>
35
+    <AuthBox
36
+      title='授权手机'
37
+      openType='getPhoneNumber'
38
+      loading={loading}
39
+      onGetPhoneNumber={handlePhoneNumber}
40
+      onCancel={onCancel}
41
+    >
34
       <View>请确认授权手机号,以便为您提供更优质的服务内容。</View>
42
       <View>请确认授权手机号,以便为您提供更优质的服务内容。</View>
35
     </AuthBox>
43
     </AuthBox>
36
   )
44
   )

+ 46
- 2
src/components/Auth/style.scss Parādīt failu

33
     display: inline-block;
33
     display: inline-block;
34
     font-size: 30rpx;
34
     font-size: 30rpx;
35
     background: #193C83;
35
     background: #193C83;
36
-    border-radius: 39px;
36
+    border-radius: 39rpx;
37
     color: #fff;
37
     color: #fff;
38
     width: 236rpx;
38
     width: 236rpx;
39
     height: 78rpx;
39
     height: 78rpx;
42
       margin-left: 80rpx;
42
       margin-left: 80rpx;
43
     }
43
     }
44
   }
44
   }
45
-}
45
+}
46
+
47
+.auth-page {
48
+  width: 100vw;
49
+  height: 100vw;
50
+  position: fixed;
51
+  z-index: 2000;
52
+  left: 0;
53
+  top: 0;
54
+  background: #fff;
55
+  display: flex;
56
+  padding: 40rpx 30rpx;
57
+  box-sizing: border-box;
58
+
59
+  .auth-header {
60
+    flex: none;
61
+    margin-top: 78rpx;
62
+
63
+    .auth-logo {
64
+      width: 128rpx;
65
+      margin: 0 auto;
66
+    }
67
+  }
68
+
69
+  .auth-body {
70
+    flex: auto;
71
+    margin-top: 195rpx;
72
+
73
+    .auth-btn {
74
+      width: 100%;
75
+      height: 92rpx;
76
+      background: #193C83;
77
+      border-radius: 44px;
78
+    }
79
+  }
80
+
81
+  .auth-footer {
82
+    flex: none;
83
+    height: 321rpx;
84
+    background: #F8F8F8;
85
+    border-radius: 8rpx;
86
+    box-sizing: border-box;
87
+    padding: 32rpx 40rpx;
88
+  }
89
+}

+ 21
- 7
src/utils/im/sdk.js Parādīt failu

56
         ...paramsRef.current,
56
         ...paramsRef.current,
57
         fail: (err) => reject(err),
57
         fail: (err) => reject(err),
58
       }).then((task) => {
58
       }).then((task) => {
59
-        console.log('[WS][connect]', task)
59
+        console.log(`[${now()}]`, '[WS] [connect]', task)
60
         instanceRef.current = task
60
         instanceRef.current = task
61
   
61
   
62
         task.onOpen(function () {
62
         task.onOpen(function () {
63
-          console.log('[WS][onOpen]', paramsRef.current)
63
+          console.log(`[${now()}]`, '[WS] [onOpen]', paramsRef.current)
64
           resolve()
64
           resolve()
65
         })
65
         })
66
 
66
 
67
         task.onMessage(function (msg) {
67
         task.onMessage(function (msg) {
68
-          console.info('[WS][onMessage]', msg)
68
+          console.info(`[${now()}]`, '[WS] [onMessage]', msg)
69
           instanceRef.onMessage().forEach((f) => f(msg))
69
           instanceRef.onMessage().forEach((f) => f(msg))
70
         })
70
         })
71
 
71
 
72
         task.onError(function (error) {
72
         task.onError(function (error) {
73
-          console.error('[WS][onError]', error)
73
+          console.error(`[${now()}]`, '[WS] [onError]', error)
74
           instanceRef.onError().forEach((f) => f(error))
74
           instanceRef.onError().forEach((f) => f(error))
75
         })
75
         })
76
 
76
 
77
         task.onClose(function (res) {
77
         task.onClose(function (res) {
78
-          console.warn('[WS][onClose]', res)
78
+          console.warn(`[${now()}]`, '[WS] [onClose]', res)
79
           instanceRef.onClose().forEach((f) => f(res))
79
           instanceRef.onClose().forEach((f) => f(res))
80
         })
80
         })
81
       })
81
       })
83
   }
83
   }
84
 
84
 
85
   function send(data) {
85
   function send(data) {
86
-    console.log('[WS][SEND]', data)
86
+    console.log(`[${now()}]`, '[WS] [SEND]', data)
87
     return new Promise((resovle, reject) => {
87
     return new Promise((resovle, reject) => {
88
       if (instanceRef.current) {
88
       if (instanceRef.current) {
89
         instanceRef.current.send({
89
         instanceRef.current.send({
90
           data,
90
           data,
91
           success: resovle,
91
           success: resovle,
92
           fail: (err) => {
92
           fail: (err) => {
93
-            console.error('[WS][SEND]', err)
93
+            console.error(`[${now()}]`, '[WS] [SEND]', err)
94
             reject(err)
94
             reject(err)
95
           },
95
           },
96
         })
96
         })
99
       }
99
       }
100
     })
100
     })
101
   }
101
   }
102
+
103
+  function now() {
104
+    const dt = new Date()
105
+    const year = dt.getFullYear()
106
+    const month = dt.getMonth() + 1
107
+    const day = dt.getDate()
108
+    const hour = dt.getHours()
109
+    const minutes = dt.getMinutes()
110
+    const seconds = dt.getSeconds()
111
+
112
+    const formate = n => n >= 10 ? n : `0${n}`
113
+
114
+    return `${year}-${formate(month)}-${formate(day)} ${formate(hour)}:${formate(minutes)}:${formate(seconds)}`
115
+  }
102
 }
116
 }