| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import api from "../api/common";
- import store from '../store';
- function login(username, password) {
- return new Promise((resolve, reject) => {
- api.login({
- userName: username,
- password: password,
- clientId: "1",
- }).then((result) => {
- if (result.code == 200) {
- store.commit("setUserInfo", result.content);
- store.commit("setToken", result.message);
- store.commit("setUserState", true);
- resolve();
- } else {
- reject(result.content);
- }
- }).catch((err) => {
- reject("服务器忙碌,请稍后重试!");
- });
- });
- }
- export default function encrypt(loginObj) {
- return new Promise((resolve, reject) => {
- if (loginObj == undefined) {
- login(systemConfig.defaultAccount.username, AesEncryptUtil.getPassword()).then(function (result) {
- resolve("登录成功");
- }).catch(function (err) {
- reject(err);
- });
- } else {
- if (loginObj.username == undefined || loginObj.username == "" || loginObj.username == null) {
- reject("用户名为空")
- }
- if (loginObj.password == undefined || loginObj.password == "" || loginObj.password == null) {
- reject("密码为空")
- }
- return login(loginObj.username, AesEncryptUtil.getPassword(loginObj.password)).then(function (result) {
- resolve("登录成功");
- }).catch(function (err) {
- reject(err);
- });
- }
- })
- }
|