fix accountbasic bug

dev_aliyun2
harry 5 years ago
parent be519f87e1
commit a691b82a7e

@ -1,7 +1,5 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Spin } from 'antd';
class Loading extends Component { class Loading extends Component {
render() { render() {
return ( return (
@ -15,7 +13,7 @@ class Loading extends Component {
` `
} }
</style> </style>
<Spin size="large" className={"margintop"} /> <p>loading...</p>
</div> </div>
); );
} }

@ -486,7 +486,7 @@ class LoginDialog extends Component {
} }
return ( return (
<Modal visible={true} id="DialogID" <Modal visible={isRender} id="DialogID"
className="zindextest" className="zindextest"
onClose={() => this.handleDialogClose()} onClose={() => this.handleDialogClose()}
> >
@ -516,7 +516,6 @@ class LoginDialog extends Component {
<div id="log_reg_content" > <div id="log_reg_content" >
{weixinlogin === true ? "" : <ul className="log_nav clearfix"> {weixinlogin === true ? "" : <ul className="log_nav clearfix">
<li className={login == 0 ? 'active' : ''} onClick={() => { this.enter(0) }}>登录</li> <li className={login == 0 ? 'active' : ''} onClick={() => { this.enter(0) }}>登录</li>
{/*<li className={speedy==0?'active':''} onClick={()=>{this.register(0)}}>快捷登录</li>*/}
</ul>} </ul>}

@ -1,37 +1,37 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import { Spin } from 'antd'; import { Spin } from 'antd';
import axios from 'axios'; import axios from 'axios';
class Otherloginqq extends Component { class Otherloginqq extends Component {
componentDidMount() { componentDidMount() {
let query=this.props.location.search; let query = this.props.location.search;
if(query!= ""){ if (query != "") {
const type = query.split('?code='); const type = query.split('?code=');
const types = type[1].split('&state='); const types = type[1].split('&state=');
const typeshref = types[1].split('%2C'); const typeshref = types[1].split('%2C');
let codeurl = `/auth/qq/callback`; let codeurl = `/auth/qq/callback`;
axios.get(codeurl,{params:{ axios.get(codeurl, {
code:types[0], params: {
redirect_uri:`https://www.educoder.net/otherloginqq` code: types[0],
}}).then((result)=> { redirect_uri: `https://www.educoder.net/otherloginqq`
if(result){ }
if(result.data.status===0){ }).then((result) => {
if(result.data.new_user===true){ if (result) {
window.location.href=`https://${decodeURIComponent(typeshref[1])}/loginqq?type=qq`; if (result.data.status === 0) {
}else{ if (result.data.new_user === true) {
window.location.href = `https://${decodeURIComponent(typeshref[1])}/loginqq?type=qq`;
} else {
// this.getinfo() // this.getinfo()
if(typeshref[0]==="account"){ if (typeshref[0] === "account") {
window.location.href=`https://${decodeURIComponent(typeshref[1])}/account/binding`; window.location.href = `https://${decodeURIComponent(typeshref[1])}/account/binding`;
}else{ } else {
window.location.href=`https://${decodeURIComponent(typeshref[1])}`; window.location.href = `https://${decodeURIComponent(typeshref[1])}`;
} }
} }
} }
} }
}).catch((error)=>{ }).catch((error) => {
}) })
} }
@ -40,7 +40,7 @@ class Otherloginqq extends Component {
render() { render() {
// Loading // Loading
return ( return (
<div className="App" style={{minHeight: '800px',width:"100%"}}> <div className="App" style={{ minHeight: '800px', width: "100%" }}>
<style> <style>
{ {
` `
@ -50,7 +50,7 @@ class Otherloginqq extends Component {
` `
} }
</style> </style>
<Spin size="large" className={"margintop"}/> <Spin size="large" className={"margintop"} />
</div> </div>
); );
} }

@ -1,44 +1,44 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import { Spin } from 'antd'; import { Spin } from 'antd';
import axios from 'axios'; import axios from 'axios';
class Otherloginstart extends Component { class Otherloginstart extends Component {
componentDidMount() { componentDidMount() {
let query=this.props.location.search; let query = this.props.location.search;
if(query!= ""){ if (query != "") {
const type = query.split('?code='); const type = query.split('?code=');
const types = type[1].split('&state='); const types = type[1].split('&state=');
const typeshref = types[1].split(','); const typeshref = types[1].split(',');
if(typeshref[1]==="test-newweb.educoder.net"){ if (typeshref[1] === "test-newweb.educoder.net") {
window.location.href=`https://${typeshref[1]}/otherloginstart?code=${types[0]}&state=null,""`; window.location.href = `https://${typeshref[1]}/otherloginstart?code=${types[0]}&state=null,""`;
}else if(typeshref[1]==="pre-newweb.educoder.net"){ } else if (typeshref[1] === "pre-newweb.educoder.net") {
window.location.href=`https://${typeshref[1]}/otherloginstart?code=${types[0]}&state=null,""`; window.location.href = `https://${typeshref[1]}/otherloginstart?code=${types[0]}&state=null,""`;
} }
let codeurl = `/auth/wechat/callback.json` let codeurl = `/auth/wechat/callback.json`
axios.get(codeurl,{params:{ axios.get(codeurl, {
code:types[0] params: {
}}).then((result)=> { code: types[0]
if(result){ }
if(result.data.status===0){ }).then((result) => {
if(result.data.new_user===true){ if (result) {
if (result.data.status === 0) {
if (result.data.new_user === true) {
this.props.history.replace(`/otherlogin?type=wechat`); this.props.history.replace(`/otherlogin?type=wechat`);
}else{ } else {
// this.getinfo() // this.getinfo()
if(typeshref[0]==="account"){ if (typeshref[0] === "account") {
this.props.history.replace(`/account/binding`); this.props.history.replace(`/account/binding`);
}else{ } else {
this.props.history.replace(`/`); this.props.history.replace(`/`);
} }
} }
} }
} }
}).catch((error)=>{ }).catch((error) => {
}) })
} }
@ -49,7 +49,7 @@ class Otherloginstart extends Component {
render() { render() {
// Loading // Loading
return ( return (
<div className="App" style={{minHeight: '800px',width:"100%"}}> <div className="App" style={{ minHeight: '800px', width: "100%" }}>
<style> <style>
{ {
` `
@ -59,7 +59,7 @@ class Otherloginstart extends Component {
` `
} }
</style> </style>
<Spin size="large" className={"margintop"}/> <Spin size="large" className={"margintop"} />
</div> </div>
); );
} }

@ -10,12 +10,10 @@ import TPMIndexHOC from '../tpm/TPMIndexHOC';
import { SnackbarHOC } from 'educoder'; import { SnackbarHOC } from 'educoder';
import AccountNav from './account/AccountNav' import AccountNav from './account/AccountNav'
import AccountBasic from './account/AccountBasic'
import axios from 'axios' import axios from 'axios'
console.log(AccountBasic, '00000000')
const AccountBasic = Loadable({
loader: () => import('./account/AccountBasic'),
loading: Loading,
})
const AccountBasicEdit = Loadable({ const AccountBasicEdit = Loadable({
loader: () => import('./account/AccountBasicEdit'), loader: () => import('./account/AccountBasicEdit'),
loading: Loading, loading: Loading,
@ -62,7 +60,6 @@ class AccountPage extends Component {
if (result.data && result.data.base_info_completed == false) { if (result.data && result.data.base_info_completed == false) {
this.props.history.push(`/account/profile/edit`); this.props.history.push(`/account/profile/edit`);
} }
// "authentication": "uncertified", // "uncertified" | "applying" | "certified"
this.setState({ this.setState({
basicInfo: Object.assign({}, { ...result.data }, { basicInfo: Object.assign({}, { ...result.data }, {
avatar_url: `${result.data.avatar_url}`, avatar_url: `${result.data.avatar_url}`,

@ -1,27 +1,17 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { SnackbarHOC, getImageUrl, City } from 'educoder'; import { Form, Button } from 'antd'
import { Form, Button, Input, Radio, Select, Tooltip, Icon } from 'antd'
import './common.css' import './common.css'
import { getHiddenName } from './AccountBasicEdit' import { getHiddenName } from './AccountBasicEdit'
const identityMap = { "teacher": "教师", "student": "学生", "professional": "专业人士" }
const RadioGroup = Radio.Group;
const Option = Select.Option
const radioOptions = [
{ label: '男', value: 'boy' },
{ label: '女', value: 'girl' },
];
export const identityMap={"teacher":"教师", "student":"学生", "professional":"专业人士"}
class AccountBasicEdit extends Component { class AccountBasicEdit extends Component {
constructor(props){ constructor(props) {
super(props); super(props);
} }
render() { render() {
const { getFieldDecorator } = this.props.form; const { basicInfo } = this.props
const {basicInfo} =this.props
const showRealName = false;
return ( return (
<div> <div>
<div className="basicForm"> <div className="basicForm">
@ -54,7 +44,7 @@ class AccountBasicEdit extends Component {
`}</style> `}</style>
<div className="titleWrap"> <div className="titleWrap">
<div className="title">基本信息</div> <div className="title">基本信息</div>
<Button type="primary" style={{ marginRight: '16px'}} <Button type="primary" style={{ marginRight: '16px' }}
ghost onClick={() => this.props.history.push('/account/profile/edit')}>修改</Button> ghost onClick={() => this.props.history.push('/account/profile/edit')}>修改</Button>
</div> </div>
@ -77,7 +67,7 @@ class AccountBasicEdit extends Component {
label="性别" label="性别"
className="display formItemInline" className="display formItemInline"
> >
{basicInfo && basicInfo.gender == 0?"男":"女"} {basicInfo && basicInfo.gender == 0 ? "男" : "女"}
</Form.Item> </Form.Item>
@ -92,7 +82,7 @@ class AccountBasicEdit extends Component {
label="职业" label="职业"
className="display formItemInline" className="display formItemInline"
> >
{ basicInfo && basicInfo.identity && identityMap[basicInfo.identity] } {basicInfo && ( basicInfo.technical_title || basicInfo.student_id)} {basicInfo && basicInfo.identity && identityMap[basicInfo.identity]} {basicInfo && (basicInfo.technical_title || basicInfo.student_id)}
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@ -110,7 +100,7 @@ class AccountBasicEdit extends Component {
</Form.Item> </Form.Item>
</Form> </Form>
</div> </div>
<div style={{color: '#989898', marginLeft: '20px'}}>* 我们确保你所提供的信息均处于严格保密状态不会泄露</div> <div style={{ color: '#989898', marginLeft: '20px' }}>* 我们确保你所提供的信息均处于严格保密状态不会泄露</div>
</div> </div>
); );
} }

@ -1,103 +1,100 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { SnackbarHOC, getImageUrl, City, ConditionToolTip } from 'educoder'; import { City, ConditionToolTip } from 'educoder';
import { Form, Button, Input, Radio, Select, Tooltip, Icon, AutoComplete } from 'antd' import { Form, Button, Input, Radio, Tooltip } from 'antd'
import ApplyForAddOrgModal from '../modal/ApplyForAddOrgModal' import ApplyForAddOrgModal from '../modal/ApplyForAddOrgModal'
import ApplyForAddChildOrgModal from '../modal/ApplyForAddChildOrgModal' import ApplyForAddChildOrgModal from '../modal/ApplyForAddChildOrgModal'
import AccountBasicEditItem from './AccountBasicEditItem'; import AccountBasicEditItem from './AccountBasicEditItem';
import axios from 'axios' import axios from 'axios'
import { identityMap } from './AccountBasic'
const RadioGroup = Radio.Group; const RadioGroup = Radio.Group;
const Option = Select.Option;
const map = identityMap // {"teacher":"教师", "student":"学生", "professional":"专业人士"}
export function getHiddenName(name) { export function getHiddenName(name) {
if (!name) return '' if (!name) return ''
let len=parseInt(name.length)-1; let len = parseInt(name.length) - 1;
let str=""; let str = "";
for(var i = 0; i < len; i++){ str += "*"; } for (var i = 0; i < len; i++) { str += "*"; }
const newName = name.substr(0,1)+str; const newName = name.substr(0, 1) + str;
return newName return newName
} }
const MAX_NAME_LENGTH = 10 const MAX_NAME_LENGTH = 10
const MAX_NICKNAME_LENGTH = 20 const MAX_NICKNAME_LENGTH = 20
class AccountBasic extends Component { class AccountBasic extends Component {
constructor(props){ constructor(props) {
super(props); super(props);
this.state={ this.state = {
nameLength:0, nameLength: 0,
showRealName:true, showRealName: true,
schoolList:undefined, schoolList: undefined,
filterSchoolList:undefined, filterSchoolList: undefined,
school:undefined, school: undefined,
departments:undefined, departments: undefined,
filterDepartments:undefined, filterDepartments: undefined,
departmentsName:undefined, departmentsName: undefined,
identity:"teacher", identity: "teacher",
school_id:undefined, school_id: undefined,
department_id:undefined department_id: undefined
} }
} }
componentDidUpdate =(prevProps)=>{ componentDidUpdate = (prevProps) => {
if(this.props.basicInfo && (prevProps.basicInfo == undefined || prevProps.basicInfo.id != this.props.basicInfo.id)){ if (this.props.basicInfo && (prevProps.basicInfo == undefined || prevProps.basicInfo.id != this.props.basicInfo.id)) {
this.setValue(this.props.basicInfo); this.setValue(this.props.basicInfo);
this.getSchoolList(this.props.basicInfo); this.getSchoolList(this.props.basicInfo);
} }
} }
componentDidMount = () =>{ componentDidMount = () => {
if(this.props.basicInfo){ if (this.props.basicInfo) {
this.setValue(this.props.basicInfo); this.setValue(this.props.basicInfo);
this.getSchoolList(this.props.basicInfo); this.getSchoolList(this.props.basicInfo);
} }
} }
setValue=(basicInfo)=>{ setValue = (basicInfo) => {
if(basicInfo){ if (basicInfo) {
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
nickname:basicInfo.nickname, nickname: basicInfo.nickname,
name:!basicInfo.show_realname ? this.hideRealName(basicInfo.name) : basicInfo.name, name: !basicInfo.show_realname ? this.hideRealName(basicInfo.name) : basicInfo.name,
sex:String(basicInfo.gender), sex: String(basicInfo.gender),
job:basicInfo.identity, job: basicInfo.identity,
org:basicInfo.school_name, org: basicInfo.school_name,
org2:basicInfo.department_name, org2: basicInfo.department_name,
city:[basicInfo.location,basicInfo.location_city] city: [basicInfo.location, basicInfo.location_city]
}) })
setTimeout(() => { setTimeout(() => {
// 等显示后再set // 等显示后再set
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
student_No:basicInfo.student_id, student_No: basicInfo.student_id,
job1:basicInfo && basicInfo.identity=="teacher" ? basicInfo.technical_title:"教授", job1: basicInfo && basicInfo.identity == "teacher" ? basicInfo.technical_title : "教授",
job2:basicInfo && basicInfo.identity=="professional" ? basicInfo.technical_title:"企业管理者", job2: basicInfo && basicInfo.identity == "professional" ? basicInfo.technical_title : "企业管理者",
}) })
}, 100) }, 100)
//if(basicInfo.nickname){ //if(basicInfo.nickname){
this.setState({ this.setState({
forDisable: true, forDisable: true,
nameLength:basicInfo.nickname?basicInfo.nickname.length:0, nameLength: basicInfo.nickname ? basicInfo.nickname.length : 0,
showRealName:basicInfo.show_realname, showRealName: basicInfo.show_realname,
realName: basicInfo.name, realName: basicInfo.name,
identity:basicInfo.identity, identity: basicInfo.identity,
school_id:basicInfo.school_id, school_id: basicInfo.school_id,
department_id:basicInfo.department_id department_id: basicInfo.department_id
}) })
//} //}
} }
} }
// 获取学校、单位 // 获取学校、单位
getSchoolList=(basicInfo, selectedName)=>{ getSchoolList = (basicInfo, selectedName) => {
let url=`/schools/for_option.json`; let url = `/schools/for_option.json`;
axios.get(url).then((result)=>{ axios.get(url).then((result) => {
if(result){ if (result) {
this.setState({ this.setState({
schoolList:result.data.schools schoolList: result.data.schools
}) })
if (selectedName) { if (selectedName) {
let school_id let school_id
result.data.schools.reverse().some( item => { result.data.schools.reverse().some(item => {
if (item.name == selectedName) { if (item.name == selectedName) {
school_id = item.id school_id = item.id
return true; return true;
@ -112,34 +109,34 @@ class AccountBasic extends Component {
}, () => { }, () => {
this.filterList(selectedName) this.filterList(selectedName)
}) })
} else if(basicInfo && basicInfo.school_name){ } else if (basicInfo && basicInfo.school_name) {
this.setState({ this.setState({
school:basicInfo.school_name, school: basicInfo.school_name,
filterSchoolList:this.state.schoolList.filter(function(item){ filterSchoolList: this.state.schoolList.filter(function (item) {
return item.name.indexOf(basicInfo.school_name)>-1; return item.name.indexOf(basicInfo.school_name) > -1;
}) })
}) })
this.getDepartments(basicInfo.school_name,false); this.getDepartments(basicInfo.school_name, false);
} }
} }
}).catch((error)=>{ }).catch((error) => {
console.log(error); console.log(error);
}) })
} }
// 输入昵称时change剩余的字数 // 输入昵称时change剩余的字数
changeNickName=(e)=>{ changeNickName = (e) => {
let num= MAX_NICKNAME_LENGTH - parseInt(e.target.value.length); let num = MAX_NICKNAME_LENGTH - parseInt(e.target.value.length);
this.setState({ this.setState({
nameLength:num < 0 ? 0 : num nameLength: num < 0 ? 0 : num
}) })
} }
handleSubmit = () => { handleSubmit = () => {
this.props.form.validateFieldsAndScroll({ force: true }, (err, values) => { this.props.form.validateFieldsAndScroll({ force: true }, (err, values) => {
console.log(values); console.log(values);
let {basicInfo}=this.props; let { basicInfo } = this.props;
if(!err ){ if (!err) {
if (!this.state.school_id) { if (!this.state.school_id) {
this.props.showNotification('请先选择学校/单位') this.props.showNotification('请先选择学校/单位')
return; return;
@ -149,23 +146,23 @@ class AccountBasic extends Component {
return; return;
} }
let url=`/users/accounts/${basicInfo.id}.json` let url = `/users/accounts/${basicInfo.id}.json`
axios.put((url),{ axios.put((url), {
nickname:values.nickname, nickname: values.nickname,
// 认证中的不能修改 // 认证中的不能修改
name: basicInfo.authentication == 'uncertified' ? name: basicInfo.authentication == 'uncertified' ?
(this.state.showRealName ? values.name : this.state.realName ) : basicInfo.name, (this.state.showRealName ? values.name : this.state.realName) : basicInfo.name,
show_realname:this.state.showRealName, show_realname: this.state.showRealName,
gender:parseInt(values.sex), gender: parseInt(values.sex),
location:values.city[0], location: values.city[0],
location_city:values.city[1], location_city: values.city[1],
identity: this.state.identity || (values.job=="teacher"?"teacher":values.job=="student"?"student":"professional"), identity: this.state.identity || (values.job == "teacher" ? "teacher" : values.job == "student" ? "student" : "professional"),
technical_title:values.job1 || values.job2, technical_title: values.job1 || values.job2,
student_id:values.job=="student" ? values.student_No : null, student_id: values.job == "student" ? values.student_No : null,
school_id:this.state.school_id, school_id: this.state.school_id,
department_id:this.state.department_id department_id: this.state.department_id
}).then((result)=>{ }).then((result) => {
if(result){ if (result) {
this.props.showNotification('保存成功') this.props.showNotification('保存成功')
// 如果是第一次完善资料,重新拉头部接口更新 // 如果是第一次完善资料,重新拉头部接口更新
if (!this.props.basicInfo.base_info_completed) { if (!this.props.basicInfo.base_info_completed) {
@ -175,7 +172,7 @@ class AccountBasic extends Component {
this.props.history.push('/account/profile') this.props.history.push('/account/profile')
} }
}).catch((error)=>{ }).catch((error) => {
console.log(error); console.log(error);
}) })
} }
@ -183,14 +180,14 @@ class AccountBasic extends Component {
} }
// 隐藏或显示真实姓名 // 隐藏或显示真实姓名
showOrHide=(flag)=>{ showOrHide = (flag) => {
const name = this.props.form.getFieldsValue().name || this.props.basicInfo.name const name = this.props.form.getFieldsValue().name || this.props.basicInfo.name
this.setState({ this.setState({
showRealName:flag==true?false:true showRealName: flag == true ? false : true
}) })
if(flag==true){ // 隐藏真实姓名 if (flag == true) { // 隐藏真实姓名
this.hideRealName(name); this.hideRealName(name);
}else{ // 显示 } else { // 显示
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
name: this.state.realName name: this.state.realName
}) })
@ -198,7 +195,7 @@ class AccountBasic extends Component {
} }
// 将名字隐藏起来 // 将名字隐藏起来
hideRealName=(name)=>{ hideRealName = (name) => {
this.setState({ realName: name }) this.setState({ realName: name })
const newName = getHiddenName(name) const newName = getHiddenName(name)
@ -209,12 +206,12 @@ class AccountBasic extends Component {
} }
// 过滤学校 // 过滤学校
filterList =(e)=>{ filterList = (e) => {
const inputVal = e.trim() const inputVal = e.trim()
let arr=[]; let arr = [];
if(inputVal){ if (inputVal) {
arr= this.state.schoolList.filter(function(item){ arr = this.state.schoolList.filter(function (item) {
return item.name.indexOf(inputVal)>-1; return item.name.indexOf(inputVal) > -1;
}); });
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
org: inputVal org: inputVal
@ -236,17 +233,17 @@ class AccountBasic extends Component {
// } // }
} }
//搜索部门 //搜索部门
searchDepartment=(e)=>{ searchDepartment = (e) => {
if (e) { if (e) {
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
org2:e org2: e
}) })
let arr = this.state.departments && this.state.departments.filter ? this.state.departments.filter(function(item){ let arr = this.state.departments && this.state.departments.filter ? this.state.departments.filter(function (item) {
return item.name.indexOf(e) > -1 return item.name.indexOf(e) > -1
}) : [] }) : []
this.setState({ this.setState({
filterDepartments:arr, filterDepartments: arr,
departmentsName:e departmentsName: e
}) })
} else { } else {
this.setState({ this.setState({
@ -256,8 +253,8 @@ class AccountBasic extends Component {
} }
// 选择部门、学院 // 选择部门、学院
changeDepartment=(e)=>{ changeDepartment = (e) => {
let arr = this.state.departments && this.state.departments.filter ? this.state.departments.filter(function(item){ let arr = this.state.departments && this.state.departments.filter ? this.state.departments.filter(function (item) {
return item.name == e; return item.name == e;
}) : []; }) : [];
if (!arr[0]) { if (!arr[0]) {
@ -271,19 +268,19 @@ class AccountBasic extends Component {
} }
this.this_department_id = arr[0].id this.this_department_id = arr[0].id
this.setState({ this.setState({
departmentsName:e, departmentsName: e,
department_id: arr[0].id, department_id: arr[0].id,
}) })
} }
// 选择学校(获取对应学校的学院、部门) // 选择学校(获取对应学校的学院、部门)
changeList=(e)=>{ changeList = (e) => {
this.getDepartments(e.trim(),true); this.getDepartments(e.trim(), true);
} }
getDepartments=(e,flag)=>{ getDepartments = (e, flag) => {
let arr=this.state.schoolList.filter(function(item){ let arr = this.state.schoolList.filter(function (item) {
if(item.name.indexOf(e) > -1){ if (item.name.indexOf(e) > -1) {
return item.name; return item.name;
} }
}); });
@ -315,21 +312,21 @@ class AccountBasic extends Component {
this.this_school_id = arr[0].id this.this_school_id = arr[0].id
this.setState({ this.setState({
school_id: arr[0].id, school_id: arr[0].id,
school:e, school: e,
}) })
this._getDepartments(arr[0].id, flag) this._getDepartments(arr[0].id, flag)
} }
_getDepartments = (schoolId, flag, selectedName) => { _getDepartments = (schoolId, flag, selectedName) => {
let url=`/schools/${schoolId || this.state.school_id}/departments/for_option.json`; let url = `/schools/${schoolId || this.state.school_id}/departments/for_option.json`;
axios.get(url).then((result)=>{ axios.get(url).then((result) => {
if(result){ if (result) {
this.setState({ this.setState({
departments:result.data.departments, departments: result.data.departments,
filterDepartments:result.data.departments filterDepartments: result.data.departments
}) })
if (selectedName) { if (selectedName) {
let department_id let department_id
result.data.departments.reverse().some( item => { result.data.departments.reverse().some(item => {
if (item.name == selectedName) { if (item.name == selectedName) {
department_id = item.id department_id = item.id
return true; return true;
@ -342,17 +339,17 @@ class AccountBasic extends Component {
department_id, department_id,
// school: selectedName // school: selectedName
}) })
} else if(result.data.departments && result.data.departments.length>0 && flag==true){ } else if (result.data.departments && result.data.departments.length > 0 && flag == true) {
// 切换学校后,部门默认选择第一个 // 切换学校后,部门默认选择第一个
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
org2:result.data.departments[0].name org2: result.data.departments[0].name
}) })
this.setState({ this.setState({
department_id: result.data.departments[0].id department_id: result.data.departments[0].id
}) })
} }
} }
}).catch((error)=>{ }).catch((error) => {
console.log(error); console.log(error);
}) })
} }
@ -380,13 +377,13 @@ class AccountBasic extends Component {
this.applyForAddOrgForm.setVisible(true) this.applyForAddOrgForm.setVisible(true)
} }
showApplyForAddChildOrgModal = () => { showApplyForAddChildOrgModal = () => {
let{school,schoolList}=this.state; let { school, schoolList } = this.state;
let arr=schoolList.filter(function(item){ let arr = schoolList.filter(function (item) {
return item.name == school; return item.name == school;
}); });
if(arr.length > 0){ if (arr.length > 0) {
this.applyForAddChildOrgForm.setVisible(true) this.applyForAddChildOrgForm.setVisible(true)
}else{ } else {
this.props.showNotification("请先选择正确的单位或者学校!"); this.props.showNotification("请先选择正确的单位或者学校!");
} }
} }
@ -398,35 +395,35 @@ class AccountBasic extends Component {
// callback(`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`); // callback(`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`);
// } // }
// 切换职称 // 切换职称
changeJob=(e)=>{ changeJob = (e) => {
this.setState({ this.setState({
identity:e identity: e
}) })
let {basicInfo}=this.props; let { basicInfo } = this.props;
if(basicInfo){ if (basicInfo) {
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
job1:basicInfo && basicInfo.identity=="teacher" ? basicInfo.technical_title:"教授", job1: basicInfo && basicInfo.identity == "teacher" ? basicInfo.technical_title : "教授",
job2:basicInfo && basicInfo.identity=="professional" ? basicInfo.technical_title:"企业管理者", job2: basicInfo && basicInfo.identity == "professional" ? basicInfo.technical_title : "企业管理者",
}) })
} }
} }
//昵称 //昵称
handleSubmitName(rule, value, callback){ handleSubmitName(rule, value, callback) {
if (value) { if (value) {
let iconRule1 = /[`~!@#$%^&*()\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im; let iconRule1 = /[`~!@#$%^&*()\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
// 判断是否含有emoji表情 // 判断是否含有emoji表情
let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig; let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig;
// 如果为true字符串含有emoji表情 false不含 // 如果为true字符串含有emoji表情 false不含
const iconRule2s =iconRule2.test(value); const iconRule2s = iconRule2.test(value);
// 如果为true字符串含有特殊符号 false不 // 如果为true字符串含有特殊符号 false不
const iconRule1s =iconRule1.test(value); const iconRule1s = iconRule1.test(value);
if (iconRule2s===true|| iconRule1s===true) { if (iconRule2s === true || iconRule1s === true) {
callback('2-20位中英文、数字及下划线'); callback('2-20位中英文、数字及下划线');
} }
else if(value.length<2){ else if (value.length < 2) {
callback('2-20位中英文、数字及下划线'); callback('2-20位中英文、数字及下划线');
}else if(value.length>=21){ } else if (value.length >= 21) {
callback('2-20位中英文、数字及下划线'); callback('2-20位中英文、数字及下划线');
} }
} }
@ -434,29 +431,29 @@ class AccountBasic extends Component {
} }
// 姓名 // 姓名
handleSubmitNames(rule, value, callback){ handleSubmitNames(rule, value, callback) {
if (value) { if (value) {
let iconRule1 = /[`~!@#$%^&()_\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&()——\-+={}|《》?:“”【】、;‘’,。、]/im; let iconRule1 = /[`~!@#$%^&()_\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&()——\-+={}|《》?:“”【】、;‘’,。、]/im;
// 判断是否含有emoji表情 // 判断是否含有emoji表情
let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig; let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig;
// 如果为true字符串含有emoji表情 false不含 // 如果为true字符串含有emoji表情 false不含
const iconRule2s =iconRule2.test(value); const iconRule2s = iconRule2.test(value);
// 如果为true字符串含有特殊符号 false不 // 如果为true字符串含有特殊符号 false不
const iconRule1s =iconRule1.test(value); const iconRule1s = iconRule1.test(value);
if (iconRule2s===true|| iconRule1s===true) { if (iconRule2s === true || iconRule1s === true) {
callback('2-10位中英文、数字'); callback('2-10位中英文、数字');
} }
else if(value.length<2){ else if (value.length < 2) {
callback('2-10位中英文、数字'); callback('2-10位中英文、数字');
}else if(value.length>=11){ } else if (value.length >= 11) {
callback('2-10位中英文、数字'); callback('2-10位中英文、数字');
} }
} }
callback(); callback();
} }
render() { render() {
let{ let {
nameLength, nameLength,
showRealName, showRealName,
filterSchoolList, filterSchoolList,
@ -466,20 +463,20 @@ class AccountBasic extends Component {
departments, departments,
departmentsName, departmentsName,
identity identity
}=this.state; } = this.state;
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
let{ basicInfo }=this.props let { basicInfo } = this.props
let common = { let common = {
changeJob:this.changeJob, changeJob: this.changeJob,
filterList:this.filterList, filterList: this.filterList,
changeList:this.changeList, changeList: this.changeList,
searchDepartment:this.searchDepartment, searchDepartment: this.searchDepartment,
changeDepartment:this.changeDepartment, changeDepartment: this.changeDepartment,
showApplyForAddOrgModal:this.showApplyForAddOrgModal, showApplyForAddOrgModal: this.showApplyForAddOrgModal,
showApplyForAddChildOrgModal:this.showApplyForAddChildOrgModal showApplyForAddChildOrgModal: this.showApplyForAddChildOrgModal
} }
// 已职业认证的账户不能修改职业,学校/单位,院系/部门true为disable // 已职业认证的账户不能修改职业,学校/单位,院系/部门true为disable
const professionalFlag = basicInfo && basicInfo.professional_certification == "certified" ; const professionalFlag = basicInfo && basicInfo.professional_certification == "certified";
// form合并了 // form合并了
const propsWithoutForm = Object.assign({}, this.props) const propsWithoutForm = Object.assign({}, this.props)
@ -576,7 +573,7 @@ class AccountBasic extends Component {
], ],
validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit
})( })(
<Input placeholder={`请输入您的昵称,最大限制${MAX_NICKNAME_LENGTH}个字符`} className="exercicenewinputysl" onInput={this.changeNickName} maxLength={MAX_NICKNAME_LENGTH} addonAfter ={ <Input placeholder={`请输入您的昵称,最大限制${MAX_NICKNAME_LENGTH}个字符`} className="exercicenewinputysl" onInput={this.changeNickName} maxLength={MAX_NICKNAME_LENGTH} addonAfter={
<span className="color-grey-6 font-13">{String(nameLength)}/{MAX_NICKNAME_LENGTH}</span> <span className="color-grey-6 font-13">{String(nameLength)}/{MAX_NICKNAME_LENGTH}</span>
}></Input> }></Input>
)} )}
@ -596,7 +593,7 @@ class AccountBasic extends Component {
label="姓名" label="姓名"
className="formItemInline" className="formItemInline"
> >
{ basicInfo.authentication == 'uncertified' ? <React.Fragment>{getFieldDecorator('name', { {basicInfo.authentication == 'uncertified' ? <React.Fragment>{getFieldDecorator('name', {
rules: [{ rules: [{
// initialValue: this.state.cityDefaultValue, // initialValue: this.state.cityDefaultValue,
required: true, required: true,
@ -607,20 +604,20 @@ class AccountBasic extends Component {
], ],
validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit
})( })(
<Input placeholder={`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`} className="yslgraduainputedit" disabled={!showRealName && this.state.forDisable == true } addonAfter={ <Input placeholder={`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`} className="yslgraduainputedit" disabled={!showRealName && this.state.forDisable == true} addonAfter={
<i className={showRealName?"iconfont icon-xianshi font-18 color-blue":"iconfont icon-yincang font-18 color-blue"} <i className={showRealName ? "iconfont icon-xianshi font-18 color-blue" : "iconfont icon-yincang font-18 color-blue"}
onClick={()=>this.showOrHide(showRealName)}></i> onClick={() => this.showOrHide(showRealName)}></i>
}></Input> }></Input>
)} )}
<span>{ showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)' }</span> <span>{showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)'}</span>
</React.Fragment> : </React.Fragment> :
<div className="df" style={{}}> <div className="df" style={{}}>
<Tooltip title="已完成实名认证,不能修改"> <Tooltip title="已完成实名认证,不能修改">
<span className="mr8" >{showRealName ? this.props.basicInfo.name : getHiddenName(this.props.basicInfo.name)}</span> <span className="mr8" >{showRealName ? this.props.basicInfo.name : getHiddenName(this.props.basicInfo.name)}</span>
</Tooltip> </Tooltip>
<i className={showRealName?"iconfont icon-xianshi font-18 color-blue":"iconfont icon-yincang font-18 color-blue"} <i className={showRealName ? "iconfont icon-xianshi font-18 color-blue" : "iconfont icon-yincang font-18 color-blue"}
onClick={()=>this.showOrHide(showRealName)}></i> onClick={() => this.showOrHide(showRealName)}></i>
<span>{ showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)' }</span> <span>{showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)'}</span>
</div> </div>
} }
</Form.Item> </Form.Item>
@ -661,9 +658,9 @@ class AccountBasic extends Component {
</Form.Item> </Form.Item>
<AccountBasicEditItem <AccountBasicEditItem
identity={identity} identity={identity}
getFieldDecorator = {getFieldDecorator} getFieldDecorator={getFieldDecorator}
professionalFlag = {professionalFlag} professionalFlag={professionalFlag}
basicInfo = {basicInfo} basicInfo={basicInfo}
{...this.props} {...this.props}
{...this.state} {...this.state}
{...common} {...common}
@ -686,7 +683,7 @@ class AccountBasic extends Component {
</Form.Item> */} </Form.Item> */}
</Form> </Form>
</div> </div>
<div style={{color: '#989898', marginLeft: '20px', marginBottom: '10px'}}>* 我们确保你所提供的信息均处于严格保密状态不会泄露</div> <div style={{ color: '#989898', marginLeft: '20px', marginBottom: '10px' }}>* 我们确保你所提供的信息均处于严格保密状态不会泄露</div>
</div> </div>
); );
} }

@ -1,6 +1,4 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { SnackbarHOC, getImageUrl } from 'educoder';
import AccountImg from './AccountImg' import AccountImg from './AccountImg'
class AccountNav extends Component { class AccountNav extends Component {
toBasic = () => { toBasic = () => {
@ -102,16 +100,16 @@ class AccountNav extends Component {
<i className="iconfont icon-renzhengxinxi color-grey-9 font-16"></i> <i className="iconfont icon-renzhengxinxi color-grey-9 font-16"></i>
{ {
basicInfo.professional_certification == 'certified' && basicInfo.authentication == 'certified' ? basicInfo.professional_certification == 'certified' && basicInfo.authentication == 'certified' ?
<i className="status fr iconfont icon-wancheng color-green-light font-16"></i>: <i className="status fr iconfont icon-wancheng color-green-light font-16"></i> :
<i className="status fr iconfont icon-tishi color-red font-16"></i> <i className="status fr iconfont icon-tishi color-red font-16"></i>
} }
</li> </li>
<li className={`navItem ${isSecure ? 'active' : ''}`} onClick={this.toSecure}> <li className={`navItem ${isSecure ? 'active' : ''}`} onClick={this.toSecure}>
<i className="iconfont icon-anquanshezhi color-grey-9 font-16"></i> <i className="iconfont icon-anquanshezhi color-grey-9 font-16"></i>
</li> </li>
{this.props.user&&this.props.user.main_site===true?<li className={`navItem ${isBinding ? 'active' : ''}`} onClick={this.isBinding}> {this.props.user && this.props.user.main_site === true ? <li className={`navItem ${isBinding ? 'active' : ''}`} onClick={this.isBinding}>
<i className="iconfont icon-lianjie color-grey-9 font-16"></i> <i className="iconfont icon-lianjie color-grey-9 font-16"></i>
</li>:""} </li> : ""}
</ul> </ul>
</div> </div>
</React.Fragment> </React.Fragment>
@ -121,4 +119,4 @@ class AccountNav extends Component {
} }
} }
export default AccountNav ; export default AccountNav;

Loading…
Cancel
Save