From a691b82a7ea418066a7138152bcf67eebd09129c Mon Sep 17 00:00:00 2001 From: harry Date: Wed, 11 Mar 2020 15:34:03 +0800 Subject: [PATCH] fix accountbasic bug --- public/react/src/Loading.js | 4 +- public/react/src/modules/login/LoginDialog.js | 3 +- .../react/src/modules/login/Otherloginqq.js | 40 +- .../src/modules/login/Otherloginstart.js | 40 +- public/react/src/modules/user/AccountPage.js | 7 +- .../src/modules/user/account/AccountBasic.js | 28 +- .../modules/user/account/AccountBasicEdit.js | 459 +++++++++--------- .../src/modules/user/account/AccountNav.js | 108 ++--- 8 files changed, 334 insertions(+), 355 deletions(-) diff --git a/public/react/src/Loading.js b/public/react/src/Loading.js index 7e56d9e7b..5a2995f01 100644 --- a/public/react/src/Loading.js +++ b/public/react/src/Loading.js @@ -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 { ` } - +

loading...

); } diff --git a/public/react/src/modules/login/LoginDialog.js b/public/react/src/modules/login/LoginDialog.js index 19c65e13b..811759872 100644 --- a/public/react/src/modules/login/LoginDialog.js +++ b/public/react/src/modules/login/LoginDialog.js @@ -486,7 +486,7 @@ class LoginDialog extends Component { } return ( - this.handleDialogClose()} > @@ -516,7 +516,6 @@ class LoginDialog extends Component {
{weixinlogin === true ? "" :
  • { this.enter(0) }}>登录
  • - {/*
  • {this.register(0)}}>快捷登录
  • */}
} diff --git a/public/react/src/modules/login/Otherloginqq.js b/public/react/src/modules/login/Otherloginqq.js index 46856eece..59a0fa934 100644 --- a/public/react/src/modules/login/Otherloginqq.js +++ b/public/react/src/modules/login/Otherloginqq.js @@ -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 ( -
+
- +
); } diff --git a/public/react/src/modules/login/Otherloginstart.js b/public/react/src/modules/login/Otherloginstart.js index 93d202ce1..ad506a41e 100644 --- a/public/react/src/modules/login/Otherloginstart.js +++ b/public/react/src/modules/login/Otherloginstart.js @@ -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 ( -
+
- +
); } diff --git a/public/react/src/modules/user/AccountPage.js b/public/react/src/modules/user/AccountPage.js index 179e5febb..2b34a2368 100644 --- a/public/react/src/modules/user/AccountPage.js +++ b/public/react/src/modules/user/AccountPage.js @@ -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}`, diff --git a/public/react/src/modules/user/account/AccountBasic.js b/public/react/src/modules/user/account/AccountBasic.js index aef66e5c2..1c799f0f7 100644 --- a/public/react/src/modules/user/account/AccountBasic.js +++ b/public/react/src/modules/user/account/AccountBasic.js @@ -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 (
@@ -54,7 +44,7 @@ class AccountBasicEdit extends Component { `}
基本信息
-
@@ -77,7 +67,7 @@ class AccountBasicEdit extends Component { label="性别" className="display formItemInline" > - {basicInfo && basicInfo.gender == 0?"男":"女"} + {basicInfo && basicInfo.gender == 0 ? "男" : "女"} @@ -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)} -
-
* 我们确保你所提供的信息均处于严格保密状态,不会泄露
+
+
* 我们确保你所提供的信息均处于严格保密状态,不会泄露
); } diff --git a/public/react/src/modules/user/account/AccountBasicEdit.js b/public/react/src/modules/user/account/AccountBasicEdit.js index 7d6fc13d2..da5aa2415 100644 --- a/public/react/src/modules/user/account/AccountBasicEdit.js +++ b/public/react/src/modules/user/account/AccountBasicEdit.js @@ -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 (
- this.applyForAddOrgForm = form} schoolName={school} - {...propsWithoutForm} addOrgSuccess={this.addOrgSuccess} + this.applyForAddOrgForm = form} schoolName={school} + {...propsWithoutForm} addOrgSuccess={this.addOrgSuccess} > this.applyForAddChildOrgForm = form} - addChildOrgSuccess={this.addChildOrgSuccess} + {...propsWithoutForm} wrappedComponentRef={(form) => this.applyForAddChildOrgForm = form} + addChildOrgSuccess={this.addChildOrgSuccess} >
@@ -572,11 +569,11 @@ class AccountBasic extends Component { required: true, message: '请输入您的昵称', }, - { validator: this.handleSubmitName }, + { validator: this.handleSubmitName }, ], - validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit + validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit })( - {String(nameLength)}/{MAX_NICKNAME_LENGTH} }> )} @@ -596,31 +593,31 @@ class AccountBasic extends Component { label="姓名" className="formItemInline" > - { basicInfo.authentication == 'uncertified' ? {getFieldDecorator('name', { - rules: [{ - // initialValue: this.state.cityDefaultValue, - required: true, - message: `请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`, - }, - { validator: this.handleSubmitNames }, - - ], - validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit - })( - this.showOrHide(showRealName)}> - }> - )} - { showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)' } - : + {basicInfo.authentication == 'uncertified' ? {getFieldDecorator('name', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: `请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`, + }, + { validator: this.handleSubmitNames }, + + ], + validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit + })( + this.showOrHide(showRealName)}> + }> + )} + {showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)'} + :
{showRealName ? this.props.basicInfo.name : getHiddenName(this.props.basicInfo.name)} - this.showOrHide(showRealName)}> - { showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)' } + this.showOrHide(showRealName)}> + {showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)'}
} @@ -660,33 +657,33 @@ class AccountBasic extends Component { )} - {/* 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} + > + {/* htmlType="submit" */} {/*
*/} - + - {this.props.basicInfo.base_info_completed && - } - {/*
+ {this.props.basicInfo.base_info_completed && + } + {/*
*/} -
-
* 我们确保你所提供的信息均处于严格保密状态,不会泄露
+
+
* 我们确保你所提供的信息均处于严格保密状态,不会泄露
); } diff --git a/public/react/src/modules/user/account/AccountNav.js b/public/react/src/modules/user/account/AccountNav.js index c4d8b0630..d6a94f6c6 100644 --- a/public/react/src/modules/user/account/AccountNav.js +++ b/public/react/src/modules/user/account/AccountNav.js @@ -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 ( -
- - { - basicInfo && basicInfo.id && - -
- - {basicInfo.name || (current_user ? "" : '')} - {basicInfo.technical_title} -
+ { + basicInfo && basicInfo.id && + +
+ + {basicInfo.name || (current_user ? "" : '')} + {basicInfo.technical_title} +
-
-
账号管理
-
    -
  • - - 基本信息 +
    +
    账号管理
    +
      +
    • + + 基本信息 { - basicInfo.base_info_completed == true ? - : - - } -
    • -
    • - 认证信息 + basicInfo.base_info_completed == true ? + : + + } +
    • +
    • + 认证信息 { - basicInfo.professional_certification == 'certified' && basicInfo.authentication == 'certified' ? - : - - } + basicInfo.professional_certification == 'certified' && basicInfo.authentication == 'certified' ? + : + + } +
    • +
    • + 安全设置
    • -
    • - 安全设置 -
    • - {this.props.user&&this.props.user.main_site===true?
    • - 绑定登录账号 -
    • :""} -
    -
    - - } -
- ); - } + {this.props.user && this.props.user.main_site === true ?
  • + 绑定登录账号 +
  • : ""} + +
    + + } + + ); + } } -export default AccountNav ; +export default AccountNav;