| | |
| | | ENV = 'development' |
| | | |
| | | # base api |
| | | VUE_APP_BASE_API = '/dev-api' |
| | | VUE_APP_BASE_API = 'http://121.196.36.24:8001/api/' |
| | |
| | | |
| | | export function login(data) { |
| | | return request({ |
| | | url: '/vue-admin-template/user/login', |
| | | method: 'post', |
| | | data |
| | | url: 'Login/LoginSave', |
| | | method: 'get', |
| | | params: data |
| | | }) |
| | | } |
| | | |
| | |
| | | name: 'wldw', |
| | | component: '/jcsz/wldw', |
| | | meta: { title: '往来单位', icon: '' } |
| | | }, |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | |
| | | asyncRoutes.push({ path: '*', redirect: '/404', hidden: true }) |
| | | commit('SET_ROUTES', asyncRoutes) |
| | | resolve(asyncRoutes) |
| | | console.log(asyncRoutes, 1) |
| | | }) |
| | | } |
| | | } |
| | |
| | | import { login, logout, getInfo } from '@/api/user' |
| | | import { getToken, setToken, removeToken } from '@/utils/auth' |
| | | import { getToken, setToken, removeToken, setCookie } from '@/utils/auth' |
| | | import { resetRouter } from '@/router' |
| | | |
| | | const getDefaultState = () => { |
| | |
| | | const { username, password } = userInfo |
| | | return new Promise((resolve, reject) => { |
| | | login({ username: username.trim(), password: password }).then(response => { |
| | | const { data } = response |
| | | commit('SET_TOKEN', data.token) |
| | | setToken(data.token) |
| | | const { data: res } = response |
| | | |
| | | setCookie('admin', res.username) |
| | | setCookie('navTabId', res.usercode) |
| | | // commit('SET_TOKEN', data.token) |
| | | // setToken(res) |
| | | // commit('SET_TOKEN', res) |
| | | // setToken(res) |
| | | resolve() |
| | | }).catch(error => { |
| | | reject(error) |
| | |
| | | export function removeToken() { |
| | | return Cookies.remove(TokenKey) |
| | | } |
| | | |
| | | export function getCookie(key) { |
| | | return Cookies.get(key) |
| | | } |
| | | |
| | | export function setCookie(key, value) { |
| | | return Cookies.set(key, value) |
| | | } |
| | | |
| | | export function removeCookie(key) { |
| | | return Cookies.remove(key) |
| | | } |
| | |
| | | const res = response.data |
| | | |
| | | // if the custom code is not 20000, it is judged as an error. |
| | | if (res.code !== 20000) { |
| | | if (res.code !== '200') { |
| | | Message({ |
| | | message: res.message || 'Error', |
| | | message: res.Message || 'Error', |
| | | type: 'error', |
| | | duration: 5 * 1000 |
| | | }) |
| | |
| | | } |
| | | return { |
| | | loginForm: { |
| | | username: 'admin', |
| | | password: '111111' |
| | | username: 'Admin', |
| | | password: '123456' |
| | | }, |
| | | loginRules: { |
| | | username: [{ required: true, trigger: 'blur', validator: validateUsername }], |