Commit 27c875f8 by zhanghaozhe

微博登录绑定手机号

parent 77363ffc
...@@ -26,7 +26,7 @@ class Activity extends Component { ...@@ -26,7 +26,7 @@ class Activity extends Component {
getGift = () => { getGift = () => {
if(this.props.user.hasError) { if(this.props.user.hasError) {
this.props.history.push('/passport'); this.props.history.push('/passport', {from: this.props.location.pathname});
} else { } else {
Toast.info('领取成功,你可前往七月在线官网/APP进行查看', 2); Toast.info('领取成功,你可前往七月在线官网/APP进行查看', 2);
localStorage.setItem('lingqu', 1); localStorage.setItem('lingqu', 1);
......
import React, { Component } from 'react'; import React, { Component } from 'react'
import './binding-tel.scss' import './binding-tel.scss'
import { withFormik, Field, Form } from "formik"; import { withFormik, Field, Form } from "formik"
import { http, getParam } from "@/utils"; import { http, getParam } from "@/utils"
import { compose } from "redux"; import { compose } from "redux"
import { connect } from "react-redux"; import { connect } from "react-redux"
import { setCurrentUser } from "@/store/userAction"; import { setCurrentUser } from "@/store/userAction"
import Captcha from '@/common/Captcha' import Captcha from '@/common/Captcha'
import { HeaderBar } from '@/common' import { HeaderBar } from '@/common'
...@@ -13,8 +13,8 @@ import { HeaderBar } from '@/common' ...@@ -13,8 +13,8 @@ import { HeaderBar } from '@/common'
import ClearableInput from '../common/clearableInputWithCountryCodes' import ClearableInput from '../common/clearableInputWithCountryCodes'
import Button from '../common/Button' import Button from '../common/Button'
import VeriCodeInput from '../common/veriCodeInput' import VeriCodeInput from '../common/veriCodeInput'
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile"
import { isEmpty } from "lodash"; import { isEmpty } from "lodash"
class BindingTel extends Component { class BindingTel extends Component {
...@@ -95,7 +95,7 @@ class BindingTel extends Component { ...@@ -95,7 +95,7 @@ class BindingTel extends Component {
</Form> </Form>
</div> </div>
</> </>
); )
} }
} }
...@@ -123,22 +123,22 @@ const formikConfig = { ...@@ -123,22 +123,22 @@ const formikConfig = {
phone_num: values.tel, phone_num: values.tel,
phone_code: values.veriCode, phone_code: values.veriCode,
mkey: getParam('mkey'), mkey: getParam('mkey'),
area_code: '00'+props.country.num, area_code: '00' + props.country.num,
plat: 5 plat: 5
}).then(res => { }).then(res => {
const data = res.data const data = res.data
if (data.errno == 200) { if (data.errno == 200) {
if (data.data['is_set_pwd']) { if (data.data['is_set_pwd']) {
props.setCurrentUser({ props.history.replace(`/passport/set-password`, {
user: {
hasError: false, hasError: false,
data: { data: {
uid: data.data.uid uid: data.data.uid
}, },
msg: data.data.msg, msg: data.data.msg,
stage: 'binding' stage: 'binding'
}
}) })
props.history.replace(`/passport/set-password`)
} else { } else {
location.assign(data.data['jump_url']) location.assign(data.data['jump_url'])
} }
...@@ -156,4 +156,4 @@ export default compose( ...@@ -156,4 +156,4 @@ export default compose(
{setCurrentUser} {setCurrentUser}
), ),
withFormik(formikConfig), withFormik(formikConfig),
)(BindingTel); )(BindingTel)
...@@ -23,6 +23,7 @@ class Passport extends Component { ...@@ -23,6 +23,7 @@ class Passport extends Component {
redirectURL = '/' redirectURL = '/'
count = 1 count = 1
blackList = new Set(['/passport/binding-tel', '/passport/set-password'])
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -85,7 +86,7 @@ class Passport extends Component { ...@@ -85,7 +86,7 @@ class Passport extends Component {
routeWhenUserLoggedIn = () => { routeWhenUserLoggedIn = () => {
let {hasError} = this.props.user let {hasError} = this.props.user
if (!hasError) { if (!hasError && !this.blackList.has(this.props.location.pathname)) {
const redirectURI = getParam('redirect') const redirectURI = getParam('redirect')
redirectURI ? (window.location.href = redirectURI) : this.props.history.go(-this.count) redirectURI ? (window.location.href = redirectURI) : this.props.history.go(-this.count)
} }
...@@ -108,7 +109,9 @@ class Passport extends Component { ...@@ -108,7 +109,9 @@ class Passport extends Component {
<Route path={match.url + '/account-login'} component={AccountLogin}/> <Route path={match.url + '/account-login'} component={AccountLogin}/>
<Route path={match.url + '/forgot-password'} component={ForgotPassword}/> <Route path={match.url + '/forgot-password'} component={ForgotPassword}/>
<Route path={match.url + '/forgot-password-email'} component={ForgotPasswordEmail}/> <Route path={match.url + '/forgot-password-email'} component={ForgotPasswordEmail}/>
<Route path={match.url + '/set-password'} component={SetPassword}/> <Route path={match.url + '/set-password'} render={props => {
return <SetPassword {...props} count={this.count}/>
}}/>
<Route path={match.url + '/binding-tel'} component={BindingTel}/> <Route path={match.url + '/binding-tel'} component={BindingTel}/>
</Switch> </Switch>
</div> </div>
......
import React, { Component } from 'react'; import React, { Component } from 'react'
import './set-password.scss' import './set-password.scss'
import { withFormik, Form, Field } from "formik"; import { withFormik, Form, Field } from "formik"
import PasswordInput from '../common/passwordInput' import PasswordInput from '../common/passwordInput'
import Button from '../common/Button' import Button from '../common/Button'
import classnames from 'classnames' import classnames from 'classnames'
import { compose } from 'redux' import { compose } from 'redux'
import { HeaderBar } from "@/common"; import { HeaderBar } from "@/common"
import { http, api } from "@/utils"; import { http } from "@/utils"
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile"
import { encrypt } from "@/components/passport/encryption"; import { encrypt } from "@/components/passport/encryption"
import { Link } from "react-router-dom"; import { Link } from "react-router-dom"
import { isEmpty } from "lodash"; import { isEmpty } from "lodash"
import { connect } from "react-redux"; import { connect } from "react-redux"
import { setCurrentUser } from '@/store/userAction'
class SetPassword extends Component { class SetPassword extends Component {
render() { render() {
...@@ -56,7 +56,7 @@ class SetPassword extends Component { ...@@ -56,7 +56,7 @@ class SetPassword extends Component {
</div> </div>
</div> </div>
</> </>
); )
} }
} }
...@@ -71,7 +71,7 @@ const formikConfig = { ...@@ -71,7 +71,7 @@ const formikConfig = {
let from = props.location.state && props.location.state.from || {pathname: '/'} let from = props.location.state && props.location.state.from || {pathname: '/'}
if (from.pathname.includes('forgot-password')) { if (from.pathname.includes('forgot-password')) {
forgotPasswordReset(values, props); forgotPasswordReset(values, props)
} else { } else {
bindMobileSetPassword(values, props) bindMobileSetPassword(values, props)
} }
...@@ -80,7 +80,7 @@ const formikConfig = { ...@@ -80,7 +80,7 @@ const formikConfig = {
validateOnChange: false, validateOnChange: false,
validate: values => { validate: values => {
let errors = {} let errors = {}
const re = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/; const re = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/
if (!re.test(values.password)) { if (!re.test(values.password)) {
errors.password = '密码需要包含6-16位字母及数字' errors.password = '密码需要包含6-16位字母及数字'
Toast.info(errors.password, 2, null, false) Toast.info(errors.password, 2, null, false)
...@@ -136,7 +136,7 @@ function bindMobileSetPassword(values, props) { ...@@ -136,7 +136,7 @@ function bindMobileSetPassword(values, props) {
export default compose( export default compose(
connect( connect(
state => ({user: state.user}), state => ({user: state.user}),
null {setCurrentUser}
), ),
withFormik(formikConfig) withFormik(formikConfig)
)(SetPassword); )(SetPassword)
\ No newline at end of file
...@@ -207,7 +207,7 @@ export default [ ...@@ -207,7 +207,7 @@ export default [
}, },
// 定金-邀请好友助力 // 定金-邀请好友助力
{ {
path: '/expand/index', path: '/expand/indexactivity',
component: ExpandShare component: ExpandShare
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment