Commit 720d4b54 authored by zhangderong's avatar zhangderong

Merge branch 'deploy' of git.quantgroup.cn:ui/recruiting-management into Ztext1

Conflicts:
	src/service/init.service.js
parents b3e356e9 bf39373b
// todo: 测试环境部署的时候对xyqb.com进行替换,先改成这样进行测试,上线改回来
// const sapi = '//recruit.xyqb.com'
const sapi = '//api.stantoo.com'
export {
......
......@@ -2,6 +2,7 @@ import axios from 'axios'
import Promise from './promise.service.js'
import {Notice} from 'iview'
import Vue from 'vue'
import router from '../router/index.js'
// axios.defaults.withCredentials = true
var instance = axios.create({});
instance.defaults.timeout = 2500;
......@@ -9,7 +10,6 @@ instance.defaults.withCredentials = true;
instance.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
instance.defaults.headers['X-Requested-With'] = 'XMLHttpRequest'
instance.interceptors.request.use(function (config) {
// 在发送请求之前做些什么
if (!config.headers['Content-Type']) {
......@@ -24,14 +24,18 @@ instance.interceptors.response.use(function (response) {
// 在发送请求之前做些什么
if(response.status >= 200 && response.status < 300){
// if (response.data.body.code == '900'){
// Notice.error('您的账号已在其他地方登录,如不是您个人操作,请及时修改密码')
// window.location.href = `${window.location.origin}/login`
// }
// if (response.data.body.code == '901'){
// Notice.error('cookie已失效,请重新登录')
// window.location.href = `${window.location.origin}/login`
// }
if (response.data.body.code == '900'){
Notice.error({render:(h) => {return h('div', {style: {
paddingRight: '10px',
fontSize: '14px',
color: '#17233d'
}}, '您的账号已在其他地方登录,如不是您个人操作,请及时修改密码')}})
router.replace({name: 'login'})
}
if (response.data.body.code == '901'){
Notice.error({title:'cookie已失效,请重新登录'})
router.replace({name: 'login'})
}
if(response.data.success){
return Promise.resolve(response)
}
......
......@@ -3,10 +3,14 @@ export default{
init: function (router) {
router.beforeEach((to, form, next) => {
let token = localstorage.get('token')
if (!token&&to.name!=='login'&&to.name!=='updatepsd'&&to.name!=='sweepCode') {
if (to.name =='login' || to.name =='text' || to.name =='sweepCode'){
next()
return
}
if(!token){
window.location.href = `${window.location.origin}/login`
return
}
}
next()
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment