|
|
|
|
@ -5,13 +5,19 @@ export default class Box4 extends Component {
|
|
|
|
|
super();
|
|
|
|
|
this.state = {
|
|
|
|
|
map: [],
|
|
|
|
|
current: 1,
|
|
|
|
|
button: "new",
|
|
|
|
|
color: 0,
|
|
|
|
|
};
|
|
|
|
|
fetch(
|
|
|
|
|
"https://test-data.educoder.net/api/paths.json?sort=desc&order=new&page=1&limit=16&keyword=&discipline_id=&sub_discipline_id="
|
|
|
|
|
"https://test-data.educoder.net/api/paths.json?sort=desc&order=" +
|
|
|
|
|
this.state.button +
|
|
|
|
|
"&page=" +
|
|
|
|
|
1 +
|
|
|
|
|
"&limit=16&keyword=&discipline_id=&sub_discipline_id="
|
|
|
|
|
)
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data.subjects);
|
|
|
|
|
this.setState({
|
|
|
|
|
map: data.subjects,
|
|
|
|
|
});
|
|
|
|
|
@ -19,24 +25,141 @@ export default class Box4 extends Component {
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="kc_main_box4">
|
|
|
|
|
{this.state.map.map((item, index) => (
|
|
|
|
|
<div>
|
|
|
|
|
{console.log()}
|
|
|
|
|
<div className="kc_main_box3">
|
|
|
|
|
<div
|
|
|
|
|
key={item.id}
|
|
|
|
|
className="kc_main_box4_box"
|
|
|
|
|
style={{ marginRight: index % 4 == 3 ? "0" : "" }}
|
|
|
|
|
className={
|
|
|
|
|
this.state.color === 0 ? "kc_main_box3_box1" : "kc_main_box3_box2"
|
|
|
|
|
}
|
|
|
|
|
onClick={this.handleClick_zuixin}
|
|
|
|
|
>
|
|
|
|
|
<div className="kc_main_box4_box_shang">
|
|
|
|
|
<img
|
|
|
|
|
src={"https://testali-cdn.educoder.net/" + item.image_url}
|
|
|
|
|
></img>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="kc_main_box4_box_xia">
|
|
|
|
|
<div className="kc_main_box4_box_xia_box1">{item.name}</div>
|
|
|
|
|
</div>
|
|
|
|
|
最新
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
className={
|
|
|
|
|
this.state.color === 1 ? "kc_main_box3_box1" : "kc_main_box3_box2"
|
|
|
|
|
}
|
|
|
|
|
onClick={this.handleClick_zuire}
|
|
|
|
|
>
|
|
|
|
|
最热
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="kc_main_box4">
|
|
|
|
|
{this.state.map.map((item, index) => (
|
|
|
|
|
<div
|
|
|
|
|
key={item.id}
|
|
|
|
|
className="kc_main_box4_box"
|
|
|
|
|
style={{ marginRight: index % 4 == 3 ? "0" : "" }}
|
|
|
|
|
>
|
|
|
|
|
<div className="kc_main_box4_box_shang">
|
|
|
|
|
<img
|
|
|
|
|
src={"https://testali-cdn.educoder.net/" + item.image_url}
|
|
|
|
|
></img>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="kc_main_box4_box_xia">
|
|
|
|
|
<div className="kc_main_box4_box_xia_box1">{item.name}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="kc_main_box5">
|
|
|
|
|
<button onClick={() => this.handleClick_shang(this.state.current)}>
|
|
|
|
|
上一页
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
style={{ marginLeft: "8px" }}
|
|
|
|
|
onClick={() => this.handleClick_xia(this.state.current)}
|
|
|
|
|
>
|
|
|
|
|
下一页
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
handleClick_zuixin = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
color: 0,
|
|
|
|
|
button: "new",
|
|
|
|
|
map: [],
|
|
|
|
|
});
|
|
|
|
|
var v = this.state.current;
|
|
|
|
|
var b = "new";
|
|
|
|
|
fetch(
|
|
|
|
|
"https://test-data.educoder.net/api/paths.json?sort=desc&order=" +
|
|
|
|
|
b +
|
|
|
|
|
"&page=" +
|
|
|
|
|
v +
|
|
|
|
|
"&limit=16&keyword=&discipline_id=&sub_discipline_id="
|
|
|
|
|
)
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
.then((data) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
map: data.subjects,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
handleClick_zuire = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
color: 1,
|
|
|
|
|
button: "",
|
|
|
|
|
map: [],
|
|
|
|
|
});
|
|
|
|
|
var v = this.state.current;
|
|
|
|
|
var b = "";
|
|
|
|
|
fetch(
|
|
|
|
|
"https://test-data.educoder.net/api/paths.json?sort=desc&order=" +
|
|
|
|
|
b +
|
|
|
|
|
"&page=" +
|
|
|
|
|
v +
|
|
|
|
|
"&limit=16&keyword=&discipline_id=&sub_discipline_id="
|
|
|
|
|
)
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
.then((data) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
map: data.subjects,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
handleClick_xia(v) {
|
|
|
|
|
this.setState({
|
|
|
|
|
current: this.state.current + 1,
|
|
|
|
|
map: [],
|
|
|
|
|
});
|
|
|
|
|
var b = this.state.button;
|
|
|
|
|
fetch(
|
|
|
|
|
"https://test-data.educoder.net/api/paths.json?sort=desc&order=" +
|
|
|
|
|
b +
|
|
|
|
|
"&page=" +
|
|
|
|
|
(v + 1) +
|
|
|
|
|
"&limit=16&keyword=&discipline_id=&sub_discipline_id="
|
|
|
|
|
)
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
.then((data) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
map: data.subjects,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
handleClick_shang(v) {
|
|
|
|
|
this.setState({
|
|
|
|
|
current: this.state.current - 1,
|
|
|
|
|
map: [],
|
|
|
|
|
});
|
|
|
|
|
var b = this.state.button;
|
|
|
|
|
fetch(
|
|
|
|
|
"https://test-data.educoder.net/api/paths.json?sort=desc&order=" +
|
|
|
|
|
b +
|
|
|
|
|
"&page=" +
|
|
|
|
|
(v - 1) +
|
|
|
|
|
"&limit=16&keyword=&discipline_id=&sub_discipline_id="
|
|
|
|
|
)
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
.then((data) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
map: data.subjects,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|