dev_forum
杨树林 5 years ago
parent 551bebf5cf
commit d0270e6b7a

@ -1,7 +1,5 @@
import React, {Component} from 'react';
import {Button} from 'antd';
import {Button,notification} from 'antd';
import {broadcastChannelPostMessage} from 'educoder';
import axios from 'axios';
import './common.css'
@ -26,12 +24,65 @@ class InterestpageComponent extends Component {
this.state = {
gouxuans: "",
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,
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) {
// console.log("46");
// console.log(nextProps);
@ -85,21 +136,21 @@ class InterestpageComponent extends Component {
}
Clickteacher2=(e)=>{
console.log(e);
let {gouxuans3} =this.state;
for (var i=0;i<gouxuans3.length;i++){
if(gouxuans3[i].id === e){
let {gouxuans4} =this.state;
for (var i=0;i<gouxuans4.length;i++){
if(gouxuans4[i].id === e){
console.log("51");
console.log(e);
if(gouxuans3[i].bool === true){
gouxuans3[i].bool=false;
if(gouxuans4[i].bool === true){
gouxuans4[i].bool=false;
}else{
gouxuans3[i].bool=true;
gouxuans4[i].bool=true;
}
}
}
console.log(gouxuans3);
console.log(gouxuans4);
this.setState({
gouxuans3:gouxuans3,
gouxuans4:gouxuans4,
})
}
@ -107,15 +158,20 @@ class InterestpageComponent extends Component {
//兴趣页面点击
Interestcompletionpage(){
if(this.state.gouxuans.length === 0){
this.props.showNotification("请选择您的职业");
this.openNotification("请选择您的职业");
return
}
var ints=[];
for (var i =0;i<this.state.gouxuans.length;i++) {
if(this.state.gouxuans[i].bool === true){
ints.push(this.state.gouxuans[i].id);
for (var i =0;i<this.state.gouxuans4.length;i++) {
if(this.state.gouxuans4[i].bool === true){
ints.push(this.state.gouxuans4[i].id);
}
}
if(ints.length<1){
this.openNotification("内容是最少得选一个");
return
}
var url = "/users/interest.json";
axios.post(url, {
identity:this.state.gouxuans,
@ -133,39 +189,39 @@ class InterestpageComponent extends Component {
})
}
//跳转然后登入
Jumptotheinterestpage=()=>{
console.log(this.state.login);
console.log(this.state.password);
var url = "/accounts/login.json";
axios.post(url, {
login: this.props.login,
password: this.props.password,
}).then((response) => {
if (response === undefined) {
return
}
if (response.status === 200) {
// if (response.data.status === 402) {
// window.location.href = response.data.url;
// } else {
// broadcastChannelPostMessage('refreshPage')
// this.setState({
// isRender: false
// })
window.location.href = "/"
// }
}
}).catch((error) => {
console.log(error);
})
}
// //跳转然后登入
// Jumptotheinterestpage=()=>{
// console.log(this.state.login);
// console.log(this.state.password);
// var url = "/accounts/login.json";
// axios.post(url, {
// login: this.props.login,
// password: this.props.password,
// }).then((response) => {
// if (response === undefined) {
// return
// }
// if (response.status === 200) {
// // if (response.data.status === 402) {
// // window.location.href = response.data.url;
// // } else {
// // broadcastChannelPostMessage('refreshPage')
// // this.setState({
// // isRender: false
// // })
// window.location.href = "/"
// // }
// }
//
//
// }).catch((error) => {
// console.log(error);
// })
// }
render() {
const {
gouxuans,
gouxuans3
gouxuans4,
} = this.state
// height: 346px;
return (
@ -193,7 +249,7 @@ class InterestpageComponent extends Component {
<div ><span className="yslspans3">基于你关注的内容推荐</span></div>
<div className="ysldivhome2">
{gouxuans3&&gouxuans3.map((item,key)=>{
{gouxuans4&&gouxuans4.map((item,key)=>{
return(
<div className={item.id<5?"ysldivhomediv1":"ysldivhomediv2"} onClick={()=>this.Clickteacher2(item.id)}>
{item.bool===true?<img src={gouxuan} className="yslgouxuanimg"/>:<div className="yslgouxuanimg2"></div>}

Loading…
Cancel
Save