Commit c9da436c by zhanghaozhe

绑定手机号

parent 6a749753
...@@ -41,7 +41,8 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { ...@@ -41,7 +41,8 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
} }
// Tools like Cloud9 rely on this. // Tools like Cloud9 rely on this.
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000; // const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 80;
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 80;
const HOST = process.env.HOST || '0.0.0.0'; const HOST = process.env.HOST || '0.0.0.0';
if (process.env.HOST) { if (process.env.HOST) {
......
...@@ -11,13 +11,6 @@ ...@@ -11,13 +11,6 @@
margin-bottom: 21px; margin-bottom: 21px;
} }
.place {
width: 100%;
height: 39px;
margin-bottom: 33px;
background: #56abff;
}
.verification { .verification {
margin-bottom: 21px; margin-bottom: 21px;
} }
......
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 { validateTel, http, api, getParam } from "@/utils";
import { compose } from "redux";
import { connect } from "react-redux";
import { setCurrentUser } from "@/store/userAction";
import Captcha from '@/common/Captcha'
import ClearableInput from '@common/ClearableInput' import ClearableInput from '@common/ClearableInput'
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 { isEmpty } from "lodash";
class BindingTel extends Component { class BindingTel extends Component {
constructor(props) {
super(props); state = {
this.state = { validate: null,
veriCode: '' captchaInstance: null
};
} }
handleChange = (val) => { getCaptchaInstance = instance => {
this.setState({veriCode: val}); this.setState({
captchaInstance: instance
})
}
onVerify = (err, data) => {
if (err) {
console.log(err)
} else {
this.setState({
validate: data.validate
})
} }
}
render() { render() {
const {
values,
errors
} = this.props
return ( return (
<div className={'binding-tel'}> <div className={'binding-tel'}>
<p className={'title'}>为提高您的账号安全,请绑定手机号</p> <p className={'title'}>为提高您的账号安全,请绑定手机号</p>
<Form>
<Field
name='tel'
render={({field, form}) => {
return (
<ClearableInput <ClearableInput
type={'number'} {...field}
setFieldValue={form.setFieldValue}
placeholder={'请输入需要绑定的手机号'} placeholder={'请输入需要绑定的手机号'}
wrapperClass={'tel'} wrapperClass={'tel'}
icon={<i className={'iconfont iconshouji'} icon={<i className={'iconfont iconshouji'}
style={{fontSize: '22px', left: '11px'}} style={{fontSize: '22px', left: '11px'}}
/>} />}
/> />
)
}}
/>
<Field
name='veriCode'
render={({field}) => {
return (
<VeriCodeInput <VeriCodeInput
type={'number'} {...field}
className={'verification'} className={'verification'}
onChange={this.handleChange}
icon={<i className={'iconfont iconduanxin'} icon={<i className={'iconfont iconduanxin'}
style={{fontSize: '20px', left: '12px'}} style={{fontSize: '20px', left: '12px'}}
/>} />}
account={values.tel}
tel={values.tel}
challenge={this.state.validate}
instance={this.state.captchaInstance}
action={'auth'}
/> />
<div className="place"/>
<Button className={'complete-btn'}>完成</Button> )
}}
/>
<Captcha onVerify={this.onVerify} getInstance={this.getCaptchaInstance}/>
<Button className={'complete-btn'} active={values.tel && values.veriCode && isEmpty(errors)}>完成</Button>
</Form>
</div> </div>
); );
} }
} }
export default BindingTel;
\ No newline at end of file const formikConfig = {
mapPropsToValues() {
return {
tel: '',
veriCode: ''
}
},
validateOnChange: true,
validate(values) {
let errors = {}
if (!validateTel(values.tel)) {
errors.tel = '请输入正确的手机号'
}
if (!values.veriCode) {
errors.veriCode = '请填写验证码'
}
return errors
},
handleSubmit(values, {props}) {
http.post(`${api['passport-api']}/bind_mobile`, {
phone_num: values.tel,
phone_code: values.veriCode,
mkey: getParam('mkey'),
plat: 5
}).then(res => {
const data = res.data
if (data.errno == 200) {
if (data.data.is_set_pwd) {
console.log('set')
}else {
location.assign(data.data.jump_url)
}
} else {
Toast.info(data.msg, 2, null, false)
}
/*props.setCurrentUser({
hasError,
data
})*/
})
}
}
export default compose(
connect(
null,
{setCurrentUser}
),
withFormik(formikConfig),
)(BindingTel);
\ No newline at end of file
...@@ -16,9 +16,11 @@ class LoginWays extends PureComponent { ...@@ -16,9 +16,11 @@ class LoginWays extends PureComponent {
{ {
this.props.loginWays.map((item, index) => { this.props.loginWays.map((item, index) => {
return ( return (
<li key={index} onClick={this.handleClick.bind(this, index)}> <li key={index} onClick={this.handleClick.bind(this, item.text)}>
<a href={item.url}>
<img src={item.logo} alt=""/> <img src={item.logo} alt=""/>
<p>{item.text}</p> <p>{item.text}</p>
</a>
</li> </li>
) )
}) })
......
...@@ -36,6 +36,10 @@ ...@@ -36,6 +36,10 @@
li { li {
text-align: center; text-align: center;
a{
display: block;
}
img { img {
width: 34px; width: 34px;
} }
......
...@@ -110,7 +110,7 @@ class VeriCodeInput extends Component { ...@@ -110,7 +110,7 @@ class VeriCodeInput extends Component {
if (!tel) { if (!tel) {
content = '手机号码不能为空' content = '手机号码不能为空'
} }
if (validateTel(tel)) { if (!validateTel(tel)) {
content = '请输入正确格式的手机号码' content = '请输入正确格式的手机号码'
} }
} else { } else {
......
...@@ -8,6 +8,7 @@ import AccountLogin from './accountLogin' ...@@ -8,6 +8,7 @@ import AccountLogin from './accountLogin'
import ForgotPassword from './forgotPassword' import ForgotPassword from './forgotPassword'
import SetPassword from './setPassword' import SetPassword from './setPassword'
import BindingTel from './bindingTel' import BindingTel from './bindingTel'
import {api} from "@/utils";
import account from './account.png' import account from './account.png'
import qq from './qq.png' import qq from './qq.png'
...@@ -17,6 +18,7 @@ import wechat from './wechat.png' ...@@ -17,6 +18,7 @@ import wechat from './wechat.png'
class Passport extends Component { class Passport extends Component {
redirect_url = location.protocol + '//' + location.hostname
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -28,15 +30,19 @@ class Passport extends Component { ...@@ -28,15 +30,19 @@ class Passport extends Component {
}, },
{ {
logo: wechat, logo: wechat,
text: '微信' text: '微信',
url: 'https://www.baidu.com'
}, },
{ {
logo: qq, logo: qq,
text: 'QQ' text: 'QQ',
url: 'https://www.baidu.com'
}, },
{ {
logo: sina, logo: sina,
text: '新浪' text: '新浪',
url: `http://passport-test.julyedu.com/mob/sinalogin?redirect_url=${this.redirect_url}`
}, },
] ]
} }
......
...@@ -21,12 +21,19 @@ class WechatLogin extends Component { ...@@ -21,12 +21,19 @@ class WechatLogin extends Component {
captchaInstance: null captchaInstance: null
} }
loginWaysClick = index => { loginWaysClick = method => {
switch (index) { console.log(method);
const {history} = this.props
switch (method) {
case '账号登录':
history.push('/passport/account-login')
break;
}
/*switch (index) {
case 0: case 0:
this.props.history.push('/passport/account-login') this.props.history.push('/passport/account-login')
break; break;
} }*/
} }
getCaptchaInstance = instance => { getCaptchaInstance = instance => {
......
...@@ -10,11 +10,13 @@ import { http, api } from "@/utils"; ...@@ -10,11 +10,13 @@ import { http, api } 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";
class SetPassword extends Component { class SetPassword extends Component {
render() { render() {
const {values, errors} = this.props
return ( return (
<> <>
<HeaderBar arrow={true} title={'设置密码'}/> <HeaderBar arrow={true} title={'设置密码'}/>
...@@ -34,7 +36,8 @@ class SetPassword extends Component { ...@@ -34,7 +36,8 @@ class SetPassword extends Component {
) )
}} }}
/> />
<Button className={'btn-active'}>完成</Button> <Button className={'btn-active'}
active={values.password && values.agreement && isEmpty(errors)}>完成</Button>
<label htmlFor="agreement" className='user-agreement'> <label htmlFor="agreement" className='user-agreement'>
<Field type='checkbox' <Field type='checkbox'
name='agreement' name='agreement'
......
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