Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleSubmit = e => {
e.preventDefault();
const { username, password } = this.state.form;
const { dispatch } = this.props;
if (!username) {
Toast.show('请输入用户名');
return;
}
if (!password) {
Toast.show('请输入密码');
return;
}
Toast.loading('登录中...', 0);
// ajax
AjaxLogin(this.state.form)
.then(res => {
if (res && res.code === 1) {
let user = res.data;
// dispatch
dispatch(setUser(user));
// set cookie
let expiresTime = new Date(new Date().getTime() + 2 * 60 * 60 * 1000); //2h
handleSubmit = e => {
e.preventDefault();
const { username, password } = this.state.form;
const { dispatch } = this.props;
if (!username) {
Toast.show('请输入用户名');
return;
}
if (!password) {
Toast.show('请输入密码');
return;
}
Toast.loading('登录中...', 0);
// ajax
AjaxLogin(this.state.form)
.then(res => {
if (res && res.code === 1) {
let user = res.data;
// dispatch
dispatch(setUser(user));
// set cookie
let expiresTime = new Date(new Date().getTime() + 2 * 60 * 60 * 1000); //2h
Cookie.set('token', user.token, { expires: expiresTime });
Cookie.set('username', user.username);
Toast.info('登录成功', 1, this.props.history.goBack());
}
<h4> Toast.show(house.model)}>{house.model}</h4>
) : (
onBackPress = () => {
const { dispatch, nav } = this.props
if (nav.routes[0].index === 0) {
if (this.lastBackPressed && this.lastBackPressed + 2000 >= Date.now()) {
BackHandler.exitApp()
return true
}
this.lastBackPressed = Date.now()
Toast.show('再按一次退出应用')
return true
} else {
dispatch(NavigationActions.back())
return true
}
}
<span> Toast.show('暂无')}>电话</span>
)}
Toast.show('click')}>国庆期间余额宝收益和转出到账时间
error => {
if (error.message === 'Request failed with status code 500') {
Toast.show('服务器出错');
} else {
Toast.show(error.message);
}
return Promise.reject(error);
}
);
this.setState({ isLike: !isLike }, () => Toast.show(res.msg, 1));
}
error => {
if (error.message === 'Request failed with status code 500') {
Toast.show('服务器出错');
} else {
Toast.show(error.message);
}
return Promise.reject(error);
}
);
UserLikeHouse(tid, true).then(res => {
if (res && res.code) {
Toast.show(res.msg, 1);
this.updateList(tid);
}
});
};