|
|
|
@ -12,6 +12,7 @@ const opens ="79e33abd4b6588941ab7622aed1e67e8";
|
|
|
|
|
let timestamp;
|
|
|
|
|
let checkSubmitFlg = false;
|
|
|
|
|
let message501=false;
|
|
|
|
|
|
|
|
|
|
broadcastChannelOnmessage('refreshPage', () => {
|
|
|
|
|
window.location.reload()
|
|
|
|
|
})
|
|
|
|
@ -25,21 +26,11 @@ function locationurl(list){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setCookier(){
|
|
|
|
|
const _params = window.location.search;
|
|
|
|
|
if (_params) {
|
|
|
|
|
let _search = _params.split('?')[1];
|
|
|
|
|
_search.split('&').forEach(item => {
|
|
|
|
|
console.log(item);
|
|
|
|
|
const _arr = item.split('=');
|
|
|
|
|
cookie.save('_educoder_session',_arr[0]);
|
|
|
|
|
cookie.save('autologin_trustie',_arr[1]);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 开发期多个身份切换
|
|
|
|
|
let debugType =""
|
|
|
|
|
let debugType =""
|
|
|
|
|
if (isDev) {
|
|
|
|
|
const _search = window.location.search;
|
|
|
|
|
let parsed = {};
|
|
|
|
@ -56,69 +47,71 @@ if (isDev) {
|
|
|
|
|
//debugType="teacher";
|
|
|
|
|
// 学生
|
|
|
|
|
//debugType="student";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function clearAllCookie() {
|
|
|
|
|
cookie.remove('_educoder_session', {path: '/'});
|
|
|
|
|
cookie.remove('autologin_trustie', {path: '/'});
|
|
|
|
|
setpostcookie()
|
|
|
|
|
}
|
|
|
|
|
clearAllCookie();
|
|
|
|
|
function setpostcookie() {
|
|
|
|
|
try {
|
|
|
|
|
const str =window.location.pathname;
|
|
|
|
|
let newdomain=".educoder.net"
|
|
|
|
|
|
|
|
|
|
if(window.location.origin==="https://www.educoder.net"){
|
|
|
|
|
newdomain=".educoder.net";
|
|
|
|
|
}else{
|
|
|
|
|
const str =window.location.pathname;
|
|
|
|
|
console.log(str.indexOf("/wxcode"))
|
|
|
|
|
let newdomain=".educoder.net"
|
|
|
|
|
if(str.indexOf("/wxcode") !== -1){
|
|
|
|
|
console.log("123")
|
|
|
|
|
cookie.remove('_educoder_session', {path: '/'});
|
|
|
|
|
cookie.remove('autologin_trustie', {path: '/'});
|
|
|
|
|
// console.log("开始重写cookis");
|
|
|
|
|
const _params = window.location.search;
|
|
|
|
|
// console.log("1111");
|
|
|
|
|
if (_params) {
|
|
|
|
|
// console.log("22222");
|
|
|
|
|
let _search = _params.split('?')[1];
|
|
|
|
|
let _educoder_sessions= _search.split('&')[0].split('=');
|
|
|
|
|
cookie.save('_educoder_session',_educoder_sessions[1], { domain:'.educoder.net', path: '/'});
|
|
|
|
|
let autologin_trusties=_search.split('&')[1].split('=');
|
|
|
|
|
cookie.save('autologin_trustie',autologin_trusties[1], { domain:'.educoder.net', path: '/'});
|
|
|
|
|
|
|
|
|
|
newdomain="test-newweb.educoder.net";
|
|
|
|
|
}
|
|
|
|
|
if(str.indexOf("/wxcode") !== -1){
|
|
|
|
|
// console.log("开始重写cookis");
|
|
|
|
|
const _params = window.location.search;
|
|
|
|
|
// console.log("1111");
|
|
|
|
|
if (_params) {
|
|
|
|
|
// console.log("22222");
|
|
|
|
|
let _search = _params.split('?')[1];
|
|
|
|
|
_search.split('&').forEach(item => {
|
|
|
|
|
const _arr = item.split('=');
|
|
|
|
|
if(_arr[0]==='_educoder_session'){
|
|
|
|
|
console.log(newdomain)
|
|
|
|
|
cookie.save('_educoder_session',_arr[1],{ path: '/' });
|
|
|
|
|
cookie.save('_educoder_session',_arr[1], { domain: newdomain, path: '/'});
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
console.log(newdomain)
|
|
|
|
|
cookie.save('autologin_trustie',_arr[1],{ path: '/' });
|
|
|
|
|
cookie.save('autologin_trustie',_arr[1], { domain: newdomain, path: '/'});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setpostcookie();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function railsgettimes(proxy) {
|
|
|
|
|
if(timestamp&&checkSubmitFlg===false){
|
|
|
|
|
$.ajax({url:proxy,async:false,success:function(data){
|
|
|
|
|
if(data.status===0){
|
|
|
|
|
timestamp=data.message;
|
|
|
|
|
setpostcookie();
|
|
|
|
|
}
|
|
|
|
|
}})
|
|
|
|
|
checkSubmitFlg=true
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
checkSubmitFlg=false;
|
|
|
|
|
}, 2000);
|
|
|
|
|
}else if(checkSubmitFlg===false){
|
|
|
|
|
$.ajax({url:proxy,async:false,success:function(data){
|
|
|
|
|
if(data.status===0){
|
|
|
|
|
timestamp=data.message;
|
|
|
|
|
setpostcookie();
|
|
|
|
|
}
|
|
|
|
|
}})
|
|
|
|
|
checkSubmitFlg=true
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
checkSubmitFlg=false;
|
|
|
|
|
}, 2000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearAllCookie()
|
|
|
|
|
|
|
|
|
|
if(timestamp&&checkSubmitFlg===false){
|
|
|
|
|
$.ajax({url:proxy,async:false,success:function(data){
|
|
|
|
|
if(data.status===0){
|
|
|
|
|
timestamp=data.message;
|
|
|
|
|
setpostcookie();
|
|
|
|
|
}
|
|
|
|
|
}})
|
|
|
|
|
checkSubmitFlg=true
|
|
|
|
|
window.setTimeout(()=>{
|
|
|
|
|
checkSubmitFlg=false;
|
|
|
|
|
}, 2000);
|
|
|
|
|
}else if(checkSubmitFlg===false){
|
|
|
|
|
$.ajax({url:proxy,async:false,success:function(data){
|
|
|
|
|
if(data.status===0){
|
|
|
|
|
timestamp=data.message;
|
|
|
|
|
setpostcookie();
|
|
|
|
|
}
|
|
|
|
|
}})
|
|
|
|
|
checkSubmitFlg=true
|
|
|
|
|
window.setTimeout( ()=>{
|
|
|
|
|
checkSubmitFlg=false;
|
|
|
|
|
}, 2000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -157,6 +150,8 @@ export function initAxiosInterceptors(props) {
|
|
|
|
|
//响应前的设置
|
|
|
|
|
axios.interceptors.request.use(
|
|
|
|
|
config => {
|
|
|
|
|
setpostcookie()
|
|
|
|
|
clearAllCookie()
|
|
|
|
|
// config.headers['Content-Type']= 'no-cache'
|
|
|
|
|
// if (token) { // 每次发送请求之前判断是否存在token,如果存在,则统一在http请求的header都加上token,不用每次请求都手动添加了
|
|
|
|
|
// config.headers.Authorization = token;
|
|
|
|
@ -259,6 +254,7 @@ export function initAxiosInterceptors(props) {
|
|
|
|
|
config.url = `${config.url}&randomcode=${timestamp}&client_key=${newopens}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setpostcookie();
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// console.log(config);
|
|
|
|
@ -285,6 +281,7 @@ export function initAxiosInterceptors(props) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
axios.interceptors.response.use(function (response) {
|
|
|
|
|
|
|
|
|
|
// console.log(".............")
|
|
|
|
|
if(response===undefined){
|
|
|
|
|
return
|
|
|
|
@ -386,7 +383,7 @@ export function initAxiosInterceptors(props) {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
requestMap[response.config.url] = false;
|
|
|
|
|
|
|
|
|
|
setpostcookie();
|
|
|
|
|
return response;
|
|
|
|
|
}, function (error) {
|
|
|
|
|
return Promise.reject(error);
|
|
|
|
|