调整小程序跨h5登录问题

dev_video
杨树明 5 years ago
parent 7e3062001e
commit 6ee46dda3b

@ -56,6 +56,43 @@ if (isDev) {
//debugType="teacher";
// 学生
//debugType="student";
function setpostcookie() {
try {
const str =window.location.pathname;
let newdomain=".educoder.net"
if(window.location.origin==="https://www.educoder.net"){
newdomain=".educoder.net";
}else{
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) {
}
}
function railsgettimes(proxy) {
@ -63,6 +100,7 @@ if (isDev) {
$.ajax({url:proxy,async:false,success:function(data){
if(data.status===0){
timestamp=data.message;
setpostcookie();
}
}})
checkSubmitFlg=true
@ -73,6 +111,7 @@ if (isDev) {
$.ajax({url:proxy,async:false,success:function(data){
if(data.status===0){
timestamp=data.message;
setpostcookie();
}
}})
checkSubmitFlg=true
@ -81,6 +120,11 @@ if (isDev) {
}, 2000);
}
}
window._debugType = debugType;
export function initAxiosInterceptors(props) {
initOnlineOfflineListener()
@ -100,31 +144,7 @@ export function initAxiosInterceptors(props) {
// proxy="https://test-newweb.educoder.net"
// proxy="https://test-jupyterweb.educoder.net"
//proxy="http://192.168.2.63:3001"
try {
const str =window.location.pathname;
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'){
cookie.save('_educoder_session',_arr[1],{ path: '/' });
cookie.save('_educoder_session',_arr[1], { domain: '.educoder.net', path: '/'});
}else{
cookie.save('autologin_trustie',_arr[1],{ path: '/' });
cookie.save('autologin_trustie',_arr[1], { domain: '.educoder.net', path: '/'});
}
});
}
}
}catch (e) {
}
// 在这里使用requestMap控制避免用户通过双击等操作发出重复的请求
// 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制

@ -45,22 +45,22 @@ const App = (props) => {
const {identifier} = props.match.params;
// 获取路径参数
const 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.remove(_arr[0], {
path: '/',
domain: '.educoder.net'
});
cookie.save(_arr[0], _arr[1], {
path: '/',
domain: '.educoder.net'
});
});
}
// const _params = window.location.search;
// if (_params) {
// let _search = _params.split('?')[1];
// _search.split('&').forEach(item => {
// // console.log(item);
// const _arr = item.split('=');
// cookie.remove(_arr[0], {
// path: '/',
// domain: '.educoder.net'
// });
// cookie.save(_arr[0], _arr[1], {
// path: '/',
// domain: '.educoder.net'
// });
// });
// }
}
setCookier();
const [isActive, setIsActive] = useState(-1);

@ -1,7 +1,7 @@
/*
* @Description:
* @Description:
* @Author: tangjiang
* @Github:
* @Github:
* @Date: 2020-01-15 15:41:10
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-18 11:43:43
@ -37,21 +37,22 @@ export const getWXCodeTestCase = (identifier, params) => {
// console.log('加载测试集: ====>>>>>>', res);
try{
const {data = {}} = res;
console.log(data.test_sets);
const _path = data.challenge.path;
dispatch({
type: types.GET_WXCODE_TEST_CASE,
payload: {
test_sets: data.test_sets || [],
game_id: data.game && data.game.id,
myIdentifier: data.myshixun.identifier,
exec_time: data.challenge.exec_time,
path: _path.split('')[0] || _path.split(';')[0] || _path,
last_compile_output: data.last_compile_output,
test_sets_count: data.test_sets_count,
sets_error_count: data.sets_error_count
}
});
if(data.test_sets){
const _path = data.challenge.path;
dispatch({
type: types.GET_WXCODE_TEST_CASE,
payload: {
test_sets: data.test_sets || [],
game_id: data.game && data.game.id,
myIdentifier: data.myshixun.identifier,
exec_time: data.challenge.exec_time,
path: _path.split('')[0] || _path.split(';')[0] || _path,
last_compile_output: data.last_compile_output,
test_sets_count: data.test_sets_count,
sets_error_count: data.sets_error_count
}
});
}
} catch(err) {
console.log(err);
};
@ -123,7 +124,7 @@ export const evaluateWxCode = (identifier, path) => {
sets_error_count
} = getState().wxcodeReducer;
updateWxCode(path, myIdentifier, userCode, game_id, 1).then(res => {
// build
// build
// const {} = res;
console.log(res);
const _resubmit = res.data.resubmit;
@ -176,7 +177,7 @@ export const evaluateWxCode = (identifier, path) => {
type: types.SHOW_WX_CODE_DIALOG,
payload: true
});
} else {
dispatch({
type: types.IS_SHOW_WXCODE_TEST_CASES,
@ -211,7 +212,7 @@ export const evaluateWxCode = (identifier, path) => {
}
})
}, 50);
}).catch(err => {
dispatch({
type: types.SHOW_WX_CODE_LOADING,

Loading…
Cancel
Save