UNPKG

py-uni

Version:

py-uni

37 lines (31 loc) 1.15 kB
import {AuthorizeService} from "../service/authorize.service"; import {Message} from "../service/message.service"; const message = new Message(); const authorizeService = new AuthorizeService(); function PasswordLogin(messageToast: any, username: string, password: string) { let checkStatus = checkPassword(messageToast, username, password); if (checkStatus) { requestLogin(messageToast, username, password); } } function checkPassword(messageToast: any, username: string, password: string): boolean { if (!username) { message.showToast(messageToast, '请输入用户名', 'error'); return false; } if (!password) { message.showToast(messageToast, '请输入密码', 'error'); return false; } return true; } function requestLogin(messageToast: any, username: string, password: string) { authorizeService.Login(username, password).then((res) => { if (res.Code === 0) { return res; } else { message.showToast(messageToast, res.Msg, 'error'); } }) } export default PasswordLogin;