global.js
795 Bytes
/**
* 全局引用js
* @author: feng.chen<feng.chen@yoho.cn>
* @date: 2017/03/15
*/
import $ from 'jquery';
import cookie from 'yoho-cookie';
import yoho from 'yoho';
import tip from 'common/tip';
// 注册ajaxError处理服务端401状态
$(document).ajaxError((event, xhr) => {
if (xhr.status === 401) {
if (yoho.isApp && !cookie.get('app_version')) {
tip({
txt: '请升级APP至最新版',
delay: 600 * 1000
});
return;
}
cookie.remove('_UID');
cookie.remove('_TOKEN');
if (yoho.isApp) {
yoho.goLogin(window.location.href);
} else {
window.location.href = `/signin.html?refer=${encodeURIComponent(window.location.href)}`;
}
}
});