Merge branch 'gitlink_server' of http://106.75.45.236:3000/Gitlink/forgeplus-react into gitlink_server

This commit is contained in:
谢思 2022-11-25 15:37:53 +08:00
commit 8d92f2962b
11 changed files with 1643 additions and 281 deletions

1116
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
"antd": "^3.26.15",
"array-flatten": "^2.1.2",
"autoprefixer": "7.1.6",
"axios": "^0.24.0",
"axios": "^0.24.0",
"bizcharts": "^3.5.8",
"bundle-loader": "^0.5.6",
"chalk": "1.1.3",

View File

@ -3,10 +3,12 @@ import 'katex/dist/katex.min.css'
import marked, { getTocContent, cleanToc, getMathExpressions, resetMathExpressions } from '../common/marked';
import 'code-prettify'
import dompurify from 'dompurify';
import { getEmoji } from '../forge/Main/emoji';
import { renderToString } from 'katex'
const preRegex = /<pre[^>]*>/g
const preRegex = /<pre[^>]*>/g;
const strRegexSub = /:([a-zA-Z_]+):/g;
function _unescape(str) {
let div = document.createElement('div')
div.innerHTML = str
@ -29,6 +31,13 @@ export default ({
rs = rs.replace("<p>[TOC]</p>", getTocContent())
cleanToc()
}
let matchStr = str.match(strRegexSub);
if(matchStr && matchStr.length>0){
for(var i=0;i < matchStr.length;i++){
rs = rs.replace(matchStr[i],getEmoji(matchStr[i]));
}
}
rs = rs.replace(/(__special_katext_id_\d+__)/g, (_match, capture) => {
const { type, expression } = math_expressions[capture];
return renderToString(_unescape(expression) || '', { displayMode: type === 'block', throwOnError: false, output: 'html' })

View File

@ -39,11 +39,8 @@ class NewHeader extends Component {
submitapplications: false,
isRender: false,
showTrial: false,
setevaluatinghides: false,
occupation: 0,
mydisplay: false,
// headtypesonClickbool: false,
// headtypess: "/",
settings: null,
visiblemyss: false,
openSearch:false,
@ -52,12 +49,11 @@ class NewHeader extends Component {
}
componentDidMount() {
// 用personal判断是否需要再次请求settings接口解决登录注册之后无设置按钮的情况
if(localStorage.chromesetting && localStorage.chromesetting.personal){
let settings = localStorage.chromesetting&&JSON.parse(localStorage.chromesetting);
if(settings){
this.setState({
settings: JSON.parse(localStorage.chromesetting)
settings
})
}else{
this.geturlsdata();
}
window._header_componentHandler = this;
@ -66,6 +62,7 @@ class NewHeader extends Component {
} catch (e) {}
}
openNotification = (messge) => {
notification.open({
message: "提示",
@ -127,11 +124,6 @@ class NewHeader extends Component {
this.setState({ isRenders: false })
}
setevaluatinghides = () => {
this.setState({
setevaluatinghides: true
})
}
//修改登录方法
Modifyloginvalue = () => {
this.setState({
@ -144,12 +136,6 @@ class NewHeader extends Component {
AccountProfiletype: false
})
};
// headtypesonClick = (url, bool) => {
// this.setState({
// headtypess: url,
// headtypesonClickbool: bool,
// })
// }
//获取数据为空的时候
gettablogourlnull = () => {
this.setState({
@ -275,13 +261,13 @@ class NewHeader extends Component {
};
render() {
const { resetUserInfo ,showNotification,publicNav} = this.props;
const { resetUserInfo ,showNotification,publicNav,mygetHelmetapi} = this.props;
let settings = mygetHelmetapi;
let current_user = this.props.user;
let {
AccountProfiletype,
user,
isRender,
settings,
visible,
} = this.state;
let search_url = settings && settings.common && settings.common.search;

View File

@ -1,7 +1,7 @@
import React from 'react';
import React , { useEffect } from 'react';
import { Link } from 'react-router-dom';
import { truncateCommitId } from '../common/util';
import {getEmoji} from './emoji';
const typeIco = {
"submodule":"icon-file-submodule font-17",
"file":'icon-wenjian6 font-15 color-blue-file',
@ -11,9 +11,19 @@ const typeIco = {
function CoderDepotCatalogue({item , goToSubRoot , owner , projectsId , platform }){
//
function getMessage(value){
let str = value.indexOf('\n') > 0 && value.split('\n');
return str[0];
var matchStr = value.match(/:([a-zA-Z_]+):/g);
if(matchStr && matchStr.length>0){
for(var i=0;i < matchStr.length;i++){
value = value.replace(matchStr[i],getEmoji(matchStr[i]));
}
}
return value;
}
useEffect(()=>{
},[])
return(
<li>
<span>
@ -28,7 +38,7 @@ function CoderDepotCatalogue({item , goToSubRoot , owner , projectsId , platform
</span>
<span title="init project">
<Link to={`/${owner}/${projectsId}/commits/${truncateCommitId(`${item.commit && item.commit.sha}`)}`} title={item.commit && item.commit.message}>
{getMessage(item.commit && item.commit.message)}
{getEmoji(getMessage(item.commit && item.commit.message))}
</Link>
</span>
<span title={item.commit && item.commit.created_at}>{item.commit && item.commit.time_from_now}</span>

View File

@ -0,0 +1,462 @@
const emoji = [
{
"emoji": "🎨",
"entity": "&#x1f3a8;",
"code": ":art:",
"description": "Improve structure / format of the code.",
"name": "art"
},
{
"emoji": "⚡️",
"entity": "&#x26a1;",
"code": ":zap:",
"description": "Improve performance.",
"name": "zap"
},
{
"emoji": "🔥",
"entity": "&#x1f525;",
"code": ":fire:",
"description": "Remove code or files.",
"name": "fire"
},
{
"emoji": "🐛",
"entity": "&#x1f41b;",
"code": ":bug:",
"description": "Fix a bug.",
"name": "bug"
},
{
"emoji": "🚑",
"entity": "&#128657;",
"code": ":ambulance:",
"description": "Critical hotfix.",
"name": "ambulance"
},
{
"emoji": "✨",
"entity": "&#x2728;",
"code": ":sparkles:",
"description": "Introduce new features.",
"name": "sparkles"
},
{
"emoji": "📝",
"entity": "&#x1f4dd;",
"code": ":memo:",
"description": "Add or update documentation.",
"name": "memo"
},
{
"emoji": "🚀",
"entity": "&#x1f680;",
"code": ":rocket:",
"description": "Deploy stuff.",
"name": "rocket"
},
{
"emoji": "💄",
"entity": "&#ff99cc;",
"code": ":lipstick:",
"description": "Add or update the UI and style files.",
"name": "lipstick"
},
{
"emoji": "🎉",
"entity": "&#127881;",
"code": ":tada:",
"description": "Begin a project.",
"name": "tada"
},
{
"emoji": "✅",
"entity": "&#x2705;",
"code": ":white_check_mark:",
"description": "Add or update tests.",
"name": "white-check-mark"
},
{
"emoji":"🍎",
"entity": "",
"code": ":apple:",
"description": "apple",
"name": "apple"
},
{
"emoji":"🐳",
"entity": "",
"code": ":whale:",
"description": "whale",
"name": "whale"
},
{
"emoji": "🔒",
"entity": "&#x1f512;",
"code": ":lock:",
"description": "Fix security issues.",
"name": "lock"
},
{
"emoji": "🔖",
"entity": "&#x1f516;",
"code": ":bookmark:",
"description": "Release / Version tags.",
"name": "bookmark"
},
{
"emoji": "🚨",
"entity": "&#x1f6a8;",
"code": ":rotating_light:",
"description": "Fix compiler / linter warnings.",
"name": "rotating-light"
},
{
"emoji": "🚧",
"entity": "&#x1f6a7;",
"code": ":construction:",
"description": "Work in progress.",
"name": "construction"
},
{
"emoji": "💚",
"entity": "&#x1f49a;",
"code": ":green_heart:",
"description": "Fix CI Build.",
"name": "green-heart"
},
{
"emoji": "⬇️",
"entity": "⬇️",
"code": ":arrow_down:",
"description": "Downgrade dependencies.",
"name": "arrow-down"
},
{
"emoji": "⬆️",
"entity": "⬆️",
"code": ":arrow_up:",
"description": "Upgrade dependencies.",
"name": "arrow-up"
},
{
"emoji": "📌",
"entity": "&#x1F4CC;",
"code": ":pushpin:",
"description": "Pin dependencies to specific versions.",
"name": "pushpin"
},
{
"emoji": "👷",
"entity": "&#x1f477;",
"code": ":construction_worker:",
"description": "Add or update CI build system.",
"name": "construction-worker"
},
{
"emoji": "📈",
"entity": "&#x1F4C8;",
"code": ":chart_with_upwards_trend:",
"description": "Add or update analytics or track code.",
"name": "chart-with-upwards-trend"
},
{
"emoji": "♻️",
"entity": "&#x2672;",
"code": ":recycle:",
"description": "Refactor code.",
"name": "recycle"
},
{
"emoji": "",
"entity": "&#10133;",
"code": ":heavy_plus_sign:",
"description": "Add a dependency.",
"name": "heavy-plus-sign"
},
{
"emoji": "",
"entity": "&#10134;",
"code": ":heavy_minus_sign:",
"description": "Remove a dependency.",
"name": "heavy-minus-sign"
},
{
"emoji": "🔧",
"entity": "&#x1f527;",
"code": ":wrench:",
"description": "Add or update configuration files.",
"name": "wrench"
},
{
"emoji": "🔨",
"entity": "&#128296;",
"code": ":hammer:",
"description": "Add or update development scripts.",
"name": "hammer"
},
{
"emoji": "🌐",
"entity": "&#127760;",
"code": ":globe_with_meridians:",
"description": "Internationalization and localization.",
"name": "globe-with-meridians"
},
{
"emoji": "✏️",
"entity": "&#59161;",
"code": ":pencil2:",
"description": "Fix typos.",
"name": "pencil2"
},
{
"emoji": "📝",
"entity": "&#x1f4dd;",
"code": ":pencil:",
"description": "Add or update documentation.",
"name": "pencil"
},
{
"emoji": "💩",
"entity": "&#58613;",
"code": ":poop:",
"description": "Write bad code that needs to be improved.",
"name": "poop"
},
{
"emoji": "⏪",
"entity": "&#9194;",
"code": ":rewind:",
"description": "Revert changes.",
"name": "rewind"
},
{
"emoji": "🔀",
"entity": "&#128256;",
"code": ":twisted_rightwards_arrows:",
"description": "Merge branches.",
"name": "twisted-rightwards-arrows"
},
{
"emoji": "📦",
"entity": "&#1F4E6;",
"code": ":package:",
"description": "Add or update compiled files or packages.",
"name": "package"
},
{
"emoji": "👽",
"entity": "&#1F47D;",
"code": ":alien:",
"description": "Update code due to external API changes.",
"name": "alien"
},
{
"emoji": "🚚",
"entity": "&#1F69A;",
"code": ":truck:",
"description": "Move or rename resources (e.g.: files, paths, routes).",
"name": "truck"
},
{
"emoji": "📄",
"entity": "&#1F4C4;",
"code": ":page_facing_up:",
"description": "Add or update license.",
"name": "page-facing-up"
},
{
"emoji": "💥",
"entity": "&#x1f4a5;",
"code": ":boom:",
"description": "Introduce breaking changes.",
"name": "boom"
},
{
"emoji": "🍱",
"entity": "&#1F371",
"code": ":bento:",
"description": "Add or update assets.",
"name": "bento"
},
{
"emoji": "♿️",
"entity": "&#9855;",
"code": ":wheelchair:",
"description": "Improve accessibility.",
"name": "wheelchair"
},
{
"emoji": "💡",
"entity": "&#128161;",
"code": ":bulb:",
"description": "Add or update comments in source code.",
"name": "bulb"
},
{
"emoji": "🍻",
"entity": "&#x1f37b;",
"code": ":beers:",
"description": "Write code drunkenly.",
"name": "beers"
},
{
"emoji": "💬",
"entity": "&#128172;",
"code": ":speech_balloon:",
"description": "Add or update text and literals.",
"name": "speech-balloon"
},
{
"emoji": "🗃",
"entity": "&#128451;",
"code": ":card_file_box:",
"description": "Perform database related changes.",
"name": "card-file-box"
},
{
"emoji": "🔊",
"entity": "&#128266;",
"code": ":loud_sound:",
"description": "Add or update logs.",
"name": "loud-sound"
},
{
"emoji": "🔇",
"entity": "&#128263;",
"code": ":mute:",
"description": "Remove logs.",
"name": "mute"
},
{
"emoji": "👥",
"entity": "&#128101;",
"code": ":busts_in_silhouette:",
"description": "Add or update contributor(s).",
"name": "busts-in-silhouette"
},
{
"emoji": "🚸",
"entity": "&#128696;",
"code": ":children_crossing:",
"description": "Improve user experience / usability.",
"name": "children-crossing"
},
{
"emoji": "🏗",
"entity": "&#1f3d7;",
"code": ":building_construction:",
"description": "Make architectural changes.",
"name": "building-construction"
},
{
"emoji": "📱",
"entity": "&#128241;",
"code": ":iphone:",
"description": "Work on responsive design.",
"name": "iphone"
},
{
"emoji": "🤡",
"entity": "&#129313;",
"code": ":clown_face:",
"description": "Mock things.",
"name": "clown-face"
},
{
"emoji": "🥚",
"entity": "&#129370;",
"code": ":egg:",
"description": "Add or update an easter egg.",
"name": "egg"
},
{
"emoji": "🙈",
"entity": "&#8bdfe7;",
"code": ":see_no_evil:",
"description": "Add or update a .gitignore file.",
"name": "see-no-evil"
},
{
"emoji": "📸",
"entity": "&#128248;",
"code": ":camera_flash:",
"description": "Add or update snapshots.",
"name": "camera-flash"
},
{
"emoji": "⚗",
"entity": "&#128248;",
"code": ":alembic:",
"description": "Perform experiments.",
"name": "alembic"
},
{
"emoji": "🔍",
"entity": "&#128269;",
"code": ":mag:",
"description": "Improve SEO.",
"name": "mag"
},
{
"emoji": "🏷️",
"entity": "&#127991;",
"code": ":label:",
"description": "Add or update types.",
"name": "label"
},
{
"emoji": "🌱",
"entity": "&#127793;",
"code": ":seedling:",
"description": "Add or update seed files.",
"name": "seedling"
},
{
"emoji": "🚩",
"entity": "&#x1F6A9;",
"code": ":triangular_flag_on_post:",
"description": "Add, update, or remove feature flags.",
"name": "triangular-flag-on-post"
},
{
"emoji": "🥅",
"entity": "&#x1F945;",
"code": ":goal_net:",
"description": "Catch errors.",
"name": "goal-net"
},
{
"emoji": "💫",
"entity": "&#x1f4ab;",
"code": ":dizzy:",
"description": "Add or update animations and transitions.",
"name": "animation"
},
{
"emoji": "🗑",
"entity": "&#x1F5D1;",
"code": ":wastebasket:",
"description": "Deprecate code that needs to be cleaned up.",
"name": "wastebasket"
},
{
"emoji": "🛂",
"entity": "&#x1F6C2;",
"code": ":passport_control:",
"description": "Work on code related to authorization, roles and permissions.",
"name": "passport-control"
},
{
"emoji": "🩹",
"entity": "&#x1FA79;",
"code": ":adhesive_bandage:",
"description": "Simple fix for a non-critical issue.",
"name": "adhesive-bandage"
}
]
export function getEmoji(code){
let filter = emoji.filter(i=>i.code === code);
return filter.length>0?filter[0].emoji:code;
}

View File

@ -90,7 +90,7 @@ function Index(props){
<ul className="securityUl ul-border-buttom">
<li>个人信息</li>
<li className={pathname.indexOf("/settings/profile")>-1 ?"active":""}><Link to={`/settings/profile`}><i className="iconfont icon-gerenziliao mr5 font-14"></i><span className="text-shodow-bold">基本资料</span></Link></li>
<li className={(pathname.indexOf("/settings/emails")>-1 || pathname.indexOf("/settings/password")>-1 || pathname.indexOf("/settings/cancel")>-1) ?"active":""}><Link to={`/settings/emails`}><i className="iconfont icon-xuanzhonganquanshezhi_icon mr5 font-14"></i><span className="text-shodow-bold">账号管理</span></Link></li>
<li className={(pathname.indexOf("/settings/emails")>-1 || pathname.indexOf("/settings/phone")>-1 || pathname.indexOf("/settings/password")>-1 || pathname.indexOf("/settings/cancel")>-1) ?"active":""}><Link to={`/settings/emails`}><i className="iconfont icon-xuanzhonganquanshezhi_icon mr5 font-14"></i><span className="text-shodow-bold">账号管理</span></Link></li>
</ul>
{notice_url && <ul className="securityUl ul-border-buttom">
<li>消息通知</li>
@ -153,6 +153,12 @@ function Index(props){
<Password {...props} {...p}/>
)}
></Route>
<Route
path="/settings/phone"
render={(p) => (
<Password {...props} {...p}/>
)}
></Route>
<Route
path="/settings/SSH"
render={(p) => (

View File

@ -52,11 +52,19 @@ export default Form.create()(
return(
<Form layout={'inline'} className="formBase">
<Form.Item label="手机">
{getFieldDecorator("phone",{
rules:[{required:true,message:"请输入邮箱账号"}]
})(
<Input placeholder="请点击右侧更改手机号按钮绑定手机" disabled style={{width:"400px"}}/>
)}
</Form.Item>
<Link className='gotoUpdateEmail mr30' to='/settings/phone'><i className='iconfont icon-bianji1 font-15 mr5'></i>更改手机号</Link>
<Form.Item label="邮箱">
{getFieldDecorator("email",{
rules:[{required:true,message:"请输入邮箱账号"}]
})(
<Input placeholder="请输入您的邮箱账号" disabled style={{width:"400px"}}/>
<Input placeholder="请点击右侧更改邮箱按钮绑定邮箱" disabled style={{width:"400px"}}/>
)}
</Form.Item>
<Link className='gotoUpdateEmail mr30' to='/settings/emails'><i className='iconfont icon-bianji1 font-15 mr5'></i>更改邮箱</Link>

View File

@ -18,6 +18,9 @@ function Index(props){
}else{
setKey("1");
switch(pathname){
case '/settings/phone':
setType('3');
break;
case '/settings/emails':
setType('0');
break;
@ -37,6 +40,7 @@ function Index(props){
{key === "0" ? <Menu mode={'horizontal'} className="infosRightMenu">
<Menu.Item key="0" className="font-16">基本资料</Menu.Item>
</Menu> : <Menu mode={'horizontal'} className="infosRightMenu" selectedKeys={type}>
<Menu.Item key="3" className="font-16" onClick={()=>{props.history.push('/settings/phone')}}>手机号管理</Menu.Item>
<Menu.Item key="0" className="font-16" onClick={()=>{props.history.push('/settings/emails')}}>邮箱管理</Menu.Item>
<Menu.Item key="1" className="font-16" onClick={()=>{props.history.push('/settings/password')}}>密码管理</Menu.Item>
<Menu.Item key="2" className="font-16" onClick={()=>{props.history.push('/settings/cancel')}}>账号注销</Menu.Item>

View File

@ -6,6 +6,7 @@ import Axios from 'axios';
import img1 from '../../Images/personalInfo3.png';
import { setmiyah } from '../../../common/Component';
import { useEffect } from 'react';
import Phone from './Phone';
export default Form.create()(
forwardRef((props)=>{
@ -239,7 +240,8 @@ export default Form.create()(
// type: 0 1 2
return(
<Fragment>
{type === '0' ? <div>
{type === '0' ?
<div>
<div className='tipsBox mb15'><img src={img1} alt="" width={16} className='mr10'/>更改邮箱后您在<span className='spanTil'>GitLink</span> 的登录账号接收通知的邮件地址将同步变更请谨慎更改!</div>
<div className='tipsBox mb20 emailBox'>现邮箱地址<span className='ml10 email spanTil'>{current_user && current_user.email}</span></div>
<div className='updateEmail mb20'>更改邮箱</div>
@ -286,7 +288,9 @@ export default Form.create()(
<Button className={`${passMap.password && passMap.email && passMap.code ? 'but25' : ''}`} type={"primary"} onClick={confirmUpdateEmail} disabled={!(passMap.password && passMap.email && passMap.code)}>确认更改</Button>
</AlignCenter>
</Form>
</div> : type === '1' ? <Form layout={'inline'} className="formBase passMan personalUpdateInfoForm mt30">
</div> :
type === '1' ?
<Form layout={'inline'} className="formBase passMan personalUpdateInfoForm mt30">
<Form.Item label="旧密码" className={`${updatePsdMap.oldPassword ? 'hasSuccess' : ''}`}>
{getFieldDecorator("old_password",{
rules:[
@ -326,17 +330,21 @@ export default Form.create()(
<span className="ant-form-item-label mr10"></span>
<Button className={`${updatePsdMap.oldPassword && updatePsdMap.password && updatePsdMap.password1 ? 'but25' : ''}`} type={"primary"} onClick={submit} disabled={!(updatePsdMap.oldPassword && updatePsdMap.password && updatePsdMap.password1)}>确认更改</Button>
</AlignCenter>
</Form> : <div>
<div className='tipsBox mb15'><img src={img1} alt="" width={16} className='mr10'/>请您谨慎操作注销后帐号内所有数据都会被清空且无法恢复帐号!</div>
<div className='tipCont'>
GitLink目前提供邮件渠道帐号注销服务如需注销帐号请通过发送邮件注销申请邮件到 <span className='orange'>gitlink@ccf.org.cn</span><br/>
相关注意事项如下:<br/>
<span className='oneTipBox mt10'>必须使用要注销的 GitLink 帐号所绑定的邮箱地址发送邮件</span>
<span className='oneTipBox mt5'>发送注销申请邮件之前确认帐号下无创建/加入组织帐号名下无仓库信息</span>
<span className='oneTipBox mt5'>邮件标题: 注销 GitLink 帐号邮件正文请注明要注销帐号的邮箱和昵称</span>
<span className='oneTipBox mt5'>发送邮件后我们会积极处理请耐心等候我们的邮件回复</span>
</Form>
: type === '2' ?
<div>
<div className='tipsBox mb15'><img src={img1} alt="" width={16} className='mr10'/>请您谨慎操作注销后帐号内所有数据都会被清空且无法恢复帐号!</div>
<div className='tipCont'>
GitLink目前提供邮件渠道帐号注销服务如需注销帐号请通过发送邮件注销申请邮件到 <span className='orange'>gitlink@ccf.org.cn</span><br/>
相关注意事项如下:<br/>
<span className='oneTipBox mt10'>必须使用要注销的 GitLink 帐号所绑定的邮箱地址发送邮件</span>
<span className='oneTipBox mt5'>发送注销申请邮件之前确认帐号下无创建/加入组织帐号名下无仓库信息</span>
<span className='oneTipBox mt5'>邮件标题: 注销 GitLink 帐号邮件正文请注明要注销帐号的邮箱和昵称</span>
<span className='oneTipBox mt5'>发送邮件后我们会积极处理请耐心等候我们的邮件回复</span>
</div>
</div>
</div>}
:<Phone {...props}/>
}
<Modals
visible={visible}
onCancel={()=>{setVisible(false)}}

View File

@ -0,0 +1,233 @@
import React , { forwardRef, useState } from 'react';
import { Form , Input , Button, message } from 'antd';
import Modals from '../../Component/PublicModal/Index';
import { AlignCenter } from '../../Component/layout';
import img1 from '../../Images/personalInfo3.png';
import { setmiyah } from '../../../common/Component';
import Axios from 'axios';
export default Form.create()(
forwardRef((props)=>{
const { getFieldDecorator, validateFields, resetFields, getFieldsValue } = props && props.form;
const { current_user, resetUserInfo} = props;
const [ passMap, setPassMap] = useState({logpassword: undefined, phone: undefined, mescode: undefined});
const [ countDown, setCountDown] = useState(undefined);
const [ phoneValue, setphoneValue] = useState(undefined);
const [ visible, setVisible] = useState(false);
//
function checkPsd(rule, value, callback){
const map = passMap;
if(value){
current_user && Axios.post(`/v1/${current_user.login}/check_password.json`,{
password: value
}).then(res=>{
if(res && !res.data.status){
map.logpassword = value;
setPassMap(map);
callback();
}else{
map.logpassword = undefined;
setPassMap(map);
callback(res.data.message);
}
})
}else{
map.logpassword = undefined;
setPassMap(map);
callback();
}
}
//
function checkCode(rule, value, callback){
const map = passMap;
const {phone, logpassword} = getFieldsValue();
if(!phone){
callback("请先输入手机号");
}
if(!logpassword){
callback("请先输入登录密码");
}
if(value){
current_user && value && value.length > 4 && Axios.post(`/v1/${current_user.login}/check_phone_verify_code.json`,{
code_type: 4,
phone: phoneValue,
code: value
}).then(res=>{
if(res && !res.data.status){
map.mescode = value;
setPassMap(map);
callback();
}else{
map.mescode = undefined;
setPassMap(map);
callback(res.data.message);
}
})
}else{
map.mescode = undefined;
setPassMap(map);
callback();
}
}
//
function checkPhone(rule, value, callback){
const map = passMap;
if(value){
if(/^([1][3456789])\d{9}$/.test(value)){
current_user && Axios.get(`/accounts/valid_email_and_phone.json`,{
params: {
login: value,
type: 3
}
}).then(res=>{
if(res && !res.data.status){
map.phone = value;
setPassMap(map);
setphoneValue(value);
callback();
}else{
setphoneValue(undefined);
map.phone = undefined;
setPassMap(map);
callback(res.data.message);
}
})
}else{
map.phone = undefined;
setPassMap(map);
callback("请输入正确的手机号");
}
}else{
setphoneValue(undefined);
map.phone = undefined;
setPassMap(map);
callback();
}
}
//
function getCaptcha() {
// https://testforgeplus.trustie.net/api/accounts/get_verification_code.json
current_user && Axios.get(`/accounts/get_verification_code`,{params: {
type: 3,
login: phoneValue,
smscode: setmiyah(phoneValue)
}}).then(res=>{
if(res && !res.data.status){
message.success('发送成功')
}
})
//
startCountDown();
}
//
function startCountDown(){
let countDownNum = 60;
const timer = setInterval(() => {
countDownNum -= 1;
setCountDown(countDownNum);
if(countDownNum <= -1){
clearInterval(timer);
setCountDown(undefined)
}
}, 1000);
}
function confirmUpdatePhone(){
validateFields((error,values)=>{
if(!error){
setVisible(true);
}
})
}
function updateEmailOrPsd(){
const {mescode, phone, logpassword} = getFieldsValue();
if(mescode && phone && logpassword){
current_user && Axios.patch(`/v1/${current_user.login}/update_phone.json`,{
code:mescode, phone, password:logpassword
}).then(res=>{
if(res && !res.data.status){
setPassMap({logpassword: undefined, phone: undefined, code: undefined});
resetFields();
resetUserInfo();
setVisible(false);
message.success('更新成功');
}else{
setVisible(false);
message.error(res.data.message || '更新失败');
}
})
}
}
return(
<div>
<Modals
visible={visible}
onCancel={()=>{setVisible(false)}}
title={'更改手机号'}
btn={
<div>
<Button size={'large'} onClick={()=>{setVisible(false)}}>取消</Button>
<Button size={"large"} type={"primary"} onClick={updateEmailOrPsd}>确认更改</Button>
</div>
}
>
<div className="desc">
<AlignCenter className="descMain">
<i className="iconfont icon-jinggao1 mr10 font-20 red"></i>确认更改手机号</AlignCenter>
<p>更改手机号后您在GitLink的登录账号将同步变更请再次确认</p>
</div>
</Modals>
<div className='tipsBox mb15'><img src={img1} alt="" width={16} className='mr10'/>更改手机号后您在<span className='spanTil'>GitLink</span> 的登录账号将同步变更请谨慎更改!</div>
{current_user && current_user.phone && <div className='tipsBox mb20 emailBox'>现手机号码<span className='ml10 email spanTil'>{current_user.phone}</span></div> }
<div className='updateEmail mb20'>更改手机号</div>
<Form layout={'inline'} className="formBase passMan personalUpdateInfoForm">
<Form.Item label="登录密码" className={`${passMap.logpassword ? 'hasSuccess' : ''}`}>
{getFieldDecorator("logpassword",{
rules:[
{required:true,message:"请输入登录密码"},
{validator:(rule, value, callback)=>checkPsd(rule, value, callback)}
],
validateTrigger:"onBlur",
})(
<Input.Password placeholder="请输入登录密码" autoComplete={"new-password"} style={{width:"400px"}}/>
)}
</Form.Item>
<Form.Item label="新手机号码" className={`${passMap.phone ? 'hasSuccess' : ''}`}>
{getFieldDecorator("phone",{
rules:[
{required:true,message:"请输入新手机号码"},
{validator:(rule, value, callback)=>checkPhone(rule, value, callback)}
],
validateTrigger:"onBlur",
})(
<Input placeholder="请输入新手机号码" style={{width:"400px"}} autoComplete={"off"}/>
)}
</Form.Item>
<div>
<Form.Item label="短信验证码" className={`${passMap.mescode ? 'hasSuccess' : ''}`}>
{getFieldDecorator("mescode",{
rules:[
{required:true,message:"请输入短信验证码"},
{validator:(rule, value, callback)=>checkCode(rule, value, callback)}
],
validateTrigger:"onBlur",
})(
<Input placeholder="请输入短信验证码" style={{width:"400px"}}/>
)}
</Form.Item>
{countDown ? <Button className='getCaptchaBut ml50' disabled>重发 ({countDown})</Button> : <Button className='getCaptchaBut ml50' onClick={getCaptcha} disabled={!phoneValue}>获取验证码</Button>}
</div>
<AlignCenter style={{marginTop:"20px"}}>
<span className="ant-form-item-label mr10"></span>
<Button onClick={confirmUpdatePhone} className={`${passMap.logpassword && passMap.phone && passMap.mescode ? 'but25' : ''}`} type={"primary"} disabled={!(passMap.logpassword && passMap.phone && passMap.mescode)}>确认更改</Button>
</AlignCenter>
</Form>
</div>
)
})
)