Commit c18a4e42 by zhanghaozhe

login-bind-phone

parent 433b6004
...@@ -171,12 +171,6 @@ class App extends Component { ...@@ -171,12 +171,6 @@ class App extends Component {
let oid = getParam('oid') let oid = getParam('oid')
if (code && !oid) { if (code && !oid) {
//针对2019双旦活动特殊处理,活动结束后删掉
//treasure_code=3538333139312c31&origin=2&aa=bb&code=0211aiYB1VVOL60rmWWB1367YB11aiY7&state=STATE
if (getParam('treasure_code') == '3538333139312c31' && code == '0211aiYB1VVOL60rmWWB1367YB11aiY7') {
return
}
http.get(`${API["passport-api"]}/m/wx_loginInfo/code/${code}?redirect=${encodeURIComponent(window.location.href)}`) http.get(`${API["passport-api"]}/m/wx_loginInfo/code/${code}?redirect=${encodeURIComponent(window.location.href)}`)
.then(res => { .then(res => {
let data = res.data let data = res.data
......
...@@ -77,6 +77,10 @@ const formikConfig = { ...@@ -77,6 +77,10 @@ const formikConfig = {
username, password, redirect: from && window.location.origin + from.pathname + from.search + from.hash username, password, redirect: from && window.location.origin + from.pathname + from.search + from.hash
}).then(res => { }).then(res => {
if (res.hasError) { if (res.hasError) {
if(res.code === 4004){
history.push(`/passport/binding-tel?username=${username}`)
return
}
Toast.info(res.msg, 2, null, false) Toast.info(res.msg, 2, null, false)
} }
}) })
......
...@@ -119,36 +119,67 @@ const formikConfig = { ...@@ -119,36 +119,67 @@ const formikConfig = {
return errors return errors
}, },
handleSubmit(values, {props}) { handleSubmit(values, {props}) {
http.post(`${API['passport-api']}/bind_mobile`, { const username = getParam('username')
phone_num: values.tel, if (username) {
phone_code: values.veriCode, //老账号绑定手机号
mkey: getParam('mkey'), http.post(`${API["passport-api"]}/m/personal/bindMobile`, {
area_code: '00' + props.country.num, phone_num: values.tel,
plat: 5 code: values.veriCode,
}).then(res => { type: 1,
const data = res.data area_code: '00' + props.country.num,
if (data.errno == 200) { user_name: username
if (data.data['is_set_pwd']) { }).then(res => {
const {history} = props const {data, errno, msg} = res.data
history.replace(`/passport/set-password`, { if (errno === 200) {
user: { props.setCurrentUser({
hasError: false, hasError: false,
data: { data: {
uid: data.data.uid username: data.user_name,
}, avatar: data.avatar_file,
msg: data.data.msg, isVip: parseInt(data.vip),
stage: 'binding' token: data.access_token,
uid: data.uid
} }
}) })
const {from} = props.location.state || {from: {pathname: '/'}}
props.history.push(from)
} else { } else {
location.assign(data.data['jump_url']) Toast.info(msg, 2, null, false)
} }
})
} else {
http.post(`${API['passport-api']}/bind_mobile`, {
phone_num: values.tel,
phone_code: values.veriCode,
mkey: getParam('mkey'),
area_code: '00' + props.country.num,
plat: 5
}).then(res => {
const data = res.data
if (data.errno == 200) {
if (data.data['is_set_pwd']) {
const {history} = props
history.replace(`/passport/set-password`, {
user: {
hasError: false,
data: {
uid: data.data.uid
},
msg: data.data.msg,
stage: 'binding'
}
})
} else {
location.assign(data.data['jump_url'])
}
} else { } else {
Toast.info(data.msg, 2, null, false) Toast.info(data.msg, 2, null, false)
} }
}) })
}
} }
} }
export default compose( export default compose(
......
...@@ -67,7 +67,8 @@ const storeUser = (res, dispatch) => { ...@@ -67,7 +67,8 @@ const storeUser = (res, dispatch) => {
payload = { payload = {
hasError: true, hasError: true,
msg: data.msg, msg: data.msg,
data: {} data: {},
code: data.errno
} }
} }
dispatch(setCurrentUser(payload)) dispatch(setCurrentUser(payload))
......
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