Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
da680cd7
Commit
da680cd7
authored
Jun 22, 2021
by
guomingpang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:login_page_modify
parent
d2676923
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
145 deletions
+147
-145
src/modules/root/Login.jsx
+0
-0
src/modules/root/Login.less
+0
-0
src/modules/root/WechatLogin.less
+30
-29
src/modules/root/WechatLogin.tsx
+117
-116
yarn.lock
+0
-0
No files found.
src/modules/root/Login.jsx
View file @
da680cd7
This diff is collapsed.
Click to expand it.
src/modules/root/Login.less
View file @
da680cd7
This diff is collapsed.
Click to expand it.
src/modules/root/WechatLogin.less
View file @
da680cd7
...
@@ -9,39 +9,40 @@
...
@@ -9,39 +9,40 @@
color: #999999;
color: #999999;
line-height: 20px;
line-height: 20px;
}
}
.rwm{
.rwm
{
position: relative;
position: relative;
width: 210px;
height: 210px;
text-align: center;
text-align: center;
display: inline-block;
display: inline-block;
margin-top: 2
4
px;
margin-top: 2
0
px;
border: 1px
soli
d #e8e8e8;
border: 1px
dashe
d #e8e8e8;
border-radius: 2px;
border-radius: 2px;
padding:15px;
padding: 5px;
.error{
#qrcode {
position: absolute;
height: 180px;
width: 200px;
}
height: 200px;
.error {
background: rgba(255, 255, 255, 0.95);
position: absolute;
display: flex;
width: 180px;
align-items:center;
height: 180px;
justify-content:center;
background: rgba(255, 255, 255, 0.95);
left:5px;
display: flex;
top:5px;
align-items: center;
div{
justify-content: center;
margin: 0 10px;
left: 5px;
font-size: 14px;
top: 5px;
font-family: PingFangSC-Regular, PingFang SC;
div {
font-weight: 400;
margin: 0 10px;
color: #333333;
font-size: 14px;
line-height: 20px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
}
color: #333333;
.ope{
line-height: 20px;
cursor: pointer;
}
color:rgba(82, 137, 250, 1);
.ope {
}
cursor: pointer;
color: rgba(82, 137, 250, 1);
}
}
}
}
}
...
...
src/modules/root/WechatLogin.tsx
View file @
da680cd7
import
React
,
{
useState
,
useRef
,
useEffect
}
from
'react'
;
import
React
,
{
useState
,
useRef
,
useEffect
}
from
'react'
;
import
qrcode
from
"@/libs/qrcode/qrcode.js"
;
import
qrcode
from
'@/libs/qrcode/qrcode.js'
;
import
Service
from
"@/common/js/service"
;
import
Service
from
'@/common/js/service'
;
import
User
from
'@/common/js/user'
;
import
User
from
'@/common/js/user'
;
import
{
PATH
}
from
'@/domains/basic-domain/constants'
;
import
{
PATH
}
from
'@/domains/basic-domain/constants'
;
import
'./WechatLogin.less'
import
'./WechatLogin.less'
;
const
Logo
=
require
(
"@/common/images/logo.png"
)
const
Logo
=
require
(
'@/common/images/logo.png'
);
declare
var
location
:
any
;
export
default
function
WechatLogin
()
{
const
freshTime
=
60
;
const
init
:
any
=
null
;
const
[
status
,
setStatus
]
=
useState
(
0
);
const
[
ticket
,
setTicket
]
=
useState
(
''
);
const
[
leftTime
,
setLeftTime
]
=
useState
(
freshTime
);
const
timer
=
useRef
(
init
);
const
leftTimeRef
=
useRef
(
init
);
export
default
function
WechatLogin
(
props
:
any
)
{
useEffect
(()
=>
{
const
freshTime
=
60
;
leftTimeRef
.
current
=
leftTime
;
const
init
:
any
=
null
;
},
[
leftTime
]);
const
[
status
,
setStatus
]
=
useState
(
0
);
const
[
ticket
,
setTicket
]
=
useState
(
''
);
const
[
leftTime
,
setLeftTime
]
=
useState
(
freshTime
)
const
QRCode
=
useRef
(
init
);
const
timer
=
useRef
(
init
);
const
leftTimeRef
=
useRef
(
init
);
useEffect
(()
=>
{
useEffect
(()
=>
{
clearInterval
(
timer
.
current
as
any
);
leftTimeRef
.
current
=
leftTime
;
if
(
status
===
0
)
{
},
[
leftTime
])
Service
.
Hades
(
'anon/hades/getTicket'
,
{}).
then
((
res
:
any
)
=>
{
setTicket
(
res
.
result
);
useEffect
(()
=>
{
const
redirect
=
`
${
PATH
}
?ticket=
${
res
.
result
}
&appTermEnum=XIAOMAI_CLOUD_CLASS_PC_WEB_ADMIN&env=
${
process
.
env
.
DEPLOY_ENV
||
'dev'
}
`
;
clearInterval
(
timer
.
current
as
any
);
const
qrcodeWrapDom
:
any
=
document
.
querySelector
(
'#qrcode'
);
if
(
status
===
0
)
{
let
qrnode
=
new
qrcode
({
Service
.
Hades
(
"anon/hades/getTicket"
,
{}).
then
((
res
:
any
)
=>
{
text
:
redirect
,
setTicket
(
res
.
result
)
correctLevel
:
2
,
const
redirect
=
`
${
PATH
}
?ticket=
${
res
.
result
}
&appTermEnum=XIAOMAI_CLOUD_CLASS_PC_WEB_ADMIN&env=
${
process
.
env
.
DEPLOY_ENV
||
'dev'
}
`
size
:
180
,
// console.log(redirect)
image
:
Logo
,
// const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww409ccf9c6e31f19e&redirect_uri=${encodeURIComponent(redirect)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
imageSize
:
50
,
// console.log(url)
});
const
qrcodeWrapDom
:
any
=
document
.
querySelector
(
'#qrcode'
);
qrcodeWrapDom
.
innerHTML
=
''
;
let
qrnode
=
new
qrcode
({
qrcodeWrapDom
&&
qrcodeWrapDom
.
appendChild
(
qrnode
);
text
:
redirect
,
setLeftTime
(
freshTime
);
correctLevel
:
2
,
timer
.
current
=
setInterval
(()
=>
{
size
:
180
,
if
(
leftTimeRef
.
current
==
0
)
{
// image: 'https://image.xiaomaiketang.com/xm/Newk4NrxKC.png',
image
:
'https://image.xiaomaiketang.com/xm/bFkRBz7teA.png'
,
imageSize
:
50
});
qrcodeWrapDom
.
innerHTML
=
''
;
qrcodeWrapDom
&&
qrcodeWrapDom
.
appendChild
(
qrnode
);
// QRCode.current.innerHTML = ''
// QRCode.current.prepend(qrnode);
setLeftTime
(
freshTime
);
timer
.
current
=
setInterval
(()
=>
{
if
(
leftTimeRef
.
current
==
0
)
{
clearInterval
(
timer
.
current
);
setStatus
(
1
);
return
}
setLeftTime
(
leftTimeRef
.
current
-
1
);
},
1000
)
})
}
return
()
=>
{
clearInterval
(
timer
.
current
);
clearInterval
(
timer
.
current
);
}
setStatus
(
1
);
},
[
status
])
return
;
}
useEffect
(()
=>
{
if
(
leftTime
==
60
||
!
ticket
)
{
return
}
Service
.
Hades
(
'anon/hades/getTicketState'
,
{
ticket
}).
then
((
res
:
any
)
=>
{
if
(
res
.
result
===
'AUTH_SUCCESS'
)
{
Service
.
Hades
(
'anon/hades/getTicketWXWorkLogin'
,
{
ticket
}).
then
((
_res
:
any
)
=>
{
User
.
setUserId
(
_res
.
result
.
loginInfo
.
userId
);
User
.
setToken
(
_res
.
result
.
loginInfo
.
xmToken
);
User
.
setEnterpriseId
(
_res
.
result
.
enterpriseId
);
User
.
setIdentifier
(
_res
.
result
.
identifier
)
window
.
RCHistory
.
push
({
pathname
:
`/switch-route`
,
})
})
}
})
},
[
leftTime
])
setLeftTime
(
leftTimeRef
.
current
-
1
);
},
1000
);
});
}
return
()
=>
{
clearInterval
(
timer
.
current
);
};
},
[
status
]);
return
<
div
className=
'wechatLoginBox'
>
useEffect
(()
=>
{
<
div
className=
"rwm"
>
if
(
leftTime
==
60
||
!
ticket
)
{
<
div
id=
"qrcode"
></
div
>
return
;
}
{
Service
.
Hades
(
'anon/hades/getTicketState'
,
{
status
===
1
&&
<
div
className=
"error"
>
ticket
,
<
div
>
二维码已过期
}).
then
((
res
:
any
)
=>
{
<
p
className=
"ope"
onClick=
{
()
=>
{
if
(
res
.
result
===
'AUTH_SUCCESS'
)
{
setStatus
(
0
)
Service
.
Hades
(
'anon/hades/getTicketWXWorkLogin'
,
{
}
}
>
刷新
</
p
>
ticket
,
</
div
>
}).
then
((
_res
:
any
)
=>
{
</
div
>
User
.
setUserId
(
_res
.
result
.
loginInfo
.
userId
);
}
User
.
setToken
(
_res
.
result
.
loginInfo
.
xmToken
);
{
User
.
setEnterpriseId
(
_res
.
result
.
enterpriseId
);
status
===
2
&&
<
div
className=
"error"
>
User
.
setIdentifier
(
_res
.
result
.
identifier
);
<
div
>
所在企业还未注册学院
window
.
RCHistory
.
push
({
pathname
:
`/switch-route`
,
});
});
}
});
},
[
leftTime
]);
<
p
className=
"ope"
onClick=
{
()
=>
{
return
(
setStatus
(
0
)
<
div
className=
'wechatLoginBox'
>
}
}
>
我知道了
</
p
>
<
div
className=
'rwm'
>
</
div
>
<
div
id=
'qrcode'
></
div
>
</
div
>
}
{
status
===
3
&&
<
div
className=
"error"
>
<
div
>
你还不是学院员工,请联系企业管理员
<
p
className=
"ope"
onClick=
{
()
=>
{
{
status
===
1
&&
(
setStatus
(
0
)
<
div
className=
'error'
>
}
}
>
我知道了
</
p
>
<
div
>
</
div
>
二维码已过期
</
div
>
<
p
}
className=
'ope'
</
div
>
onClick=
{
()
=>
{
<
p
className=
'text'
>
请使用企业微信扫码登录
</
p
>
setStatus
(
0
);
}
}
>
刷新
</
p
>
</
div
>
</
div
>
)
}
{
status
===
2
&&
(
<
div
className=
'error'
>
<
div
>
所在企业还未注册学院
<
p
className=
'ope'
onClick=
{
()
=>
{
setStatus
(
0
);
}
}
>
我知道了
</
p
>
</
div
>
</
div
>
)
}
{
status
===
3
&&
(
<
div
className=
'error'
>
<
div
>
你还不是学院员工,请联系企业管理员
<
p
className=
'ope'
onClick=
{
()
=>
{
setStatus
(
0
);
}
}
>
我知道了
</
p
>
</
div
>
</
div
>
)
}
</
div
>
<
p
className=
'text'
>
请使用企业微信扫码登录
</
p
>
</
div
>
</
div
>
}
);
\ No newline at end of file
}
yarn.lock
View file @
da680cd7
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment