Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baiguangyao
mr-julyedu
Commits
413a80c8
Commit
413a80c8
authored
Jun 18, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信登录
parent
9b5207b6
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
133 additions
and
34 deletions
+133
-34
src/App.js
+48
-2
src/components/passport/bindingTel/index.js
+7
-1
src/components/passport/forgotPassword/index.js
+1
-1
src/components/passport/index.js
+0
-5
src/components/passport/login/index.js
+10
-3
src/components/passport/setPassword/index.js
+62
-18
src/index.js
+4
-0
src/router/index.js
+1
-4
No files found.
src/App.js
View file @
413a80c8
...
...
@@ -3,6 +3,8 @@ import Routes from './router'
import
cookie
from
'js-cookie'
import
{
connect
}
from
"react-redux"
;
import
{
setCurrentUser
}
from
"@/store/userAction"
;
import
{
withRouter
}
from
'react-router-dom'
import
{
compose
}
from
'redux'
//拦截ajax请求,返回mock数据
...
...
@@ -15,12 +17,15 @@ import './assets/css/index.scss';
// iconfont
import
'./assets/font/iconfont.css'
;
import
{
api
,
http
}
from
"@/utils"
;
import
{
api
,
getParam
,
http
,
isLogin
}
from
"@/utils"
;
import
{
Toast
}
from
"antd-mobile"
;
class
App
extends
Component
{
componentDidMount
()
{
console
.
log
(
this
.
props
.
history
);
//平台信息
cookie
.
set
(
'plat'
,
'5'
)
...
...
@@ -29,6 +34,43 @@ class App extends Component {
})
let
code
=
getParam
(
'code'
)
let
{
history
,
state
,
location
}
=
this
.
props
if
(
code
)
{
http
.
get
(
`
${
api
[
'base-api'
]}
/m/wx_loginInfo/code/
${
code
}
`
)
.
then
(
res
=>
{
let
data
=
res
.
data
console
.
log
(
res
)
if
(
data
.
errno
==
200
)
{
if
(
data
.
data
[
'is_bind_mobile'
])
{
window
.
location
.
assign
(
data
.
data
.
url
)
}
else
{
console
.
log
(
this
.
props
.
location
)
}
}
else
{
Toast
.
info
(
data
.
msg
)
}
})
}
/*else {
if (isLogin) {
console.log(location.pathname);
// history.replace(location.pathname)
} else {
console.log(state);
history.replace('/passport', {...state})
}
}*/
}
transformUser
=
res
=>
{
...
...
@@ -71,7 +113,10 @@ class App extends Component {
}
}
export
default
connect
(
export
default
compose
(
connect
(
null
,
{
setCurrentUser
}
),
withRouter
)(
App
)
\ No newline at end of file
src/components/passport/bindingTel/index.js
View file @
413a80c8
...
...
@@ -122,8 +122,14 @@ const formikConfig = {
if
(
data
.
errno
==
200
)
{
if
(
data
.
data
[
'is_set_pwd'
])
{
props
.
setCurrentUser
({
hasError
:
false
,
data
:
{
uid
:
data
.
data
.
uid
},
msg
:
data
.
data
.
msg
})
props
.
history
.
replace
(
`/passport/set-password`
)
}
else
{
location
.
assign
(
data
.
data
[
'jump_url'
])
...
...
src/components/passport/forgotPassword/index.js
View file @
413a80c8
...
...
@@ -128,7 +128,7 @@ const formikConfig = {
code
:
values
.
veriCode
}).
then
(
res
=>
{
if
(
res
.
data
.
errno
==
0
)
{
props
.
history
.
push
(
'/passport/set-password'
)
props
.
history
.
push
(
'/passport/set-password'
,
{
from
:
props
.
location
}
)
}
else
{
Toast
.
info
(
res
.
data
.
msg
)
}
...
...
src/components/passport/index.js
View file @
413a80c8
...
...
@@ -23,11 +23,6 @@ class Passport extends Component {
redirect_url
=
location
.
protocol
+
'//'
+
location
.
hostname
componentDidMount
()
{
console
.
log
(
this
.
props
.
location
);
}
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
...
...
src/components/passport/login/index.js
View file @
413a80c8
...
...
@@ -15,12 +15,17 @@ import { Toast } from 'antd-mobile';
import
{
validateTel
}
from
"@/utils"
;
class
Wechat
Login
extends
Component
{
class
Login
extends
Component
{
state
=
{
validate
:
null
,
captchaInstance
:
null
}
componentDidMount
()
{
console
.
log
(
this
.
props
);
}
loginWaysClick
=
method
=>
{
const
{
history
,
loginWays
,
location
}
=
this
.
props
...
...
@@ -34,6 +39,8 @@ class WechatLogin extends Component {
let
{
from
}
=
location
.
state
||
{
from
:
{
pathname
:
'/'
}}
const
redirectURI
=
window
.
location
.
protocol
+
'//'
+
window
.
location
.
hostname
+
from
.
pathname
alert
(
redirectURI
)
window
.
location
.
assign
(
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=
${
encodeURIComponent
(
redirectURI
)}
&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
)
break
;
default
:
...
...
@@ -153,4 +160,4 @@ export default compose(
{
quickLogin
}
),
withFormik
(
FormikConfig
),
)(
WechatLogin
)
\ No newline at end of file
)(
Login
)
\ No newline at end of file
src/components/passport/setPassword/index.js
View file @
413a80c8
...
...
@@ -11,12 +11,19 @@ import { Toast } from "antd-mobile";
import
{
encrypt
}
from
"@/components/passport/encryption"
;
import
{
Link
}
from
"react-router-dom"
;
import
{
isEmpty
}
from
"lodash"
;
import
{
connect
}
from
"react-redux"
;
class
SetPassword
extends
Component
{
componentDidMount
()
{
console
.
log
(
this
.
props
.
location
);
}
render
()
{
const
{
values
,
errors
}
=
this
.
props
let
{
values
,
errors
,
location
}
=
this
.
props
let
{
from
}
=
location
.
state
||
{
from
:
{
pathname
:
'/'
}}
return
(
<>
<
HeaderBar
arrow
=
{
true
}
title
=
{
'设置密码'
}
/
>
...
...
@@ -49,7 +56,8 @@ class SetPassword extends Component {
同意
<
span
>
《七月在线用户使用协议》
<
/span
>
<
/label
>
<
/Form
>
<
div
className
=
"skip"
>
<
div
className
=
"skip"
style
=
{{
display
:
from
&&
from
.
pathname
.
includes
(
'forgot-password'
)
?
'none'
:
'block'
}}
>
<
Link
replace
to
=
'/passport/account-login'
>
跳过
<
/Link
>
<
/div
>
<
/div
>
...
...
@@ -67,24 +75,12 @@ const formikConfig = {
},
handleSubmit
:
(
values
,
{
props
})
=>
{
let
key
=
sessionStorage
.
getItem
(
'r_type'
)
===
'email'
?
'email'
:
'tel'
let
encrypted
=
encrypt
(
values
.
password
)
http
.
post
(
`
${
api
[
'passport-api'
]}
/account/up_pass
${
key
===
'tel'
&&
'_by_phone'
||
''
}
`
,
{
[
key
]:
sessionStorage
.
getItem
(
key
),
pass
:
encrypted
,
re_pass
:
encrypted
})
.
then
(
res
=>
{
if
(
res
.
data
.
errno
==
0
)
{
Toast
.
info
(
'密码设置成功'
)
setTimeout
(
function
()
{
props
.
history
.
replace
(
'/passport'
)
},
1000
)
let
{
from
}
=
props
.
location
.
state
||
{
from
:
{
pathname
:
'/'
}}
if
(
from
.
pathname
.
includes
(
'forgot-password'
))
{
forgotPasswordReset
(
values
,
props
);
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
,
null
,
false
)
bindMobileSetPassword
(
values
,
props
)
}
})
},
validateOnChange
:
false
,
...
...
@@ -103,6 +99,53 @@ const formikConfig = {
}
}
function
forgotPasswordReset
(
values
,
props
)
{
let
key
=
sessionStorage
.
getItem
(
'r_type'
)
===
'email'
?
'email'
:
'tel'
http
.
post
(
`
${
api
[
'passport-api'
]}
/account/up_pass_by_
${
key
===
'email'
?
'email'
:
'phone'
}
`
,
{
[
key
]:
sessionStorage
.
getItem
(
key
),
password
:
encrypt
(
values
.
password
)
})
.
then
(
res
=>
{
if
(
res
.
data
.
errno
==
200
)
{
Toast
.
info
(
'密码设置成功'
)
setTimeout
(
function
()
{
props
.
history
.
replace
(
'/passport/account-login'
)
},
1000
)
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
,
null
,
false
)
}
})
}
function
bindMobileSetPassword
(
values
,
props
)
{
http
.
post
(
`
${
api
[
'passport-api'
]}
/bind_mobile/set_pwd_new`
,
{
uid
:
props
.
user
.
data
.
uid
,
password
:
encrypt
(
values
.
password
)
})
.
then
(
res
=>
{
if
(
res
.
data
.
errno
==
200
)
{
Toast
.
info
(
'密码设置成功'
)
let
from
=
getFrom
(
props
.
location
)
setTimeout
(
function
()
{
props
.
history
.
replace
(
from
.
pathname
)
},
1000
)
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
,
null
,
false
)
}
})
}
function
getFrom
(
location
)
{
return
{
from
}
=
location
.
state
||
{
from
:
{
pathname
:
'/'
}}
}
export
default
compose
(
connect
(
state
=>
({
user
:
state
.
user
}),
null
),
withFormik
(
formikConfig
)
)(
SetPassword
);
\ No newline at end of file
src/index.js
View file @
413a80c8
...
...
@@ -2,6 +2,7 @@ import React from 'react';
import
ReactDOM
from
'react-dom'
;
import
{
createStore
,
applyMiddleware
,
compose
}
from
'redux'
import
{
Provider
}
from
'react-redux'
import
{
BrowserRouter
as
Router
}
from
'react-router-dom'
import
thunk
from
'redux-thunk'
import
logger
from
'redux-logger'
import
rootReducers
from
'./store'
...
...
@@ -20,6 +21,8 @@ const store = createStore(
ReactDOM
.
render
(
<
Provider
store
=
{
store
}
>
<
Router
>
<
App
/>
<
/Router
>
<
/Provider>
,
document
.
getElementById
(
'root'
));
\ No newline at end of file
src/router/index.js
View file @
413a80c8
import
React
from
'react'
import
{
BrowserRouter
as
Router
,
Switch
,
Route
}
from
'react-router-dom'
import
{
Switch
,
Route
}
from
'react-router-dom'
import
RouterConfig
from
'./router-config'
import
PrivateRoute
from
'./privateRoute'
export
default
function
()
{
return
(
<
Router
>
<
Switch
>
{
RouterConfig
.
map
((
item
,
index
)
=>
{
let
{
isPrivate
,
...
rest
}
=
item
...
...
@@ -19,6 +18,5 @@ export default function () {
}
})}
<
/Switch
>
<
/Router
>
)
}
\ No newline at end of file
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