dev_forum
hjm 5 years ago
parent a9d83f0ba0
commit 8b6ca86a83

@ -3,7 +3,7 @@ import React, { Component } from 'react';
import { SnackbarHOC, getImageUrl, City } from 'educoder'; import { SnackbarHOC, getImageUrl, City } from 'educoder';
import { Form, Button, Input, Radio, Select, Tooltip, Icon } from 'antd' import { Form, Button, Input, Radio, Select, Tooltip, Icon } from 'antd'
import './common.css' import './common.css'
import { getHiddenName } from './AccountBasicEdit'
const RadioGroup = Radio.Group; const RadioGroup = Radio.Group;
const Option = Select.Option const Option = Select.Option
@ -70,7 +70,7 @@ class AccountBasicEdit extends Component {
label="姓名" label="姓名"
className="display formItemInline" className="display formItemInline"
> >
{basicInfo && basicInfo.name} {basicInfo && (basicInfo.show_realname == true ? basicInfo.name : getHiddenName(basicInfo.name))}
</Form.Item> </Form.Item>
<Form.Item <Form.Item

@ -10,6 +10,14 @@ const RadioGroup = Radio.Group;
const Option = Select.Option; const Option = Select.Option;
const map = identityMap // {"teacher":"教师", "student":"学生", "professional":"专业人士"} 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;
return newName
}
class AccountBasic extends Component { class AccountBasic extends Component {
constructor(props){ constructor(props){
super(props); super(props);
@ -154,19 +162,10 @@ class AccountBasic extends Component {
} }
} }
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;
return newName
}
// 将名字隐藏起来 // 将名字隐藏起来
hideRealName=(name)=>{ hideRealName=(name)=>{
this.setState({ realName: name }) this.setState({ realName: name })
const newName = this.getHiddenName(name) const newName = getHiddenName(name)
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
name: newName name: newName
@ -406,7 +405,7 @@ class AccountBasic extends Component {
<span>{ showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)' }</span> <span>{ showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)' }</span>
</React.Fragment> : </React.Fragment> :
<div className="df" style={{ 'justify-content': 'center' }}> <div className="df" style={{ 'justify-content': 'center' }}>
<span className="mr8" >{showRealName ? this.props.basicInfo.name : this.getHiddenName(this.props.basicInfo.name)}</span> <span className="mr8" >{showRealName ? this.props.basicInfo.name : getHiddenName(this.props.basicInfo.name)}</span>
<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>

Loading…
Cancel
Save