diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index 63324c35f..f335f1705 100644 --- a/public/react/config/webpack.config.dev.js +++ b/public/react/config/webpack.config.dev.js @@ -32,7 +32,7 @@ module.exports = { // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // devtool: "cheap-module-eval-source-map", // 开启调试 - //devtool: "source-map", // 开启调试 + devtool: "source-map", // 开启调试 // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. // The first two entry points enable "hot" CSS and auto-refreshes for JS. @@ -153,8 +153,8 @@ module.exports = { include: paths.appSrc, loader: require.resolve('babel-loader'), options: { - - // This is a feature of `babel-loader` for webpack (not Babel itself). + + // This is a feature of `babel-loader` for webpack (not Babel itself). // It enables caching results in ./node_modules/.cache/babel-loader/ // directory for faster rebuilds. cacheDirectory: true, diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js old mode 100644 new mode 100755 index d5461b627..749cd251d --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js @@ -3,9 +3,10 @@ import { Breadcrumb,Layout,Table, Divider, Tag,Badge,Row, Col,Button, Menu, Icon import { Link } from 'react-router-dom'; import axios from 'axios'; import {markdownToHTML,getImageUrl} from 'educoder'; -import CompetitionContents from './CompetitionContents'; -import CompetitionContentsChart from './CompetitionContentsChart'; -import CompetitionContentsMd from './CompetitionContentsMd'; +import CompetitionContents from './CompetitionCommonChild/CompetitionContents'; +import CompetitionContentsChart from './CompetitionCommonChild/CompetitionContentsChart'; +import CompetitionContentsMd from './CompetitionCommonChild/CompetitionContentsMd'; +import CompetitionContentspdf from './CompetitionCommonChild/CompetitionContentspdf'; import './CompetitionCommon.css'; @@ -15,14 +16,15 @@ class CompetitionCommon extends Component{ constructor(props) { super(props) this.state={ - data:undefined, - bannerdata:undefined, - module_type:undefined, - mdContentdata:undefined, - chart_rules:undefined, - Competitionedittype:false, - chartdata:undefined, - has_url:false + data: undefined, + bannerdata: undefined, + module_type: undefined, + mdContentdata: undefined, + chart_rules: undefined, + Competitionedittype: false, + chartdata: undefined, + has_url: false, + signupdata: undefined } } @@ -52,8 +54,8 @@ class CompetitionCommon extends Component{ axios.get(url).then((response) => { if(response.status===200){ this.setState({ - data:response.data, - thiskeys:menuid===undefined||menuid===""?response.data.competition_modules[0].id:menuid + data: response.data, + thiskeys: menuid === undefined || menuid === "" ? response.data.competition_modules[0].id : menuid }) if(menuid===undefined||menuid===""){ this.getrightdata( @@ -80,27 +82,27 @@ class CompetitionCommon extends Component{ console.log(error) }) - if(this.props.user&&this.props.user.login!= ""){ - const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`; - axios.get((zul)).then((result) => { - if (result) { - if (result.data) { - this.setState({ - signupdata:result.data - }) - } - } - }).catch((error) => { - //console.log(error); - }) - } + if (this.props.user && this.props.user.login != "") { + const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`; + axios.get((zul)).then((result) => { + if (result) { + if (result.data) { + this.setState({ + signupdata: result.data + }) + } + } + }).catch((error) => { + //console.log(error); + }) + } } getrightdatas=(e)=>{ - let keys=parseInt(e.key); - this.getlistdata(keys) - this.props.history.replace(`?menu=${keys}`); + let keys = parseInt(e.key); + this.getlistdata(keys) + this.props.history.replace(`?menu=${keys}`); } getlistdata=(keys,listkey)=>{ @@ -127,7 +129,7 @@ class CompetitionCommon extends Component{ if(response.status===200){ this.setState({ chart_rules:response.data, - tabkey:tabkey===undefined?response.data.stages[0].id===null?"0":`${response.data.stages[0].id}`:tabkey + tabkey: tabkey === undefined ? response.data.stages[0].id === null ? "0" : `${response.data.stages[0].id}` : tabkey }) @@ -142,10 +144,10 @@ class CompetitionCommon extends Component{ // if(typeid==="enroll"){ // this.props.history.replace(`/competitions/${this.props.match.params.identifier}/enroll`); - // return + // return // } - this.getnewchartdata(typeid,listkey) + this.getnewchartdata(typeid, listkey) if(has_url===false){ let url=`${module_url}`; @@ -167,11 +169,11 @@ class CompetitionCommon extends Component{ console.log(error) }) }else{ - if(module_url.substring(0,7)=='http://'||module_url.substring(0,8)=='https://') { + if (module_url.substring(0, 7) == 'http://' || module_url.substring(0, 8) == 'https://') { // window.location.href= module_url - window.open(module_url) + window.open(module_url) }else{ - window.open(`https://${module_url}`) + window.open(`https://${module_url}`) // window.location.href=; } return @@ -186,9 +188,9 @@ class CompetitionCommon extends Component{ } Competitionedit=()=>{ - this.setState({ - Competitionedittype:true - }) + this.setState({ + Competitionedittype: true + }) } hideCompetitionedit=()=>{ @@ -215,10 +217,10 @@ class CompetitionCommon extends Component{ if(data.member_of_course===true){ this.props.history.replace(`/courses/${data.course_id}`); }else{ - // 以学生身份调用加入课堂 进入课堂首页 + // 以学生身份调用加入课堂 进入课堂首页 let url="/courses/apply_to_join_course.json" axios.post(url, { - invite_code:data.invite_code, + invite_code: data.invite_code, student:1 } ).then((response) => { @@ -229,12 +231,46 @@ class CompetitionCommon extends Component{ } } }else{ - this.props.history.replace(url); + + if (url === "personal") { + this.Personalregistration() + } else { + this.props.history.replace(url); + } + + } + } + + + Personalregistration = () => { + + let {signupdata} = this.state; + let urls = `/competitions/${this.props.match.params.identifier}/enroll`; + if (signupdata.enroll_ended === true) { + //已截止 + this.props.showNotification(`报名已截止`); + return; } + if (signupdata.enrolled === true) { + this.props.showNotification(`你已经报名,不能重复报名!`); + return; + } + const url = `/competitions/${this.props.match.params.identifier}/competition_teams.json`; + axios.post(url).then((response) => { + if (response) { + if (response.data) { + this.props.showNotification(`报名成功,预祝您夺得桂冠!`); + this.props.history.replace(urls); + } + } + }).catch((error) => { + + }); } + Competitioncallback=(key)=>{ - this.setState({ + this.setState({ tabkey:key }) let url=`/competitions/${this.props.match.params.identifier}/charts.json`; @@ -252,146 +288,172 @@ class CompetitionCommon extends Component{ } + render() { - let {data,thiskeys,Competitionedittype}=this.state; + let {data, module_type, Competitionedittype, signupdata} = this.state; return ( data===undefined?"":
- - 在线竞赛 - {data&&data.name} - - -
- - - {data.competition_status==="nearly_published"? - data && data.permission.editable === true ? "" : -
即将发布 敬请期待
: ""} - - - + + 在线竞赛 + {data && data.name} + + +
+ + + {data.competition_status === "nearly_published" ? + data && data.permission.editable === true ? "" : +
即将发布 敬请期待
: ""} + + + + + + + 15 ? "competitionbannerdiv mt30" : "competitionbannerdiv mt30"}>{data && data.name} + + + 竞赛时间:{data && data.start_time}~{data && data.end_time} + {/**/} - - - 15?"competitionbannerdiv mt30":"competitionbannerdiv mt30"}>{data&&data.name} - - 竞赛时间:{data&&data.start_time}~{data&&data.end_time} - {/**/} + + + +
奖金
+ +
浏览数
+ + +
报名数
+ +
- - - -
奖金
- - -
浏览数
- - -
报名数
- -
- - - -
¥{data&&data.bonus}
- - -
{data.competition_status==="nearly_published"?"--":data&&data.visits_count}
- - -
this.gotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}>{data.competition_status==="nearly_published"?"--":data&&data.member_count}
- -
+ + +
¥{data && data.bonus}
+ + +
{data.competition_status === "nearly_published" ? "--" : data && data.visits_count}
+ + +
this.gotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}>{data.competition_status === "nearly_published" ? "--" : data && data.member_count}
+
+ - {data.competition_status==="ended"?: : } - - {data.competition_status==="ended"? - :data.enroll_end===true?: - data.competition_status==="progressing"? : data.enroll_end === true ? + : + data.competition_status === "progressing" ? + :""} - - {data&&data.enroll_end_time===null?"":`报名截止时间:${data&&data.enroll_end_time}`} -
-
- - - - this.getrightdatas(e)}> - {data&&data.competition_modules.map((item,key)=>{ - if(item.module_type!="enroll"){ - return( - - {/*{item.has_url===false?this.getrightdata(item.id,item.module_type,item.module_url,item.has_url)}*/} - {/*>{item.name}:this.getrightdata(item.id,item.module_type)}*/} - {/*>{item.name}}*/} - {item.name} - - ) - } - })} - - - - - {this.state.module_type==="chart"?Competitionedittype===false?this.Competitionedit()} - Competitioncallback={(e)=>this.Competitioncallback(e)} - />:"":Competitionedittype===false?this.Competitionedit()} - {...this.props} - {...this.state} - />:""} - {/**/} - {Competitionedittype===true?this.hideCompetitionedit()} - getlistdata={(keys,listkey)=>this.getlistdata(keys,listkey)} - Competitioncallback={(e)=>this.Competitioncallback(e)} - {...this.props} - {...this.state} - />:""} - - - + {data && data.enroll_end_time === null ? "" : `报名截止时间:${data && data.enroll_end_time}`} + +
+
+ + + + this.getrightdatas(e)}> + {data && data.competition_modules.map((item, key) => { + if (item.module_type != "enroll") { + return ( + + {/*{item.has_url===false?this.getrightdata(item.id,item.module_type,item.module_url,item.has_url)}*/} + {/*>{item.name}:this.getrightdata(item.id,item.module_type)}*/} + {/*>{item.name}}*/} + {item.name} + + ) + } + })} + + + {/*this.isdownloadpdf(e)}>*/} + {/**/} + {/*证书下载*/} + {/**/} + {/**/} + + + {module_type === "certificate" ? "" : + {this.state.module_type === "chart" ? Competitionedittype === false ? this.Competitionedit()} + Competitioncallback={(e) => this.Competitioncallback(e)} + /> : "" : Competitionedittype === false ? this.Competitionedit()} + {...this.props} + {...this.state} + /> : ""} + {/**/} + {Competitionedittype === true ? this.hideCompetitionedit()} + getlistdata={(keys, listkey) => this.getlistdata(keys, listkey)} + Competitioncallback={(e) => this.Competitioncallback(e)} + {...this.props} + {...this.state} + /> : ""} + } + + {module_type === "certificate" ? + + : ""} +
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionContents.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContents.js similarity index 100% rename from public/react/src/modules/competitions/Competitioncommon/CompetitionContents.js rename to public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContents.js diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsChart.js similarity index 100% rename from public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js rename to public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsChart.js diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js similarity index 98% rename from public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js rename to public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js index aae9283c4..049f2bab1 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import {Button, Card, Row, Col ,Upload,Icon,message,Tabs} from 'antd'; import axios from 'axios'; import {getImageUrl,getUrl,appendFileSizeToUploadFileAll,appendFileSizeToUploadFile} from 'educoder'; -import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; +import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'; const { TabPane } = Tabs; class CompetitionContentsMd extends Component{ constructor(props) { diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdf.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdf.js new file mode 100644 index 000000000..0109d3d01 --- /dev/null +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdf.js @@ -0,0 +1,59 @@ +import React, {Component} from 'react'; +import {Tabs} from 'antd'; +import axios from 'axios'; +import {markdownToHTML, getImageUrl, AttachmentList} from 'educoder'; +import CompetitionContentspdfdownload from './CompetitionContentspdfChild/CompetitionContentspdfdownload'; +import CompetitionContentspdfpeopledata from './CompetitionContentspdfChild/CompetitionContentspdfpeopledata'; +// import NoneData from "../../../courses/shixunHomework/shixunHomework"; + +const {TabPane} = Tabs; + +class CompetitionContentspdf extends Component { + constructor(props) { + super(props) + this.state = { + Tabskey: "1" + } + } + + componentDidMount() { + window.document.title = '竞赛'; + + } + + Competitioncallback = (key) => { + this.setState({ + Tabskey: key + }) + } + + render() { + + + return ( + +
+
+ this.Competitioncallback(e)} activeKey={this.state.Tabskey}> + + this.Competitioncallback(e)} + /> + + + + + +
+
+ + ) + } +} + +export default CompetitionContentspdf; diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.css b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.css new file mode 100644 index 000000000..726a02277 --- /dev/null +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.css @@ -0,0 +1,24 @@ +.pdfdownload { + max-width: 791px; + height: 40px; + background: rgba(249, 249, 249, 1); + line-height: 40px; + padding-left: 15px; +} + +.pdfpicture { + font-size: 16px; + color: rgba(0, 0, 0, 1); +} + +.pdfdownloadfont4CACFF { + color: #4CACFF !important; +} + +.pdfdownloadfont00CC5F { + color: #00CC5F; +} + +.pdfdownloadfontFF6602 { + color: #FF6602; +} diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js new file mode 100644 index 000000000..760dca819 --- /dev/null +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js @@ -0,0 +1,216 @@ +import React, {Component} from 'react'; +import {Button, Layout, Row, Col, Divider, Table} from 'antd'; +import axios from 'axios'; +import {getImageUrl} from 'educoder'; +import './CompetitionContentspdfdownload.css'; + +// import NoneData from "../../../courses/shixunHomework/shixunHomework"; + + +class CompetitionContentspdfdownload extends Component { + constructor(props) { + super(props) + this.state = { + data: undefined, + teams: undefined + } + } + + componentDidMount() { + window.document.title = '竞赛'; + let url = `/competitions/${this.props.match.params.identifier}/prize.json`; + axios.get(url).then((response) => { + if (response.status === 200) { + + let datas = response.data.teams; + if (datas.length > 0) { + datas.map((item, key) => { + let lista = item.team_members; + if (lista.length > 0) { + console.log(lista) + lista.map((i, k) => { + i["bank_account"] = item.bank_account; + }) + } + }) + } + + this.setState({ + data: response.data, + teams: datas, + }) + } + }).catch((error) => { + console.log(error) + }) + } + + render() { + + + let {data, teams} = this.state; + + const columns = [ + { + title: '角色', + dataIndex: 'type', + key: 'type', + render: (text, record) => ( + + {record.role} + + ), + }, + { + title: '姓名', + dataIndex: 'name', + key: 'name', + render: (text, record) => ( + + {record.name} + + ), + }, + { + title: '实名认证', + dataIndex: 'namecertify', + key: 'namecertify', + render: (text, record) => ( + + {record.real_name_auth === "authed" ? + 已认证 : record.real_name_auth === "authing" ? + 待审核 : record.real_name_auth === "not_authed" ? + 未认证 : ""} + + ), + }, + { + title: '职业认证', + key: 'certify', + dataIndex: 'certify', + render: (text, record) => ( + + {record.professional_auth === "authed" ? + 已认证 : record.real_name_auth === "authing" ? + 待审核 : record.real_name_auth === "not_authed" ? + 未认证 : ""} + + ), + }, + { + title: '手机绑定', + key: 'mobile', + dataIndex: 'mobile', + render: (text, record) => ( + + {record.phone_binded === true ? 已绑定 : + 未绑定} + + ), + }, + { + title: '邮箱绑定', + key: 'mail', + dataIndex: 'mail', + render: (text, record) => ( + + {record.email_binded === true ? 已绑定 : + 未绑定} + + ), + }, + { + title: '开户行及银行卡号信息(队长填写)', + key: 'idcard', + dataIndex: 'idcard', + render: (value, record, index) => { + if (index === 0 && record.bank_account != null) { + return { + children: + {record.bank_account.bank + record.bank_account.second_bank + record.bank_account.card_no}, + }; + } + + }, + }, + ]; + + + let people = [{url: '/api/competitions/xxxxx/certificates/1/personal'}, + {url: '/api/competitions/xxxxx/certificates/2/personal'},] + return ( + + + 温馨提示:填写的个人信息经审批后,将提供个人获奖证书下载;团队队员信息全部审批后,将提供团队获奖证书下载。 + + + + 证书情况 + + + + 个人证书: {data && data.personal_certifications.length === 0 ? + 暂未生成 原因:还未认证个人信息, this.props.Competitioncallback("2")}>立即查看 : + data && data.personal_certifications.map((item, key) => { + return ( + + + 立即下载 + + ) + })} + + + + 团队证书: + {data && data.team_certifications.length === 0 ? 暂未生成 + : data && data.team_certifications.map((item, key) => { + return ( + + + 立即下载 + + ) + })} + + + + + {teams && teams.map((item, key) => { + return ( + + {item.name}战队信息填报概况 + + + + ) + }) + } + + + + ) + } +} + +export default CompetitionContentspdfdownload; diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfpeopledata.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfpeopledata.js new file mode 100644 index 000000000..3585f5b81 --- /dev/null +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfpeopledata.js @@ -0,0 +1,848 @@ +import React, {Component} from 'react'; +import {Button, Layout, Input, Form} from 'antd'; +import axios from 'axios'; +import {getImageUrl} from 'educoder'; +import mycompetotionchild from './mycompetotionchild.css'; +import {getHiddenName} from "../../../../user/account/AccountBasicEdit"; +import '../../../../courses/css/Courses.css' +import RealNameCertificationModal from "../../../../user/modal/RealNameCertificationModal"; + +export const identityMap = {"teacher": "教师", "student": "学生", "professional": "专业人士"} + +class CompetitionContentspdfpeopledata extends Component { + constructor(props) { + super(props) + this.state = { + basicInfo: {}, + updating: '', + secondsFlag: false, + seconds: 60, + phonebool: false, + emailbool: false, + formationdata: [], + bank_account_editable: false, + leader: false, + bank_account: undefined, + certification: 1 + } + } + + componentDidMount() { + window.document.title = '竞赛'; + console.log("获取用户信息"); + console.log(this.props); + this.getdata(); + this.GetawardinformationAPI(); + } + + GetawardinformationAPI = () => { + let url = `/competitions/${this.props.match.params.identifier}/prize.json`; + axios.get(url).then((result) => { + if (result.data) { + this.setState({ + formationdata: result.data.formationdata, + bank_account_editable: result.data.bank_account_editable, //队长是否可以编辑 + leader: result.data.leader, //是否是队长 + bank_account: result.data.bank_account, //队长银行卡号信息 + }) + } + }).catch((error) => { + console.log(error); + }) + } + + + getdata = () => { + this.setState({ + certification: 3 + }) + let url = `/users/accounts/${this.props.current_user.login}.json`; + axios.get(url).then((result) => { + if (result.data) { + 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}`, + gender: result.data.gender == null || result.data.gender == undefined ? 0 : result.data.gender + }), + certification: 3 + }) + } + }).catch((error) => { + console.log(error); + }) + }; + // 绑定手机 + onPhoneSubmit = () => { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + let {login} = this.props.current_user; + let reg = /^1\d{10}$/; + if (reg.test(values.phone)) { + let url = `/users/accounts/${login}/phone_bind.json` + axios.post((url), { + phone: values.phone, + code: values.phoneValidateCode + }).then((result) => { + if (result) { + this.props.showNotification("手机号码绑定成功!"); + this.setState({ + phonebool: false + }) + this.getdata(); + } + }).catch((error) => { + console.log(error); + }) + } else { + this.props.showNotification("请输入有效的11位手机号码"); + } + } + }) + } + // 绑定邮箱 + onEmailSubmit = () => { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + let {login} = this.props.current_user; + let reg = /^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/; + if (reg.test(values.email)) { + let url = `/users/accounts/${login}/email_bind.json` + axios.post((url), { + email: values.email, + code: values.emailValidateCode + }).then((result) => { + if (result) { + this.props.showNotification("邮箱地址绑定成功!"); + this.setState({ + updating: '' + }) + this.getdata(); + } + }).catch((error) => { + console.log(error); + }) + } else { + this.props.showNotification("请输入正确的邮箱地址"); + } + } + }) + } + //取消编辑 + hideUpdating = (i) => { + if (i === 1) { + this.setState({ + phonebool: false + }) + } else if (i === 2) { + this.setState({ + emailbool: false + }) + + } else if (i === 3) { + + } + + } + + // 获取验证码 + getCode = (index) => { + let url = `/accounts/get_verification_code.json` + let login = ''; + let values = this.props.form.getFieldsValue(); + if (index == 3) { + //绑定手机号码 + login = values.phone; + let reg = /^1\d{10}$/; + if (reg.test(login) == false) { + this.props.showNotification(`请先输入正确的手机号码`); + return; + } + } else if (index == 4) { + // 绑定邮箱 + login = values.email; + let reg = /^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/; + if (reg.test(login) == false) { + this.props.showNotification(`请先输入正确的邮箱地址`); + return; + } + } + let type = index; + if (!login) { + this.props.showNotification(`请先输入${index == 3 ? "手机号码" : "邮箱地址"}`); + return; + } + axios.get((url), { + params: { + login, type + } + }).then((result) => { + if (result) { + // 倒计时 + this.setState({ + secondsFlag: true + }) + this.remainTime(); + } + }).catch((error) => { + console.log(error); + }) + } + + // 获取验证码倒计时 + remainTime = () => { + this.setState({ + seconds: 60 + }) + this.timer = setInterval(() => { + let {seconds} = this.state; + let s = parseInt(seconds) - 1; + if (s > -1) { + this.setState({ + seconds: s + }) + } else { + this.setState({ + secondsFlag: false + }) + clearInterval(this.timer); + } + }, 1000) + } + + phonebools = () => { + this.setState({ + phonebool: true + }) + } + + emailbools = () => { + console.log("点击了邮箱"); + this.setState({ + emailbool: true + }) + } + + //立即认证 + checkBasicInfo = (index) => { + if (this.state.basicInfo.base_info_completed == true) { + this.showRealNameCertificationModal(index) + } else { + try { + this.props.confirm({ + okText: `立即完善`, + content: `请先完善基本信息`, + onOk: () => { + this.props.history.push('/account/profile/edit') + } + }) + } catch (e) { + this.props.history.push(`/account/profile/edit`); + + } + } + + } + showRealNameCertificationModal = (index) => { + this.setState({ + certification: index, + }, () => { + if (index == 1) { + this.realNameCertificationModal1.setVisible(true) + } else if (index == 2) { + this.realNameCertificationModal2.setVisible(true) + } + }) + } + //绑定银行确认 + yhBankstrue = () => { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + let url = `/competitions/${this.props.match.params.identifier}/prize_leader_account.json`; + axios.patch(url, { + bank: values.openingbank, + second_bank: values.subbranchs, + card_no: values.subbranch + }) + .then((result) => { + try { + if (result.data.status == 0) { + // console.log(JSON.stringify(result)); + this.props.showNotification(`提交成功成功`); + this.getdata(); + this.GetawardinformationAPI(); + } + } catch (e) { + + } + + }).catch((error) => { + console.log(error); + }) + } + }) + + } + + //取消认证弹框 + onCancel = () => { + this.getdata(); + + } + + + //撤销认证 + Cancellationofapplication = (index) => { + let url = "" + if (index === 1) { + url = `/users/accounts/${this.props.user.user_id}/authentication_apply.json`; + } else if (index === 2) { + url = `/users/accounts/${this.props.user.user_id}/professional_auth_apply.json`; + } + axios.delete(url) + .then((response) => { + try { + if (response.data.status == 0) { + if (index === 1) { + this.props.showNotification('撤销实名认证成功') + } else if (index === 2) { + this.props.showNotification('撤销职业认证成功') + } + this.getdata(); + + } + } catch (e) { + + } + + }) + .catch(function (error) { + console.log(error); + }); + + } + + + render() { + const {getFieldDecorator} = this.props.form; + const {updating, seconds, secondsFlag, basicInfo, phonebool, emailbool, certification, formationdata, bank_account_editable, leader, bank_account} = this.state + console.log(emailbool); + return ( +
+ {this.state.certification === 1 ? + this.realNameCertificationModal1 = form} + certification={certification} + Getdata={() => this.getdata()} + onCancel={() => this.onCancel()} + > : ""} + + {this.state.certification === 2 ? + this.realNameCertificationModal2 = form} + certification={certification} + Getdata={() => this.getdata()} + onCancel={() => this.onCancel()} + + > : ""} +
+

