fix accountbasic bug

dev_aliyun2
harry 5 years ago
parent be519f87e1
commit a691b82a7e

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

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

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

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

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

@ -1,27 +1,17 @@
import React, { Component } from 'react';
import { SnackbarHOC, getImageUrl, City } from 'educoder';
import { Form, Button, Input, Radio, Select, Tooltip, Icon } from 'antd'
import { Form, Button } from 'antd'
import './common.css'
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 {
constructor(props){
constructor(props) {
super(props);
}
render() {
const { getFieldDecorator } = this.props.form;
const {basicInfo} =this.props
const showRealName = false;
const { basicInfo } = this.props
return (
<div>
<div className="basicForm">
@ -54,7 +44,7 @@ class AccountBasicEdit extends Component {
`}</style>
<div className="titleWrap">
<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>
</div>
@ -77,7 +67,7 @@ class AccountBasicEdit extends Component {
label="性别"
className="display formItemInline"
>
{basicInfo && basicInfo.gender == 0?"男":"女"}
{basicInfo && basicInfo.gender == 0 ? "男" : "女"}
</Form.Item>
@ -92,7 +82,7 @@ class AccountBasicEdit extends Component {
label="职业"
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
@ -109,8 +99,8 @@ class AccountBasicEdit extends Component {
{basicInfo && basicInfo.department_name}
</Form.Item>
</Form>
</div>
<div style={{color: '#989898', marginLeft: '20px'}}>* 我们确保你所提供的信息均处于严格保密状态不会泄露</div>
</div>
<div style={{ color: '#989898', marginLeft: '20px' }}>* 我们确保你所提供的信息均处于严格保密状态不会泄露</div>
</div>
);
}

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

@ -1,6 +1,4 @@
import React, { Component } from 'react';
import { SnackbarHOC, getImageUrl } from 'educoder';
import AccountImg from './AccountImg'
class AccountNav extends Component {
toBasic = () => {
@ -12,20 +10,20 @@ class AccountNav extends Component {
toSecure = () => {
this.props.history.push(`/account/secure`)
}
isBinding = () => {
this.props.history.push(`/account/binding`)
}
render() {
let { basicInfo, current_user } = this.props
// console.log(this.props);
const path = window.location.pathname
const isBasic = path.indexOf('profile') != -1 || path == "/account"
const isCertification = path.indexOf('certification') != -1
const isSecure = path.indexOf('secure') != -1
const isBinding = path.indexOf('binding') != -1
return (
<div className="accountNav fl">
<style>{`
isBinding = () => {
this.props.history.push(`/account/binding`)
}
render() {
let { basicInfo, current_user } = this.props
// console.log(this.props);
const path = window.location.pathname
const isBasic = path.indexOf('profile') != -1 || path == "/account"
const isCertification = path.indexOf('certification') != -1
const isSecure = path.indexOf('secure') != -1
const isBinding = path.indexOf('binding') != -1
return (
<div className="accountNav fl">
<style>{`
.accountInfo {
text-align: center;
display: flex;
@ -77,48 +75,48 @@ class AccountNav extends Component {
color: #45E660!important;
}
`}</style>
{
basicInfo && basicInfo.id &&
<React.Fragment>
<div className="accountInfo">
<AccountImg src={basicInfo.avatar_url} {...this.props}></AccountImg>
<span className="name">{basicInfo.name || (current_user ? "" : '')}</span>
<span className="role">{basicInfo.technical_title}</span>
</div>
{
basicInfo && basicInfo.id &&
<React.Fragment>
<div className="accountInfo">
<AccountImg src={basicInfo.avatar_url} {...this.props}></AccountImg>
<span className="name">{basicInfo.name || (current_user ? "" : '')}</span>
<span className="role">{basicInfo.technical_title}</span>
</div>
<div className="accountManagement">
<div className="title">账号管理</div>
<ul>
<li className={`navItem ${isBasic ? 'active' : ''}`} onClick={this.toBasic}>
<i className="iconfont icon-jibenxinxi color-grey-9 font-16"></i>
基本信息
<div className="accountManagement">
<div className="title">账号管理</div>
<ul>
<li className={`navItem ${isBasic ? 'active' : ''}`} onClick={this.toBasic}>
<i className="iconfont icon-jibenxinxi color-grey-9 font-16"></i>
基本信息
{
basicInfo.base_info_completed == true ?
<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>
}
</li>
<li className={`navItem ${isCertification ? 'active' : ''}`} onClick={this.toCertification}>
<i className="iconfont icon-renzhengxinxi color-grey-9 font-16"></i>
basicInfo.base_info_completed == true ?
<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>
}
</li>
<li className={`navItem ${isCertification ? 'active' : ''}`} onClick={this.toCertification}>
<i className="iconfont icon-renzhengxinxi color-grey-9 font-16"></i>
{
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-tishi color-red font-16"></i>
}
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-tishi color-red font-16"></i>
}
</li>
<li className={`navItem ${isSecure ? 'active' : ''}`} onClick={this.toSecure}>
<i className="iconfont icon-anquanshezhi color-grey-9 font-16"></i>
</li>
<li className={`navItem ${isSecure ? 'active' : ''}`} onClick={this.toSecure}>
<i className="iconfont icon-anquanshezhi color-grey-9 font-16"></i>
</li>
{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>
</li>:""}
</ul>
</div>
</React.Fragment>
}
</div>
);
}
{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>
</li> : ""}
</ul>
</div>
</React.Fragment>
}
</div>
);
}
}
export default AccountNav ;
export default AccountNav;

Loading…
Cancel
Save