dev_cs
杨树林 5 years ago
parent f251e1bc74
commit fb0fd87f08

@ -315,9 +315,33 @@ class CoursesIndex extends Component{
if(isNaN(id)){ if(isNaN(id)){
return return
} }
const querys = this.props.location.search;
var dataqueryss={}
try {
var foqus=this.foo(querys);
if(JSON.stringify(foqus) ==="{}"){
this.setState({
dataquerys:{},
});
}else{
this.setState({
dataquerys:foqus,
});
dataqueryss=foqus;
}
}catch (e) {
this.setState({
dataquerys:{},
})
}
// let id=this.props.match.params.coursesId; // let id=this.props.match.params.coursesId;
let url ="/courses/"+id+"/left_banner.json" let url ="/courses/"+id+"/left_banner.json"
axios.get(url).then((response) => { axios.get(url,
{params:
dataqueryss
}
).then((response) => {
if(response!=undefined){ if(response!=undefined){
if(response.data&&response.data){ if(response.data&&response.data){
this.setState({ this.setState({
@ -330,7 +354,28 @@ class CoursesIndex extends Component{
} }
} }
}) })
} };
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;
};
locationNav=(list)=>{ locationNav=(list)=>{
if(list){ if(list){

@ -94,9 +94,30 @@ class CoursesBanner extends Component {
this.updatabanner() this.updatabanner()
} }
updatabanner=()=>{ updatabanner=()=>{
const query = this.props.location.search;
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:{},
})
}
let courseId = this.props.match.params.coursesId; let courseId = this.props.match.params.coursesId;
let url = "/courses/" + courseId + "/top_banner.json" let url = "/courses/" + courseId + "/top_banner.json"
axios.get(url).then((result) => { axios.get(url,{params:
dataqueryss
}).then((result) => {
if( result!=undefined){ if( result!=undefined){
let data = result.data; let data = result.data;
this.setState({ this.setState({
@ -107,7 +128,28 @@ class CoursesBanner extends Component {
this.onloadupdatabanner() this.onloadupdatabanner()
} }
}) })
} };
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;
};
showeditmenu = () => { showeditmenu = () => {
this.setState({ this.setState({
show: true, show: true,

Loading…
Cancel
Save