*实名信息 +

+ {basicInfo && basicInfo.authentication == "uncertified" ? +

通过实名认证后才能获得证书

: "" + } + {basicInfo && basicInfo.authentication == "uncertified" ? +

this.checkBasicInfo(1)}>立即认证

: "" + } + +
+
+

姓名:

+

{basicInfo && basicInfo.name} + + { + basicInfo && basicInfo.authentication == "uncertified" ? "" : + basicInfo && basicInfo.authentication == "applying" ? +

待审核!

this.Cancellationofapplication(1)}>撤销认证

+ : +

+

已认证

+

+ } +

+
+ +
+

性别:

+

{basicInfo && basicInfo.gender == 0 ? "男" : "女"}

+
+ +
+

*职业信息 +

+ { + basicInfo && basicInfo.professional_certification == "uncertified" ? +

通过职业认证后才能获得证书

+ + : ""} + { + basicInfo && basicInfo.professional_certification == "uncertified" ? +

this.checkBasicInfo(2)}>立即认证

+ + : ""} +
+ +
+

职业:

+

{basicInfo && basicInfo.identity && identityMap[basicInfo.identity]} + { + basicInfo && basicInfo.professional_certification == "uncertified" ? + "" : + basicInfo && basicInfo.professional_certification == "applying" ? +

+

待审核!

this.Cancellationofapplication(2)}>撤销认证

