Merge remote-tracking branch 'origin/master'

dev_forum
杨树明 5 years ago
commit 047c03f694

@ -1,7 +1,5 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import {Button,notification} from 'antd';
import {Button} from 'antd';
import {broadcastChannelPostMessage} from 'educoder'; import {broadcastChannelPostMessage} from 'educoder';
import axios from 'axios'; import axios from 'axios';
import './common.css' import './common.css'
@ -26,12 +24,65 @@ class InterestpageComponent extends Component {
this.state = { this.state = {
gouxuans: "", gouxuans: "",
gouxuans2:0, gouxuans2:0,
gouxuans3:[{id:1,name:"前端开发",bool:false,url:qdkf},{id:2,name:"后端开发",bool:false,url:hdkf},{id:3,name:"移动开发",bool:false,url:ydkf},{id:4,name:"数据库",bool:false,url:sjk},{id:5,name:"云计算和大数据",bool:false,url:ysj},{id:6,name:"运维与测试",bool:false,url:yunwei},{id:7,name:"人工智能",bool:false,url:rgzn},{id:8,name:"其他",bool:false,url:qita}], gouxuans4:[],
namezh:this.props.namezh, namezh:this.props.namezh,
passmm:this.props.passmm, passmm:this.props.passmm,
homedatalist:undefined,
hometypepvisible: undefined,
}
}
openNotification = (messge) => {
// type 1 成功提示绿色 2提醒颜色黄色 3错误提示红色
notification.open({
message: "提示",
description: messge,
onClick: () => {
console.log('Notification Clicked!');
},
});
}
componentDidMount(){
let{gouxuans4} =this.state;
let url=`/repertoires.json`;
axios.get(url).then((response)=> {
if(response){
console.log("53");
console.log(response.data);
for(var i=0;i<response.data.repertoires.length;i++){
var qdkfys="";
if(response.data.repertoires[i].id===1){
qdkfys=qdkf;
}if(response.data.repertoires[i].id===2){
qdkfys=hdkf;
}if(response.data.repertoires[i].id===3){
qdkfys=ydkf;
}if(response.data.repertoires[i].id===4){
qdkfys=sjk;
}if(response.data.repertoires[i].id===5){
qdkfys=ysj;
}if(response.data.repertoires[i].id===6){
qdkfys=yunwei;
}if(response.data.repertoires[i].id===8){
qdkfys=qita;
}if(response.data.repertoires[i].id===9){
qdkfys=rgzn;
}
var datas={id:response.data.repertoires[i].id,name:response.data.repertoires[i].name,bool:false,url:qdkfys};
gouxuans4.push(datas);
this.setState({
gouxuans4:gouxuans4,
})
} }
console.log("75");
console.log(gouxuans4);
} }
}).catch((error)=>{
console.log(error)
});
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// console.log("46"); // console.log("46");
// console.log(nextProps); // console.log(nextProps);
@ -85,21 +136,21 @@ class InterestpageComponent extends Component {
} }
Clickteacher2=(e)=>{ Clickteacher2=(e)=>{
console.log(e); console.log(e);
let {gouxuans3} =this.state; let {gouxuans4} =this.state;
for (var i=0;i<gouxuans3.length;i++){ for (var i=0;i<gouxuans4.length;i++){
if(gouxuans3[i].id === e){ if(gouxuans4[i].id === e){
console.log("51"); console.log("51");
console.log(e); console.log(e);
if(gouxuans3[i].bool === true){ if(gouxuans4[i].bool === true){
gouxuans3[i].bool=false; gouxuans4[i].bool=false;
}else{ }else{
gouxuans3[i].bool=true; gouxuans4[i].bool=true;
} }
} }
} }
console.log(gouxuans3); console.log(gouxuans4);
this.setState({ this.setState({
gouxuans3:gouxuans3, gouxuans4:gouxuans4,
}) })
} }
@ -107,14 +158,19 @@ class InterestpageComponent extends Component {
//兴趣页面点击 //兴趣页面点击
Interestcompletionpage(){ Interestcompletionpage(){
if(this.state.gouxuans.length === 0){ if(this.state.gouxuans.length === 0){
this.props.showNotification("请选择您的职业"); this.openNotification("请选择您的职业");
return return
} }
var ints=[]; var ints=[];
for (var i =0;i<this.state.gouxuans.length;i++) { for (var i =0;i<this.state.gouxuans4.length;i++) {
if(this.state.gouxuans[i].bool === true){ if(this.state.gouxuans4[i].bool === true){
ints.push(this.state.gouxuans[i].id); ints.push(this.state.gouxuans4[i].id);
}
} }
if(ints.length<1){
this.openNotification("内容是最少得选一个");
return
} }
var url = "/users/interest.json"; var url = "/users/interest.json";
axios.post(url, { axios.post(url, {
@ -133,39 +189,39 @@ class InterestpageComponent extends Component {
}) })
} }
//跳转然后登入 // //跳转然后登入
Jumptotheinterestpage=()=>{ // Jumptotheinterestpage=()=>{
console.log(this.state.login); // console.log(this.state.login);
console.log(this.state.password); // console.log(this.state.password);
var url = "/accounts/login.json"; // var url = "/accounts/login.json";
axios.post(url, { // axios.post(url, {
login: this.props.login, // login: this.props.login,
password: this.props.password, // password: this.props.password,
}).then((response) => { // }).then((response) => {
if (response === undefined) { // if (response === undefined) {
return // return
} // }
if (response.status === 200) { // if (response.status === 200) {
// if (response.data.status === 402) { // // if (response.data.status === 402) {
// window.location.href = response.data.url; // // window.location.href = response.data.url;
// } else { // // } else {
// broadcastChannelPostMessage('refreshPage') // // broadcastChannelPostMessage('refreshPage')
// this.setState({ // // this.setState({
// isRender: false // // isRender: false
// // })
// window.location.href = "/"
// // }
// }
//
//
// }).catch((error) => {
// console.log(error);
// }) // })
window.location.href = "/"
// } // }
}
}).catch((error) => {
console.log(error);
})
}
render() { render() {
const { const {
gouxuans, gouxuans,
gouxuans3 gouxuans4,
} = this.state } = this.state
// height: 346px; // height: 346px;
return ( return (
@ -193,7 +249,7 @@ class InterestpageComponent extends Component {
<div ><span className="yslspans3">基于你关注的内容推荐</span></div> <div ><span className="yslspans3">基于你关注的内容推荐</span></div>
<div className="ysldivhome2"> <div className="ysldivhome2">
{gouxuans3&&gouxuans3.map((item,key)=>{ {gouxuans4&&gouxuans4.map((item,key)=>{
return( return(
<div className={item.id<5?"ysldivhomediv1":"ysldivhomediv2"} onClick={()=>this.Clickteacher2(item.id)}> <div className={item.id<5?"ysldivhomediv1":"ysldivhomediv2"} onClick={()=>this.Clickteacher2(item.id)}>
{item.bool===true?<img src={gouxuan} className="yslgouxuanimg"/>:<div className="yslgouxuanimg2"></div>} {item.bool===true?<img src={gouxuan} className="yslgouxuanimg"/>:<div className="yslgouxuanimg2"></div>}

Loading…
Cancel
Save