源代码:
const fetchInfo = (value,type)=> {
let url = type==='login' ? port()+'/card/login?isWx=true' : port()+''; //登录或者注册
let data = type==='login' ? {
phone: value.phone ,
password: hex_md5(value.password)
} : {
}
return dispatch =>{
dispatch(beginFetch());
return fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
}).then( res =>{
console.log(res.status);
console.log(res.json());
return res.json()
}).then( json => {
console.log(json);
dispatch(loginSuccess());
}).catch( e =>{
dispatch(fallFetch());
console.log(e.message)
});
}
}