From bd319f53ecfc2b1014d0285cf5dda512fa58ca9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Thu, 19 Sep 2019 16:07:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=8F=82=E6=95=B0=E5=8F=98?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paths/PathDetail/PathDetailIndex.js | 7 +- public/react/src/modules/tpm/TPMIndexHOC.js | 137 +++++++++++++++++- 2 files changed, 137 insertions(+), 7 deletions(-) diff --git a/public/react/src/modules/paths/PathDetail/PathDetailIndex.js b/public/react/src/modules/paths/PathDetail/PathDetailIndex.js index 84bdff5df..883ed6875 100644 --- a/public/react/src/modules/paths/PathDetail/PathDetailIndex.js +++ b/public/react/src/modules/paths/PathDetail/PathDetailIndex.js @@ -83,7 +83,8 @@ class PathDetailIndex extends Component{ loadtype:false, courses:undefined, items: getItems(10), - pathtopskey:1 + pathtopskey:1, + dataquerys:{}, } this.onDragEnd = this.onDragEnd.bind(this); @@ -258,7 +259,9 @@ class PathDetailIndex extends Component{ // yslwebobject 后端需要的接口 let pathid=this.props.match.params.pathId; let url="/paths/"+pathid+".json"; - axios.get(url).then((result)=>{ + axios.get(url, + {params:this.state.dataquerys} + ).then((result)=>{ if (result.data.status === 407 || result.data.status === 401) { debugger return; diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index c366b21a3..581aef930 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -81,7 +81,8 @@ export function TPMIndexHOC(WrappedComponent) { isRender: false, AccountProfiletype: false, - globalLoading: false + globalLoading: false, + dataquerys:{}, } } @@ -165,7 +166,32 @@ export function TPMIndexHOC(WrappedComponent) { $.ajaxSetup({ cache: true }); - this.fetchUser(); + + //帮助后台传参数 + const query = this.props.location.search; + // const type = query.split('?chinaoocTimestamp='); + // console.log("Eduinforms12345"); + // 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({ + dataquerys:foqus, + }); + dataqueryss=foqus; + } + }catch (e) { + this.setState({ + dataquerys:{}, + }) + } + this.fetchUsers(dataqueryss); let url=`/users/get_navigation_info.json`; axios.get(url, { @@ -260,9 +286,23 @@ export function TPMIndexHOC(WrappedComponent) { courseId = parseInt(type[2]) // url += `?course_id=${courseId}` } + var datay={}; + if(JSON.stringify(this.state.dataquerys) ==="{}"){ + 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, + } + } axios.get(url,{params:{ - course_id:isNaN(courseId)?undefined:courseId, - school:1 + datay } }, { @@ -301,7 +341,94 @@ export function TPMIndexHOC(WrappedComponent) { }).catch((error) => { 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 = {}; + var regExp = /[\?\&](\w+)(=?)(\w*)/g; + 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; + + json[key] = value; + } + } while (arr); + + return json; + }; hideLoginDialog = () => { this.setState({ isRender: false