+

+ : +

+

已认证

+

this.checkBasicInfo(2)}>重新认证

+ +

+ } +

+
+
+

职称:

+

{basicInfo && basicInfo.technical_title}

+
+
+

学校:

+

{basicInfo && basicInfo.school_name}

+
+
+

院系:

+

{basicInfo && basicInfo.department_name}

+
+
+

*联系方式 +

+
+
+

手机号:

+ { + basicInfo && basicInfo.phone ? +

{basicInfo && basicInfo.phone}

+ : +

未绑定

+ } +

this.phonebools()}>{basicInfo && basicInfo.phone ? (phonebool === false ? "更换" : "") : (phonebool === false ? "立即绑定" : "")}

+
+ {/*手机号绑定*/} + { + phonebool === true ? +
+ +
+ + + {getFieldDecorator('phone', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: `请输入要${basicInfo.phone ? '更换' : '绑定'}的手机号码`, + }], + })( + + )} + + + + {getFieldDecorator('phoneValidateCode', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: '请输入手机获取的验证码', + }], + })( + + )} + + + +
+ + +
+
+
+
+ : "" + } + + +
+

Email:

+

{basicInfo && basicInfo.mail}

+

this.emailbools()}>{basicInfo && basicInfo.mail ? (emailbool === false ? "更换" : "") : (emailbool === false ? "立即绑定" : "")}

