dev_aliyun2
harry 5 years ago
parent b48a7f4913
commit 39b575f91d

@ -1,27 +1,23 @@
import React from 'react';
import React, { Component } from 'react';
import NewHeader from './NewHeader'
import NewFooter from './NewFooter'
import SiderBar from './SiderBar'
import { downloadFile } from 'educoder'
import { getUrl, 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 Loading from '../../Loading';
const $ = window.$;
let _url_origin='';
if(window.location.port === "3007"){
_url_origin="https://test-newweb.educoder.net";
}
if (!window['indexHOCLoaded']) {
window.indexHOCLoaded = true;
//解决首屏加载问题
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?3`));
@ -34,7 +30,6 @@ if (!window['indexHOCLoaded']) {
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?3`));
}
// TODO css加载完成后再打开页面行为和tpm其他页面一致
export default function TPMIndexHOC(WrappedComponent) {
// 这里如果extends WrappedComponent 会出现 WrappedComponent mount twice的问题
return class II extends React.Component {
@ -170,54 +165,6 @@ export default function TPMIndexHOC(WrappedComponent) {
// console.log(this.foo(query));
// console.log(JSON.stringify(this.foo(query)));
var dataqueryss={}
try {
var foqus=this.foo(query);
if(JSON.stringify(foqus) ==="{}"){
this.setState({
dataquerys:{},
});
}else{
this.setState({
watched: !watched
})
}
}).catch((error) => {
console.log(error)
})
}
keyupListener = (e) => {
if (e.key === "Escape") {
this.setState({ globalLoading: false })
}
}
componentWillUnmount() {
window.removeEventListener('keyup', this.keyupListener)
}
componentDidMount() {
window.addEventListener('keyup', this.keyupListener)
if (this.props.match.path === "/") {
} 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 = "实训项目";
} else if (this.props.match.path === "/paths") {
document.title = "实践课程";
} else if (this.props.match.path === "/courses") {
document.title = "翻转课堂";
}
$.ajaxSetup({
cache: true
});
//帮助后台传参数
const query = this.props.location.search;
var dataqueryss = {}
try {
var foqus=this.foo(query);
if(JSON.stringify(foqus) ==="{}"){
@ -235,6 +182,58 @@ export default function TPMIndexHOC(WrappedComponent) {
dataquerys:{},
})
}
this.fetchUsers(dataqueryss);
let url=`/users/get_navigation_info.json`;
axios.get(url, {
}).then((response) => {
// console.log("开始请求/get_navigation_info.json");
// console.log(response);
if(response!=undefined){
if(response.status===200){
this.setState({
Headertop:response.data.top,
Footerdown:response.data.down
})
}
}
});
///请求定制化的信息
this.getAppdata();
}
/**
课堂权限相关方法暂时写这里了 ----------------------------------------START
ADMIN = 0 # 超级管理员
CREATOR = 1 # 课程创建者
PROFESSOR = 2 # 课程老师
ASSISTANT_PROFESSOR = 3 # 课程助教
STUDENT = 4 # 学生
NORMAL = 5 # 普通用户
v2
# 课程权限判断
ADMIN = 0 # 超级管理员
BUSINESS = 1 # 运营人员
CREATOR = 2 # 课程创建者 课堂管理员
PROFESSOR = 3 # 课程老师
ASSISTANT_PROFESSOR = 4 # 课程助教
STUDENT = 5 # 学生
NORMAL = 6 # 普通用户
Anonymous = 7 # 普未登录
*/
//超管0
isSuperAdmin = () => {
// return false
return this.state.coursedata&&this.state.coursedata.course_identity === 0
}
isCourseAdmin = () => {
return this.state.coursedata&&this.state.coursedata.course_identity === 2
}
//超管、运维0-1
isClassManagement = () => {
return this.state.coursedata&&this.state.coursedata.course_identity < 2
}
//超管、运维、课堂管理0-2
isAdminOrCreator = () => {
return this.state.coursedata&&this.state.coursedata.course_identity < 3
@ -277,6 +276,42 @@ export default function TPMIndexHOC(WrappedComponent) {
//获取数据为空的时候
gettablogourlnull = () => {
this.setState({
mygetHelmetapi: undefined
});
document.title = "EduCoder";
var link = document.createElement('link'),
oldLink = document.getElementById('dynamic-favicon');
link.id = 'dynamic-favicon';
link.rel = 'shortcut icon';
link.href = "/react/build/./favicon.ico";
if (oldLink) {
document.head.removeChild(oldLink);
}
document.head.appendChild(link);
};
//获取数据的时候
gettablogourldata = (response) => {
document.title = response.data.setting.name;
var link = document.createElement('link'),
oldLink = document.getElementById('dynamic-favicon');
link.id = 'dynamic-favicon';
link.rel = 'shortcut icon';
link.href = '/' + response.data.setting.tab_logo_url;
if (oldLink) {
document.head.removeChild(oldLink);
}
document.head.appendChild(link);
}
//获取当前定制信息
getAppdata = () => {
try {
var chromesettingArray = JSON.parse(localStorage.getItem('chromesetting'));
var chromesettingresponseArray = JSON.parse(localStorage.getItem('chromesettingresponse'));
// console.log("TPMLNdexHOC");
// console.log(chromesettingArray);
// console.log(chromesettingresponseArray);
this.setState({
mygetHelmetapi:chromesettingArray
});
@ -328,6 +363,10 @@ export default function TPMIndexHOC(WrappedComponent) {
}).catch((error) => {
this.gettablogourlnull();
});
}
fetchUser = () => {
let url = `/users/get_user_info.json`
let courseId;
@ -401,19 +440,28 @@ export default function TPMIndexHOC(WrappedComponent) {
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: this.state.dataquerys.chinaoocTimestamp,
websiteName: this.state.dataquerys.websiteName,
chinaoocKey: this.state.dataquerys.chinaoocKey,
chinaoocTimestamp:yslurlobject.chinaoocTimestamp,
websiteName:yslurlobject.websiteName,
chinaoocKey:yslurlobject.chinaoocKey,
}
}
axios.get(url, {
params:
axios.get(url,{params:
datay
}).then((response) => {
},
{
// withCredentials: true
}
).then((response) => {
/*
{
"username": "黄井泉",
@ -454,9 +502,12 @@ export default 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;
@ -620,45 +671,6 @@ export default function TPMIndexHOC(WrappedComponent) {
}
}
render() {
let { Headertop, Footerdown, isRender, AccountProfiletype, AccountPhoneemailtype } = this.state;
const common = {
isSuperAdmin: this.isSuperAdmin,
isAdminOrCreator: this.isAdminOrCreator,
isClassManagement: this.isClassManagement,
isCourseAdmin: this.isCourseAdmin,
isAdmin: this.isAdmin,
isAdminOrTeacher: this.isAdminOrTeacher,
isStudent: this.isStudent,
isAdminOrStudent: this.isAdminOrStudent,
isNotMember: this.isNotMember,
isCourseEnd: this.isCourseEnd,
isUserid: this.state.coursedata && this.state.coursedata.userid,
fetchUser: this.fetchUser,
showLoginDialog: this.showLoginDialog,
checkIfLogin: this.checkIfLogin,
showProfileCompleteDialog: this.showProfileCompleteDialog,
showhideAccountPhoneemailDialog: this.showhideAccountPhoneemailDialog,
checkIfProfileCompleted: this.checkIfProfileCompleted,
showaccountprofileDialog: this.showaccountprofileDialog,
checkIfProfessionalCertification: this.checkIfProfessionalCertification,
showProfessionalCertificationDialog: this.showProfessionalCertificationDialog,
ShowOnlinePdf: (url) => this.ShowOnlinePdf(url),
DownloadFileA: (title, url) => this.DownloadFileA(title, url),
DownloadOpenPdf: (type, url) => this.DownloadOpenPdf(type, url),
slowDownload: this.slowDownload,
showGlobalLoading: this.showGlobalLoading,
hideGlobalLoading: this.hideGlobalLoading,
yslslowCheckresults: this.yslslowCheckresults,
yslslowCheckresultsNo: this.yslslowCheckresultsNo,
MdifHasAnchorJustScorll: this.MdifHasAnchorJustScorll,
scrollToAnchor: this.scrollToAnchor
render() {
let{Headertop,Footerdown, isRender, AccountProfiletype,AccountPhoneemailtype}=this.state;
const common = {
@ -744,11 +756,12 @@ export default function TPMIndexHOC(WrappedComponent) {
.newContainers{
min-width: 1200px;
max-width: unset;
margin: 0 auto;
height: 100%;
min-height: 100%;
overflow: hidden;
position: realtive;
}
.newHeaders{
// position: fixed;
max-width: unset;
background: #24292D !important;
width: 100%;
@ -764,6 +777,7 @@ export default function TPMIndexHOC(WrappedComponent) {
}
.indexHOC > .ant-spin-nested-loading {
background: #000;
height: 100%;
}
.indexHOC > .ant-spin-nested-loading > div > .ant-spin .ant-spin-dot {
top: 50% !important;
@ -780,10 +794,12 @@ export default function TPMIndexHOC(WrappedComponent) {
}</style>
{this.state.globalLoading ? <Loading /> :
<React.Fragment>
<NewHeader {...this.state} {...this.props}></NewHeader>
<div className="newContainers">
<Spin spinning={this.state.globalLoading} delay={0} className="globalSpin"
size="large"
tip= {this._gLoadingTip || "加载中..."}
>
<div className="newContainer newContainers">
<WrappedComponent initCommonState={(user)=>this.initCommonState(user)}
{...this.props} {...this.state}
showShixun={this.showShixun} aboutFocus={this.aboutFocus}
@ -792,16 +808,16 @@ export default function TPMIndexHOC(WrappedComponent) {
</WrappedComponent>
</div>
</Spin>
<NewFooter
{...this.state} {...this.props}
Footerdown={Footerdown}
/>
</React.Fragment>
}
</div>
);
}
}
}

Loading…
Cancel
Save