|
|
@ -1,5 +1,6 @@
|
|
|
|
import {login, logout, getInfo} from '@/api/login'
|
|
|
|
import {login, logout, getInfo} from '@/api/login'
|
|
|
|
import {getToken, setToken, removeToken, removeAdminId, setAdminId} from '@/utils/auth'
|
|
|
|
import {getToken, setToken, removeToken, removeAdminId, setAdminId} from '@/utils/auth'
|
|
|
|
|
|
|
|
import {sha256} from "js-sha256";
|
|
|
|
|
|
|
|
|
|
|
|
const user = {
|
|
|
|
const user = {
|
|
|
|
state: {
|
|
|
|
state: {
|
|
|
@ -66,18 +67,18 @@ const user = {
|
|
|
|
// 登录
|
|
|
|
// 登录
|
|
|
|
Login({commit}, userInfo) {
|
|
|
|
Login({commit}, userInfo) {
|
|
|
|
const username = userInfo.username.trim()
|
|
|
|
const username = userInfo.username.trim()
|
|
|
|
const password = userInfo.password
|
|
|
|
const password = sha256(userInfo.password)
|
|
|
|
const code = userInfo.code
|
|
|
|
const code = userInfo.code
|
|
|
|
const uuid = userInfo.uuid
|
|
|
|
const uuid = userInfo.uuid
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
login(username, password, code, uuid).then(res => {
|
|
|
|
login(username, password, code, uuid).then(res => {
|
|
|
|
if(res.code == 20000){
|
|
|
|
if (res.code == 20000) {
|
|
|
|
setToken(res.data.token)
|
|
|
|
setToken(res.data.token)
|
|
|
|
setAdminId(res.data.id)
|
|
|
|
setAdminId(res.data.id)
|
|
|
|
commit('SET_TOKEN', res.data.token)
|
|
|
|
commit('SET_TOKEN', res.data.token)
|
|
|
|
commit('SET_ADMINID', res.data.id)
|
|
|
|
commit('SET_ADMINID', res.data.id)
|
|
|
|
resolve()
|
|
|
|
resolve(res)
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
reject(res.message);
|
|
|
|
reject(res.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch(error => {
|
|
|
|
}).catch(error => {
|
|
|
|