+
+ { + emailbool === false ? "" : +
+ +
+ + + {getFieldDecorator('email', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: basicInfo && basicInfo.mail ? '请输入要更换的新邮箱地址' : '请输入邮箱地址', + }], + })( + + )} + + + + {getFieldDecorator('emailValidateCode', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: '请输入邮箱收到的验证码', + }], + })( + + )} + + + +
+ + +
+
+
+
+ } + { + leader === true ? +
+ { + bank_account_editable === true ? +
+
+

签/领/开户行及银行卡号

+

为保障奖金的及时发放,请队长如实填写你名下的银行卡信息

+
+
+ +
+ + + {getFieldDecorator('openingbank', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: '请输入开户行', + }], + })( + + )} + + + + {getFieldDecorator('subbranch', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: '请输入支行', + }], + })( + + )} + + + + {getFieldDecorator('subbranchs', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: '请输入账号', + }], + })( + + )} + + +
+

+
+ {/*
this.yhBanksfalse()}>

取消

*/} + +
+
+
+
+ +
+
+ + : +
+
+

签/领/开户行及银行卡号

+

为保障奖金的及时发放,请队长如实填写你名下的银行卡信息

+
+ { + bank_account && bank_account ? +
+
+

开户行:

+

{bank_account && bank_account.bank}

+
+
+

支行:

+

{bank_account && bank_account.second_bank}

+
+
+

账号:

+

{bank_account && bank_account.card_no}

+
+
+ : + "" + } + +
+ } + +
+ : "" + } + + +
+ ) + } +} + +const CompetitionContentspdfpeopledatas = Form.create({name: 'CompetitionContentspdfpeopledata'})(CompetitionContentspdfpeopledata); + +export default CompetitionContentspdfpeopledatas; + diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/mycompetotionchild.css b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/mycompetotionchild.css new file mode 100644 index 000000000..fd85606e0 --- /dev/null +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/mycompetotionchild.css @@ -0,0 +1,314 @@ +/*垂直布局 + + 一 + 二 + 三 +*/ +.flexdirectionjust { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + + +.directstwebkitflex { + display: flex; + display: -webkit-flex; + flex-direction: column; + align-items: center; +} + +.diredisplayitflex { + display: flex; + display: -webkit-flex; + align-items: center; +} + +/*垂直布局*/ +/*靠左侧 +一 二 三 四 五 六 七 八 +*/ +.flexdirection { + display: flex; + flex-direction: row; +} + +.flexdirections { + display: flex; + flex-direction: initial; +} + +/*靠左侧 +*/ + + +/*靠右侧八 七 六 五 四 三 二 一*/ +.flexdirectionss { + display: flex; + flex-direction: row-reverse; +} + + +/*垂直布局 +一 +二 +三 +四 +*/ +.flexdidirectionss { + display: flex; + flex-direction: column; +} + +/*垂直布局 +四 +三 +二 +一 +*/ +.flexdidireverses { + display: flex; + flex-direction: column-reverse; +} + +.fontcolorsysl { + color: #FF0000 +} + +.fontcolorsyslhei { + color: #000000 +} + +.fontcolorsyslhui { + color: #888888 +} + +.fontcolorsyslhui1 { + color: #666666; +} + +.fontcolorsysllan { + color: #4CACFF +} + +.fontcolorsysljin { + color: #DD7600 +} + +.w200 { + width: 200px; +} + +.w64 { + width: 64px; +} + +.w60 { + width: 60px; +} + +.w98 { + width: 98px; +} + +.myysllineheight { + line-height: 40px; +} + +.myyslminwidth { + min-width: 60px; +} + +.myyslminwidth276 { + width: 276px; +} + +.buttongo { + background: #E7E7E7; + border: 1px solid #E7E7E7; + width: 60px; + height: 30px; + border-radius: 4px; + color: #999999; + font-size: 16px; +} + +.buttongo2 { + background: #4CACFF; + border: 1px solid #4CACFF; + width: 64px; + height: 32px; + border-radius: 4px; + color: #FFFFFF; + font-size: 16px; +} + +.fontwenzi { + text-align: center; + line-height: 30px; +} + +.mt17 { + margin-top: 17px; +} + +.mt36 { + margin-top: 36px; +} + +.mt23 { + margin-top: 23px; +} + +.mt19 { + margin-top: 19px; +} + +.mt23 { + margin-top: 23px; +} + +.mt34 { + margin-top: 34px; +} + +.ml11 { + margin-left: 11px; +} + +.ml38 { + margin-left: 38px; +} + +.ml7 { + margin-left: 7px; +} + +.colorgreenlight { + color: #6EC76E +} + +.colorgreenorg { + color: #FF7300; +} + +.borcolors { + border: 1px solid #4CACFF; + + text-align: center; +} + +.mycompitcursor { + cursor: pointer; +} + +.basicForm { + background: #fff; + padding: 30px; + margin-bottom: 10px; + box-sizing: border-box; + width: 100%; + min-height: 390px; +} + +.basicForm .title { + font-size: 16px; + padding-left: 30px; + margin-bottom: 10px; +} + +.flexTable { + display: flex; + flex-direction: column; +} + +.flexRow { + display: flex; +} + +.mb15 { + margin-bottom: 15px !important; +} + +/* BUTTOn */ +.ant-btn { + border-radius: 2px; +} + +button.ant-btn.ant-btn-primary.grayBtn { + background: #CBCBCB; + border-color: #CBCBCB; +} + +.borderBottom { + border-bottom: 1px solid #4CACFF; +} + +/* form ---------------- START */ +.formItemInline { + display: flex; +} + +.formItemInline .ant-form-item-control-wrapper { + display: inline-block; +} + +.hideRequireTag .ant-form-item-required:before { + display: none; +} + + +/* .basicForm .ant-form-item-label { + width: 100px; + padding-right: 10px; +} + .basicForm .ant-form-item-label label { + color: #979797 + } */ + + +.courseNormalForm .ant-select-show-search { + height: 40px; +} + +.courseNormalForm .ant-select-auto-complete.ant-select .ant-input { + height: 40px; +} + +.courseNormalForm .ant-select-search__field__mirror { + height: 40px; +} + +.courseNormalForm .ant-input-lg { + height: 40px; +} + +.courseNormalForm .ant-select-selection--single { + height: 40px; +} + +.courseNormalForm .ant-select-auto-complete.ant-select .ant-select-selection--single { + height: 40px +} + +.courseNormalForm .ant-input-affix-wrapper { + height: 40px; +} + +/* 职业 */ +.courseNormalForm .ant-select-selection-selected-value { + line-height: 38px +} + +.courseNormalForm input { + height: 40px; +} + +.w300 { + width: 300px; +} + +.w56 { + width: 56px; +} diff --git a/public/react/src/modules/user/account/AccountBasicEdit.js b/public/react/src/modules/user/account/AccountBasicEdit.js index 1f87454a5..033f433b0 100644 --- a/public/react/src/modules/user/account/AccountBasicEdit.js +++ b/public/react/src/modules/user/account/AccountBasicEdit.js @@ -4,6 +4,7 @@ import { SnackbarHOC, getImageUrl, City, ConditionToolTip } from 'educoder'; import { Form, Button, Input, Radio, Select, Tooltip, Icon, AutoComplete } 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; @@ -282,7 +283,9 @@ class AccountBasic extends Component { getDepartments=(e,flag)=>{ let arr=this.state.schoolList.filter(function(item){ - return item.name == e; + if(item.name.indexOf(e) > -1){ + return item.name; + } }); if (!arr[0]) { if (!e) { @@ -354,20 +357,7 @@ class AccountBasic extends Component { }) } - // 切换职称 - changeJob=(e)=>{ - - this.setState({ - identity:e - }) - 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:"企业管理者", - }) - } - } + addOrgSuccess = (name) => { // const schoolList = this.state.schoolList.slice(0) @@ -407,6 +397,19 @@ class AccountBasic extends Component { } callback(`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`); } + // 切换职称 + changeJob=(e)=>{ + this.setState({ + identity:e + }) + 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:"企业管理者", + }) + } + } render() { let{ @@ -422,10 +425,17 @@ class AccountBasic extends Component { }=this.state; const { getFieldDecorator } = this.props.form; let{ basicInfo }=this.props - - // 已职业认证的账户不能修改职业,学校/单位,院系/部门,产品还未确定,先默认为false--可以更改 - // basicInfo && basicInfo.professional_certification == "certified" - const professionalFlag = false; + let common = { + 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" ; // form合并了 const propsWithoutForm = Object.assign({}, this.props) @@ -599,177 +609,22 @@ class AccountBasic extends Component { )} -
- - {getFieldDecorator('job', { - rules: [{ - initialValue:"teacher", - required: true, - message: '请先选择职业', - }], - })( - - )} - - { - identity && identity=="student" && - - {getFieldDecorator('student_No', { - rules: [{ - required: true, - message: '请先输入学号', - }], - })( - - )} - - } - { - identity && identity=="teacher" && - - {getFieldDecorator('job1', { - rules: [{ - initialValue:"教授", - required: true, - message: '请先选择职称', - }], - })( - - )} - - } - { - identity && identity=="professional" && - - {getFieldDecorator('job2', { - rules: [{ - initialValue:"企业管理者", - required: true, - message: '请先选择职称', - }], - })( - - )} - - } -
- - - {getFieldDecorator('org', { - rules: [{ - // initialValue: this.state.cityDefaultValue, - // type: 'array', - required: true, - message: '请先选择学校/单位', - - // 做不了,输入时和submit时都会执行这里 - // validator: (rule, value, callback) => { - // if (this.this_school_id) { - // callback(); - // return; - // } - // callback('请先选择学校/单位'); - // } - - }], - })( - - { - filterSchoolList && filterSchoolList.map((item,key)=>{ - return() - }) - } - - )} - - - {!filterSchoolList || (filterSchoolList && filterSchoolList.length==0 )&& school && -
- - 未找到包含“{school}”的高校, - 申请新增 - -
- } - - {getFieldDecorator('org2', { - rules: [{ - // initialValue: this.state.cityDefaultValue, - // type: 'array', - required: true, - message: '请先选择院系/部门', - // validator: (rule, value, callback) => { - // if (this.this_department_id) { - // callback(); - // return; - // } - // callback('请先选择院系/部门'); - // } - }], - })( - - { - filterDepartments && filterDepartments.map((item,key)=>{ - return( - - ) - }) - } - - )} - - - { - filterDepartments != undefined && ( (filterDepartments && filterDepartments.length==0 ) - || (departmentsName == '' && !this.state.department_id - && (!departments || departments.length == 0) )) && -
- - {departmentsName ? `未找到包含“${departmentsName}”的院系/部门` : '未找到院系'}, - 申请新增 - -
- } - - + {/* htmlType="submit" */} {/*
*/} diff --git a/public/react/src/modules/user/account/AccountBasicEditItem.js b/public/react/src/modules/user/account/AccountBasicEditItem.js new file mode 100644 index 000000000..28988ebf3 --- /dev/null +++ b/public/react/src/modules/user/account/AccountBasicEditItem.js @@ -0,0 +1,199 @@ +import React, { Component } from 'react'; + +import { SnackbarHOC, getImageUrl, City, ConditionToolTip } from 'educoder'; +import { Form, Button, Input, Radio, Select, Tooltip, Icon, AutoComplete } from 'antd' +const RadioGroup = Radio.Group; +const Option = Select.Option; +class AccpimtBasicEditItem extends Component { + constructor(props){ + super(props); + } + + render(){ + let { + professionalFlag , + getFieldDecorator , + identity , + filterSchoolList , + filterDepartments, + departmentsName, + school, + departments, + department_id + } = this.props + return( +
+
+ + {getFieldDecorator('job', { + rules: [{ + initialValue:"teacher", + required: true, + message: '请先选择职业', + }], + })( + + )} + + { + identity && identity=="student" && + + {getFieldDecorator('student_No', { + rules: [{ + required: true, + message: '请先输入学号', + }], + })( + + )} + + } + { + identity && identity=="teacher" && + + {getFieldDecorator('job1', { + rules: [{ + initialValue:"教授", + required: true, + message: '请先选择职称', + }], + })( + + )} + + } + { + identity && identity=="professional" && + + {getFieldDecorator('job2', { + rules: [{ + initialValue:"企业管理者", + required: true, + message: '请先选择职称', + }], + })( + + )} + + } +
+ + {getFieldDecorator('org', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + // type: 'array', + required: true, + message: '请先选择学校/单位', + + // 做不了,输入时和submit时都会执行这里 + // validator: (rule, value, callback) => { + // if (this.this_school_id) { + // callback(); + // return; + // } + // callback('请先选择学校/单位'); + // } + + }], + })( + + { + filterSchoolList && filterSchoolList.map((item,key)=>{ + return() + }) + } + + )} + + + {!filterSchoolList || (filterSchoolList && filterSchoolList.length==0 )&& school && +
+ + 未找到包含“{school}”的高校, + 申请新增 + +
+ } + + + {getFieldDecorator('org2', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + // type: 'array', + required: true, + message: '请先选择院系/部门', + // validator: (rule, value, callback) => { + // if (this.this_department_id) { + // callback(); + // return; + // } + // callback('请先选择院系/部门'); + // } + }], + })( + + { + filterDepartments && filterDepartments.map((item,key)=>{ + return( + + ) + }) + } + + )} + + + { + filterDepartments != undefined && ( (filterDepartments && filterDepartments.length==0 ) + || (departmentsName == '' && ! department_id + && (!departments || departments.length == 0) )) && +
+ + {departmentsName ? `未找到包含“${departmentsName}”的院系/部门` : '未找到院系'}, + 申请新增 + +
+ } +
+ ) + } +} +export default AccpimtBasicEditItem; \ No newline at end of file diff --git a/public/react/src/modules/user/modal/RealNameCertificationModal.js b/public/react/src/modules/user/modal/RealNameCertificationModal.js index 9af082fea..b3bbdf319 100644 --- a/public/react/src/modules/user/modal/RealNameCertificationModal.js +++ b/public/react/src/modules/user/modal/RealNameCertificationModal.js @@ -1,330 +1,753 @@ -import React, { Component } from "react"; -import { message, Icon, Input, Form, Upload} from "antd"; -import axios from 'axios' -import ModalWrapper from "../../courses/common/ModalWrapper" -import { City, getUploadActionUrl, getImageUrl, ImageLayer2, getUploadActionUrlOfAuth } from 'educoder' -import '../account/common.css' - -import authImg from '../../../images/account/auth.png' -import jobImg from '../../../images/account/job.png' - -const { TextArea } = Input; -const Dragger = Upload.Dragger; -function getBase64(img, callback) { - const reader = new FileReader(); - reader.addEventListener('load', () => callback(reader.result)); - reader.readAsDataURL(img); -} -function beforeUpload(file) { - const isJPG = file.type === 'image/jpeg'; - if (!isJPG) { - message.error('You can only upload JPG file!'); - } - const isLt2M = file.size / 1024 / 1024 < 2; - if (!isLt2M) { - message.error('Image must smaller than 2MB!'); - } - return isJPG && isLt2M; -} -class RealNameCertificationModal extends Component{ - constructor(props){ - super(props); - this.state={ - } - } - - componentDidMount() { - - } - setVisible = (visible) => { - this.refs.modalWrapper.setVisible(visible) - } - - onSendOk = () => { - this.props.form.validateFieldsAndScroll((err, values) => { - console.log(values); - if(!err){ - let{imageUrl2}=this.state; - let{current_user,basicInfo}=this.props; - if(imageUrl2){ - let { certification } = this.props; - if(certification == 1){ - // 实名认证 - let url = `/users/accounts/${current_user && current_user.login}/authentication_apply.json` - axios.post((url),{ - name:basicInfo.name, - id_number:values.credentials - }).then((result)=>{ - if(result){ - this.props.showNotification("申请已提交,请等待审核!"); - this.props.getBasicInfo(); - this.setVisible(false); - } - }).catch((error)=>{ - console.log(error); - }) - }else{ - // 职业认证 - let url = `/users/accounts/${current_user && current_user.login}/professional_auth_apply.json` - axios.post((url),{ - school_id:basicInfo && basicInfo.school_id, - department_id:basicInfo && basicInfo.department_id, - identity:basicInfo && basicInfo.identity, - extra:basicInfo && basicInfo.identity == "student" ? basicInfo.student_id:basicInfo.technical_title - }).then((result)=>{ - if(result){ - this.props.showNotification("申请已提交,请等待审核!"); - this.props.getBasicInfo(); - this.setVisible(false); - } - }).catch((error)=>{ - console.log(error); - }) - } - }else{ - this.props.showNotification("请先上传照片!"); - } - } - }) - } - - onOk = () => { - const { course_lists, checkBoxValues } = this.state - this.onSendOk() - } - - handleChange = (info) => { - if (info.file.status === 'uploading') { - this.setState({ loading: true }); - return; - } - if (info.file.status === 'done') { - // Get this url from response in real world. - getBase64(info.file.originFileObj, imageUrl => this.setState({ - imageUrl, - loading: false, - })); - } - } - handleChange2 = (info) => { - if (info.file.status === 'uploading') { - this.setState({ loading: true }); - return; - } - if (info.file.status === 'done') { - // Get this url from response in real world. - getBase64(info.file.originFileObj, imageUrl2 => this.setState({ - imageUrl2, - loading: false, - })); - } - } - - render(){ - const { course_lists, checkBoxValues, searchValue, loading, imageUrl, imageUrl2 } = this.state - const { moduleName } = this.props - const { getFieldDecorator } = this.props.form; - let {certification}=this.props; - // /api/users/accounts/${this.props.current_user.login}/auth_attachment.json - const uploadProps2 = { - name: 'image', - data:{type:certification == 1 ? "real_name" : "professional"}, - multiple: true, - showUploadList: false, - // https://newweb.educoder.net - action: this.props.current_user ? `${getUploadActionUrlOfAuth(this.props.current_user.login)}` : '', - className: 'idPic-uploader', - onChange: this.handleChange2, - }; - return( - 实名认证: - 职业认证 - } - {...this.props } - onOk={this.onOk} - okText="保存" - className="applyForModal certificationModal courseNormalForm" - bottomRender={ - certification && certification == 1? -
-

认证须知:

-

- 1.你需要准备有效的身份证正面(人像面)的证件照照片,请确保证件照片清晰可见,严禁PS; -

- 2.我们将在你提交认证信息后的24小时(不包含节假日)内完成审核,审核结果将会以系统消息的形式发送给你; -

- 3.实名认证审核完成后,无法删除,请谨慎填写; -

- 4.实名认证审核完成后,系统将自动发放500个金币作为奖励; -

- 5.我们会确保你所提供的信息均处于严格的保密状态,不会泄露; -

- 6.如存在恶意乱填写姓名,证件号,及上传与实名认证证件无关图片者,一经发现将冻结EduCoder账号。 -

-
: -
-

认证须知:

-

- 1.根据职业上传相应的证件照:教师(教师证),专业人士(员工证)、学生(学生证),请确保证件照内容完整并且清晰可见,严禁PS; -

- 2.我们将在你提交职业证信息后的24小时(不包含节假日)内完成审核,审核结果将会以系统消息的形式发送给你; -

- 3.职业认证审核完成后,无法删除,请谨慎填写;职业变更请选择重新认证; -

- 4.职业认证审核完成后,系统将自动发放500个金币作为奖励; -

- 5.我们会确保你所提供的信息均处于严格的保密状态,不会泄露; -

- 6.如存在恶意乱填写姓名,学号,及上传与职业证件无关图片者,一经发现将冻结EduCoder账号。 -

-
- } - > - -
- { - certification && certification ==1 && - - {getFieldDecorator('credentials', { - rules: [{ - // initialValue: this.state.cityDefaultValue, - required: true, - message: '请输入证件号', - }], - })( - - )} - - } -
-
- { certification && certification == 1 ? "身份证(人像面)上传":"职业证照片上传" } - (png/jpg/bmp格式,不超过2MB) -
- -
- - avatar - - - {imageUrl2 ? - // - avatar - : - -

- -

-

点击或拖拽上传图片

- {/*

Support for a single or bulk upload. Strictly prohibit from uploading company data or other band files

*/} -
- } -
-
-
- 示例图片 - - - 查看大图 - -
-
- - - - - -
- ) - } -} -const WrappedRealNameCertificationModal = Form.create({ name: 'RealNameCertificationModal' })(RealNameCertificationModal); - -export default WrappedRealNameCertificationModal; - - +import React, { Component } from "react"; +import { message, Icon, Input, Form, Upload,Radio ,Tooltip} from "antd"; +import axios from 'axios' +import ModalWrapper from "../../courses/common/ModalWrapper" +import { City, getUploadActionUrl, getImageUrl, ImageLayer2, getUploadActionUrlOfAuth ,ConditionToolTip } from 'educoder' +import '../account/common.css' +import AccountBasicEditItem from '../account/AccountBasicEditItem' +import ApplyForAddOrgModal from './ApplyForAddOrgModal' +import ApplyForAddChildOrgModal from './ApplyForAddChildOrgModal' + +import authImg from '../../../images/account/auth.png' +import jobImg from '../../../images/account/job.png' + +const RadioGroup = Radio.Group; +const Dragger = Upload.Dragger; +const MAX_NAME_LENGTH = 10 +function getBase64(img, callback) { + const reader = new FileReader(); + reader.addEventListener('load', () => callback(reader.result)); + reader.readAsDataURL(img); +} +function beforeUpload(file) { + const isJPG = file.type === 'image/jpeg'; + if (!isJPG) { + message.error('You can only upload JPG file!'); + } + const isLt2M = file.size / 1024 / 1024 < 2; + if (!isLt2M) { + message.error('Image must smaller than 2MB!'); + } + return isJPG && isLt2M; +} +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 RealNameCertificationModal extends Component{ + constructor(props){ + super(props); + this.state={ + identity:"teacher", + departmentsName:undefined, + filterSchoolList:undefined, + filterDepartments :undefined, + school:undefined, + school_id:undefined, + department_id:undefined, + schoolList:undefined, + departments:undefined, + showRealName:true, + } + } + + componentDidMount() { + console.log("RealNameCertificationModal"); + console.log(this.props.basicInfo); + if(this.props.basicInfo){ + this.setValue(this.props.basicInfo); + this.getSchoolList(this.props.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, + + // city:[basicInfo.location,basicInfo.location_city] + }) + setTimeout(() => { + // 等显示后再set + this.props.form.setFieldsValue({ + job:basicInfo.identity, + student_No:basicInfo.student_id, + org2:basicInfo.department_name, + 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 + }) + //} + } + } + + getSchoolList=(basicInfo, selectedName)=>{ + let url=`/schools/for_option.json`; + axios.get(url).then((result)=>{ + if(result){ + this.setState({ + schoolList:result.data.schools + }) + if (selectedName) { + let school_id + result.data.schools.reverse().some( item => { + if (item.name == selectedName) { + school_id = item.id + return true; + } + }) + this.props.form.setFieldsValue({ + org: selectedName + }) + this.setState({ + school_id, + school: selectedName + }, () => { + this.filterList(selectedName) + }) + } 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; + }) + }) + this.getDepartments(basicInfo.school_name,false); + } + } + }).catch((error)=>{ + console.log(error); + }) + } + + // 将名字隐藏起来 + hideRealName=(name)=>{ + this.setState({ realName: name }) + const newName = getHiddenName(name) + + this.props.form.setFieldsValue({ + name: newName + }) + return newName + } + + getDepartments=(e,flag)=>{ + let arr=this.state.schoolList.filter(function(item){ + if(item.name.indexOf(e) > -1){ + return item.name; + } + }); + if (!arr[0]) { + if (!e) { + this.setState({ + filterSchoolList: [] + }) + } + // 没找到学校,清空部门 + this.setState({ + departments: [], + filterDepartments: [], + departmentsName: '', + school_id: '', + department_id: '', + }) + this.this_school_id = '' + this.props.form.setFieldsValue({ + org2: '' + }) + return; + } + this.props.form.setFieldsValue({ + org: arr[0].name + }) + this.filterList(e) + // 保存选择的学校id + this.this_school_id = arr[0].id + this.setState({ + school_id: arr[0].id, + 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){ + this.setState({ + departments:result.data.departments, + filterDepartments:result.data.departments + }) + if (selectedName) { + let department_id + result.data.departments.reverse().some( item => { + if (item.name == selectedName) { + department_id = item.id + return true; + } + }) + this.props.form.setFieldsValue({ + org2: selectedName + }) + this.setState({ + department_id, + // school: selectedName + }) + } else if(result.data.departments && result.data.departments.length>0 && flag==true){ + // 切换学校后,部门默认选择第一个 + this.props.form.setFieldsValue({ + org2:result.data.departments[0].name + }) + this.setState({ + department_id: result.data.departments[0].id + }) + }else if(result.data.departments && result.data.departments.length == 0 && flag==true){ + this.props.form.setFieldsValue({ + org2:'' + }) + } + } + }).catch((error)=>{ + console.log(error); + }) + } + + filterList =(e)=>{ + const inputVal = e.trim() + let arr=[]; + if(inputVal){ + arr= this.state.schoolList.filter(function(item){ + return item.name.indexOf(inputVal)>-1; + }); + this.props.form.setFieldsValue({ + org: inputVal + }) + this.setState({ + school: inputVal, + filterSchoolList: arr + }) + } else { + this.setState({ + school: '', + }) + } + // else{ + // let {school}=this.state; + // arr= this.state.schoolList.filter(function(item){ + // return item.name.indexOf(school)>-1; + // }); + // } + } + + setVisible = (visible) => { + this.refs.modalWrapper.setVisible(visible) + } + + onSendOk = () => { + this.props.form.validateFieldsAndScroll((err, values) => { + console.log(values); + if(!err){ + let{imageUrl2}=this.state; + let{current_user,basicInfo}=this.props; + if(imageUrl2){ + let { certification } = this.props; + if(certification == 1){ + // 实名认证 + let url = `/users/accounts/${current_user && current_user.login}/authentication_apply.json` + axios.post((url),{ + name:basicInfo.name, + gender:parseInt(values.sex), + id_number:values.credentials + }).then((result)=>{ + if(result){ + this.props.showNotification("申请已提交,请等待审核!"); + try { + this.props.getBasicInfo(); + } catch (e) { + } + try { + this.props.Getdata(); + } catch (e) { + + } + this.setVisible(false); + + + } + }).catch((error)=>{ + console.log(error); + }) + }else{ + // 职业认证 + // console.log(values.job == "student" ? values.student_No : values.job == "teacher" ? values.job1 : values.job2); + let url = `/users/accounts/${current_user && current_user.login}/professional_auth_apply.json` + axios.post((url),{ + school_id:this.state.school_id, + department_id:this.state.department_id, + identity:this.state.identity, + extra: values.job == "student" ? values.student_No : values.job == "teacher" ? values.job1 : values.job2 + }).then((result)=>{ + if(result){ + this.props.showNotification("申请已提交,请等待审核!"); + try { + this.props.getBasicInfo(); + } catch (e) { + + } + try { + this.props.Getdata(); + } catch (e) { + + } + this.setVisible(false); + + } + }).catch((error)=>{ + console.log(error); + }) + } + }else{ + this.props.showNotification("请先上传照片!"); + } + } + }) + } + + onOk = () => { + const { course_lists, checkBoxValues } = this.state + this.onSendOk() + } + + handleChange = (info) => { + if (info.file.status === 'uploading') { + this.setState({ loading: true }); + return; + } + if (info.file.status === 'done') { + // Get this url from response in real world. + getBase64(info.file.originFileObj, imageUrl => this.setState({ + imageUrl, + loading: false, + })); + } + } + handleChange2 = (info) => { + if (info.file.status === 'uploading') { + this.setState({ loading: true }); + return; + } + if (info.file.status === 'done') { + // Get this url from response in real world. + getBase64(info.file.originFileObj, imageUrl2 => this.setState({ + imageUrl2, + loading: false, + })); + } + } + // 切换职称 + changeJob=(e)=>{ + this.setState({ + identity:e + }) + 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:"企业管理者", + }) + } + } + // 选择学校(获取对应学校的学院、部门) + changeList=(e)=>{ + this.getDepartments(e.trim(),true); + } + + showApplyForAddOrgModal = () => { + this.applyForAddOrgForm.setVisible(true) + } + showApplyForAddChildOrgModal = () => { + let{school,schoolList}=this.state; + let arr=schoolList.filter(function(item){ + return item.name == school; + }); + if(arr.length > 0){ + this.applyForAddChildOrgForm.setVisible(true) + }else{ + this.props.showNotification("请先选择正确的单位或者学校!"); + } + } + addOrgSuccess = (name) => { + // const schoolList = this.state.schoolList.slice(0) + // schoolList.push({ id: schoolList.length + 2000, name: name}) + // this.setState({ schoolList }) + + this.getSchoolList(this.props.basicInfo, name); + this.props.form.setFieldsValue({ + org: name + }) + } + + addChildOrgSuccess = (deptName) => { + + this._getDepartments(this.state.school_id, false, deptName); + + } + + // 隐藏或显示真实姓名 + showOrHide=(flag)=>{ + const name = this.props.form.getFieldsValue().name || this.props.basicInfo.name + this.setState({ + showRealName:flag==true?false:true + }) + if(flag==true){ // 隐藏真实姓名 + this.hideRealName(name); + }else{ // 显示 + this.props.form.setFieldsValue({ + name: this.state.realName + }) + } + } + + render(){ + const { course_lists, checkBoxValues, searchValue, loading, imageUrl, imageUrl2, + identity, + departmentsName , + filterSchoolList , + filterDepartments , + school, + department_id, + departments, + school_id, + + showRealName + } = this.state + const { moduleName } = this.props + const { getFieldDecorator } = this.props.form; + let {certification}=this.props; + // /api/users/accounts/${this.props.current_user.login}/auth_attachment.json + + // 已职业认证的账户不能修改职业,学校/单位,院系/部门(true为disable) + const professionalFlag = basicInfo && basicInfo.professional_certification == "certified" ; + + let{ basicInfo }=this.props + let common={ + changeJob:this.changeJob, + filterList:this.filterList, + changeList:this.changeList, + showApplyForAddOrgModal:this.showApplyForAddOrgModal, + showApplyForAddChildOrgModal:this.showApplyForAddChildOrgModal + } + const uploadProps2 = { + name: 'image', + data: {type: certification == 1 ? "real_name" : "professional"}, + multiple: true, + showUploadList: false, + // https://newweb.educoder.net + action: this.props.current_user ? `${getUploadActionUrlOfAuth(this.props.current_user.login)}` : '', + className: 'idPic-uploader', + onChange: this.handleChange2, + }; + + // form合并了 + const propsWithoutForm = Object.assign({}, this.props) + delete propsWithoutForm.form + return( +
+ this.applyForAddOrgForm = form} schoolName={school} + {...propsWithoutForm} addOrgSuccess={this.addOrgSuccess} + > + this.applyForAddChildOrgForm = form} + addChildOrgSuccess={this.addChildOrgSuccess} + > + 实名认证: + 职业认证 + } + {...this.props } + {...this.state} + onOk={this.onOk} + okText="保存" + className="applyForModal certificationModal courseNormalForm" + width="660px" + bottomRender={ + certification && certification == 1? +
+

认证须知:

+

+ 1.你需要准备有效的身份证正面(人像面)的证件照照片,请确保证件照片清晰可见,严禁PS; +

+ 2.我们将在你提交认证信息后的24小时(不包含节假日)内完成审核,审核结果将会以系统消息的形式发送给你; +

+ 3.实名认证审核完成后,无法删除,请谨慎填写; +

+ 4.实名认证审核完成后,系统将自动发放500个金币作为奖励; +

+ 5.我们会确保你所提供的信息均处于严格的保密状态,不会泄露; +

+ 6.如存在恶意乱填写姓名,证件号,及上传与实名认证证件无关图片者,一经发现将冻结EduCoder账号。 +

+
: +
+

认证须知:

+

+ 1.根据职业上传相应的证件照:教师(教师证),专业人士(员工证)、学生(学生证),请确保证件照内容完整并且清晰可见,严禁PS; +

+ 2.我们将在你提交职业证信息后的24小时(不包含节假日)内完成审核,审核结果将会以系统消息的形式发送给你; +

+ 3.职业认证审核完成后,无法删除,请谨慎填写;职业变更请选择重新认证; +

+ 4.职业认证审核完成后,系统将自动发放500个金币作为奖励; +

+ 5.我们会确保你所提供的信息均处于严格的保密状态,不会泄露; +

+ 6.如存在恶意乱填写姓名,学号,及上传与职业证件无关图片者,一经发现将冻结EduCoder账号。 +

+
+ } + > + + +
+ {certification && certification == 1 ? +
+ + {basicInfo && basicInfo.authentication == 'uncertified' ? {getFieldDecorator('name', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: `请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`, + validator: this.checkNameLength + }], + })( + this.showOrHide(showRealName)}> + }> + )} + { showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)' } + : +
+ + {showRealName ? this.props.basicInfo.name : getHiddenName(this.props.basicInfo.name)} + + this.showOrHide(showRealName)}> + { showRealName ? '(显示:平台将显示您的真实姓名)' : '(隐藏:平台将显示你的昵称)' } +
+ } +
+ + + {getFieldDecorator('sex', { + rules: [{ + required: true, + message: '请选择性别', + }], + })( + + + + + + + )} + + + {getFieldDecorator('credentials', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: '请输入证件号', + }], + })( + + )} + +
+ : + + } +
+
+ { certification && certification == 1 ? "身份证上传:":"职业证上传:" } +
+ + avatar + + + {imageUrl2 ? + // + avatar + : + +

+ +

+

点击或拖拽上传图片

+ {/*

Support for a single or bulk upload. Strictly prohibit from uploading company data or other band files

*/} +
+ } +
+
+
+
+ +

示例图片

+

(png/jpg/bmp格式,不超过2MB)

+
+ + + 查看大图 + +
+
+ + + +
+ +
+ ) + } +} +const WrappedRealNameCertificationModal = Form.create({ name: 'RealNameCertificationModal' })(RealNameCertificationModal); + +export default WrappedRealNameCertificationModal; + +