|
|
|
@ -1,39 +1,29 @@
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
|
|
import NewHeader from './NewHeader'
|
|
|
|
|
import NewFooter from './NewFooter'
|
|
|
|
|
import SiderBar from './SiderBar'
|
|
|
|
|
import { getUrl, downloadFile } from 'educoder'
|
|
|
|
|
import { downloadFile } from 'educoder'
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import { Spin } from 'antd';
|
|
|
|
|
import './TPMIndex.css';
|
|
|
|
|
import LoginDialog from '../login/LoginDialog';
|
|
|
|
|
import AccountProfile from '../user/AccountProfile';
|
|
|
|
|
import AccountPhoneemail from '../user/AccountPhoneemail';
|
|
|
|
|
import Trialapplication from "../login/Trialapplication";
|
|
|
|
|
// import "antd/dist/antd.css";
|
|
|
|
|
// import '../../css/educoder/edu-common.css'
|
|
|
|
|
// import '../../css/educoder/edu-all.css'
|
|
|
|
|
// import '../../css/educoder/edu-main.css'
|
|
|
|
|
|
|
|
|
|
const $ = window.$;
|
|
|
|
|
const versionNum = '0001';
|
|
|
|
|
// let _url_origin = getUrl()
|
|
|
|
|
|
|
|
|
|
let _url_origin = '';
|
|
|
|
|
if (window.location.port === "3007") {
|
|
|
|
|
_url_origin = "https://test-newweb.educoder.net";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// let _url_origin=`https://www.educoder.net`;
|
|
|
|
|
|
|
|
|
|
if (!window['indexHOCLoaded']) {
|
|
|
|
|
window.indexHOCLoaded = true;
|
|
|
|
|
//解决首屏加载问题
|
|
|
|
|
|
|
|
|
|
// $('head').append($('<link rel="stylesheet" type="text/css" />')
|
|
|
|
|
// .attr('href', `${_url_origin}/stylesheets/educoder/antd.min.css?1525440977`));
|
|
|
|
|
$('head').append($('<link rel="stylesheet" type="text/css" />')
|
|
|
|
|
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?3`));
|
|
|
|
|
|
|
|
|
@ -44,25 +34,7 @@ if (!window['indexHOCLoaded']) {
|
|
|
|
|
$('head').append($('<link rel="stylesheet" type="text/css" />')
|
|
|
|
|
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?3`));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $('head').append($('<link rel="stylesheet" type="text/css" />')
|
|
|
|
|
// .attr('href', `${_url_origin}/stylesheets/educoder/css_min_all.css?1525440977`));
|
|
|
|
|
// 加timeout 为了覆盖掉antd的样式
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// $('head').append( $('<link rel="stylesheet" type="text/css" />')
|
|
|
|
|
// .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?1525440977`) );
|
|
|
|
|
|
|
|
|
|
// $('head').append( $('<link rel="stylesheet" type="text/css" />')
|
|
|
|
|
// .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?1525440977`) );
|
|
|
|
|
// $('head').append( $('<link rel="stylesheet" type="text/css" />')
|
|
|
|
|
// .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?1525440977`) );
|
|
|
|
|
// }, 1000);
|
|
|
|
|
|
|
|
|
|
$("script").append('<script></script>')
|
|
|
|
|
.attr('src', `${_url_origin}/javascripts/jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?_t=${versionNum}`);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// `${_url_origin}/javascripts/jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?_t=${versionNum}`
|
|
|
|
|
// TODO css加载完成后再打开页面,行为和tpm其他页面一致
|
|
|
|
|
export function TPMIndexHOC(WrappedComponent) {
|
|
|
|
|
// 这里如果extends WrappedComponent 会出现 WrappedComponent mount twice的问题
|
|
|
|
@ -90,7 +62,6 @@ export function TPMIndexHOC(WrappedComponent) {
|
|
|
|
|
|
|
|
|
|
// header里面需要有user
|
|
|
|
|
initCommonState(user) {
|
|
|
|
|
// 更新头像后,需要改变参数,不然会被图片缓存影响到 --> 后台已加 ?t=${new Date().getTime()
|
|
|
|
|
const newUser = Object.assign({}, { ...user }, { image_url: `${user.image_url}` });
|
|
|
|
|
this.setState({
|
|
|
|
|
user: newUser,
|
|
|
|
@ -128,7 +99,6 @@ export function TPMIndexHOC(WrappedComponent) {
|
|
|
|
|
.then((response) => {
|
|
|
|
|
const status = response.data.status;
|
|
|
|
|
if (status == 1) {
|
|
|
|
|
const new_author_info = Object.assign({}, creator)
|
|
|
|
|
this.setState({
|
|
|
|
|
watched: !watched
|
|
|
|
|
})
|
|
|
|
@ -148,8 +118,6 @@ export function TPMIndexHOC(WrappedComponent) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
// console.log("TPMIndexHOC========");
|
|
|
|
|
// console.log(this.props);
|
|
|
|
|
window.addEventListener('keyup', this.keyupListener)
|
|
|
|
|
|
|
|
|
|
if (this.props.match.path === "/") {
|
|
|
|
@ -166,28 +134,6 @@ export function TPMIndexHOC(WrappedComponent) {
|
|
|
|
|
document.title = "翻转课堂";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if(this.props.match.path==="/"){
|
|
|
|
|
// document.title="EduCoder-IT实践教学平台_信息技术类精品课程网_大学生MOOC平台";
|
|
|
|
|
// }else if(this.props.match.path==="/403"){
|
|
|
|
|
// document.title="你没有权限访问";
|
|
|
|
|
// }else if(this.props.match.path==="/nopage"){
|
|
|
|
|
// document.title="没有找到该页面";
|
|
|
|
|
// }else if(this.props.match.path==="/shixuns"){
|
|
|
|
|
// document.title="EduCoder-IT实践教学平台_信息技术类精品课程网_大学生MOOC平台";
|
|
|
|
|
// }else if(this.props.match.path==="/paths"){
|
|
|
|
|
// document.title="实践课程_项目实战开发_web前端开发实训_web后端开发实战_人工智能技术-EduCoder";
|
|
|
|
|
// }else if(this.props.match.path==="/courses"){
|
|
|
|
|
// document.title="实训项目_php后端开发_app前端开发_java_python实训_C语言入门课程-EduCoder";
|
|
|
|
|
// }else if(this.props.match.path==="/competitions"){
|
|
|
|
|
// document.title="在线竞赛_计算机应用大赛_编程大赛_大学生设计大赛_全国高校绿色计算大赛-EduCoder";
|
|
|
|
|
// }else if(this.props.match.path==="/moop_cases"){
|
|
|
|
|
// document.title="教学案例-EduCoder";
|
|
|
|
|
// }else if(this.props.match.path==="/forums"){
|
|
|
|
|
// document.title="交流问答-EduCoder";
|
|
|
|
|
// }else if(this.props.match.path==="/forums"){
|
|
|
|
|
// document.title="交流问答-EduCoder";
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
$.ajaxSetup({
|
|
|
|
|
cache: true
|
|
|
|
|
});
|
|
|
|
@ -216,7 +162,7 @@ export function TPMIndexHOC(WrappedComponent) {
|
|
|
|
|
dataquerys: {},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.fetchUsers(dataqueryss);
|
|
|
|
|
this.fetchUser(dataqueryss);
|
|
|
|
|
|
|
|
|
|
let url = `/users/get_navigation_info.json`;
|
|
|
|
|
axios.get(url, {
|
|
|
|
@ -462,71 +408,6 @@ export function TPMIndexHOC(WrappedComponent) {
|
|
|
|
|
console.log(error)
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
fetchUsers = (yslurlobject) => {
|
|
|
|
|
let url = `/users/get_user_info.json`
|
|
|
|
|
let courseId;
|
|
|
|
|
let query = this.props.location.pathname;
|
|
|
|
|
const type = query.split('/');
|
|
|
|
|
if (type[1] == 'courses' && type[2]) {
|
|
|
|
|
courseId = parseInt(type[2])
|
|
|
|
|
// url += `?course_id=${courseId}`
|
|
|
|
|
}
|
|
|
|
|
var datay = {};
|
|
|
|
|
if (JSON.stringify(yslurlobject) === "{}") {
|
|
|
|
|
datay = {
|
|
|
|
|
course_id: isNaN(courseId) ? undefined : courseId,
|
|
|
|
|
school: 1
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
datay = {
|
|
|
|
|
course_id: isNaN(courseId) ? undefined : courseId,
|
|
|
|
|
school: 1,
|
|
|
|
|
chinaoocTimestamp: yslurlobject.chinaoocTimestamp,
|
|
|
|
|
websiteName: yslurlobject.websiteName,
|
|
|
|
|
chinaoocKey: yslurlobject.chinaoocKey,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
axios.get(url, {
|
|
|
|
|
params:
|
|
|
|
|
datay
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// withCredentials: true
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
/*
|
|
|
|
|
{
|
|
|
|
|
"username": "黄井泉",
|
|
|
|
|
"login": "Hjqreturn",
|
|
|
|
|
"user_id": 12,
|
|
|
|
|
"image_url": "avatar/User/12",
|
|
|
|
|
"admin": true,
|
|
|
|
|
"is_teacher": false,
|
|
|
|
|
"tidding_count": 0
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
if (response === undefined) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (response.data) {
|
|
|
|
|
this.initCommonState(response.data)
|
|
|
|
|
this.setState({
|
|
|
|
|
tpmLoading: false,
|
|
|
|
|
coursedata: {
|
|
|
|
|
course_identity: response.data.course_identity >= 0 ? response.data.course_identity : undefined,
|
|
|
|
|
course_public: response.data.course_public,
|
|
|
|
|
name: response.data.course_name,
|
|
|
|
|
userid: response.data.user_id
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
//截取url 数据的
|
|
|
|
|
foo = (url) => {
|
|
|
|
|
var json = {};
|
|
|
|
@ -534,12 +415,9 @@ export function TPMIndexHOC(WrappedComponent) {
|
|
|
|
|
var arr;
|
|
|
|
|
do {
|
|
|
|
|
arr = regExp.exec(url);
|
|
|
|
|
// console.log(arr); // arr = [完整的字符串, key, 等号或'', value或'']
|
|
|
|
|
|
|
|
|
|
if (arr) {
|
|
|
|
|
var key = arr[1];
|
|
|
|
|
var value = arr[3];
|
|
|
|
|
// arr[2] === ''时, value = undefined
|
|
|
|
|
if (!arr[2])
|
|
|
|
|
value = undefined;
|
|
|
|
|
|
|
|
|
|