diff --git a/public/react/package.json b/public/react/package.json index 7b00881d5..19b8286d9 100644 --- a/public/react/package.json +++ b/public/react/package.json @@ -3,6 +3,8 @@ "version": "0.1.0", "private": true, "dependencies": { + "@novnc/novnc": "^1.1.0", + "@flatten/array": "^1.1.7", "@icedesign/base": "^0.2.5", "antd": "^3.6.5", diff --git a/public/react/src/modules/courses/Index.js b/public/react/src/modules/courses/Index.js index 553db6090..3dcdb1c18 100644 --- a/public/react/src/modules/courses/Index.js +++ b/public/react/src/modules/courses/Index.js @@ -442,16 +442,21 @@ class CoursesIndex extends Component{ {/* 资源列表页 */} - () + (props) => () } > () + (props) => () } > + () + } + > {/*课堂讨论*/} {/* 毕设选题列表 */} - () + (props) => () }> @@ -554,9 +559,9 @@ class CoursesIndex extends Component{ {/* 毕设任务列表 https://www.trustie.net/issues/19981 */} - () + (props) => () } > @@ -593,13 +598,13 @@ class CoursesIndex extends Component{ > {/* 普通作业 */} - () } > {/* 分组作业 */} - () } diff --git a/public/react/src/modules/courses/ListPageIndex.js b/public/react/src/modules/courses/ListPageIndex.js index 12237e177..1f8bf6b29 100644 --- a/public/react/src/modules/courses/ListPageIndex.js +++ b/public/react/src/modules/courses/ListPageIndex.js @@ -56,6 +56,14 @@ const ShixunHomework= Loadable({ loading: Loading, }) +const GraduationTopics= Loadable({ + loader: () => import('./graduation/topics'), + loading: Loading, +}) +const GraduationTasks= Loadable({ + loader: () => import('./graduation/tasks'), + loading: Loading, +}) class ListPageIndex extends Component{ constructor(props) { super(props) @@ -169,12 +177,34 @@ class ListPageIndex extends Component{ } > + + () + } + > + () + } + > + + () + }> + () + } + > + {/* 默认 */} () } > - + diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index 1cae3d559..6476ef2bb 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -573,7 +573,7 @@ class Fileslists extends Component{ return( -
+ {/*发送*/} @@ -647,7 +647,6 @@ class Fileslists extends Component{ has_course_groups={this.state.has_course_groups} />:""} - - -
+ ) } } diff --git a/public/react/src/modules/courses/busyWork/commonWork.js b/public/react/src/modules/courses/busyWork/commonWork.js index 5ba97b03a..9f3d8dda0 100644 --- a/public/react/src/modules/courses/busyWork/commonWork.js +++ b/public/react/src/modules/courses/busyWork/commonWork.js @@ -71,6 +71,13 @@ class commonWork extends Component{ sureDelClasses(){ } + componentDidUpdate(prevProps, prevState) { + debugger; + if (prevProps.match.path != this.props.match.path) { + this.componentDidMount() + } + } + componentDidMount(){ this.setState({ diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js index e1284832c..1f49804e5 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js @@ -85,6 +85,19 @@ class GraduationTasksSubmitnew extends Component{ handleSubmit=(e) => { let {fileList,selectmemberslist,workslist}=this.state; + + if(fileList.length === 0){ + this.setState({ + Modalstype:true, + Modalstopval:'请上传附件!', + Loadtype:true, + ModalCancel:this.cancelAttachment + }) + + + return + } + let userids=[]; @@ -432,6 +445,8 @@ render(){ let graduation_id=workslist===undefined?"":workslist.graduation_id; let task_id=workslist===undefined?"":workslist.task_id; + + return( diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js index c842d02f2..b681388f8 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js @@ -697,7 +697,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.teacherrating)>60&&parseInt(record.teacherrating)<90?"#FF6800":'#747A7F'}}>{record.teacherrating==="--"||record.teacherrating==="未批阅"?"--":parseInt(record.teacherrating)} + 90?'#DD1717':parseInt(record.teacherrating)>60&&parseInt(record.teacherrating)<90?"#FF6800":'#747A7F'}}>{record.teacherrating==="--"||record.teacherrating==="未批阅"?"--":record.teacherrating} ), @@ -709,7 +709,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.crossrating)>60&&parseInt(record.crossrating)<90?"#FF6800":'#747A7F'}}>{record.crossrating==="--"||record.crossrating==="未批阅"?"--":parseInt(record.crossrating)} + 90?'#DD1717':parseInt(record.crossrating)>60&&parseInt(record.crossrating)<90?"#FF6800":'#747A7F'}}>{record.crossrating==="--"||record.crossrating==="未批阅"?"--":record.crossrating} ), @@ -721,7 +721,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.finalscore)>60&&parseInt(record.finalscore)<90?"#FF6800":'#747A7F'}}>{record.finalscore==="--"?"--":parseInt(record.finalscore)} + 90?'#DD1717':parseInt(record.finalscore)>60&&parseInt(record.finalscore)<90?"#FF6800":'#747A7F'}}>{record.finalscore==="--"?"--":record.finalscore} ), @@ -838,7 +838,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.teacherrating)>60&&parseInt(record.teacherrating)<90?"#FF6800":'#747A7F'}}>{record.teacherrating==="--"||record.teacherrating==="未批阅"?"--":parseInt(record.teacherrating)} + 90?'#DD1717':parseInt(record.teacherrating)>60&&parseInt(record.teacherrating)<90?"#FF6800":'#747A7F'}}>{record.teacherrating==="--"||record.teacherrating==="未批阅"?"--":record.teacherrating} ), @@ -850,7 +850,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.crossrating)>60&&parseInt(record.crossrating)<90?"#FF6800":'#747A7F'}}>{record.crossrating==="--"||record.crossrating==="未批阅"?"--":parseInt(record.crossrating)} + 90?'#DD1717':parseInt(record.crossrating)>60&&parseInt(record.crossrating)<90?"#FF6800":'#747A7F'}}>{record.crossrating==="--"||record.crossrating==="未批阅"?"--":record.crossrating} ), @@ -862,7 +862,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.finalscore)>60&&parseInt(record.finalscore)<90?"#FF6800":'#747A7F'}}>{record.finalscore==="--"?"--":parseInt(record.finalscore)} + 90?'#DD1717':parseInt(record.finalscore)>60&&parseInt(record.finalscore)<90?"#FF6800":'#747A7F'}}>{record.finalscore==="--"?"--":record.finalscore} ), @@ -995,7 +995,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.teacherrating)>60&&parseInt(record.teacherrating)<90?"#FF6800":'#747A7F'}}>{record.teacherrating==="--"||record.teacherrating==="未批阅"?"--":parseInt(record.teacherrating)} + 90?'#DD1717':parseInt(record.teacherrating)>60&&parseInt(record.teacherrating)<90?"#FF6800":'#747A7F'}}>{record.teacherrating==="--"||record.teacherrating==="未批阅"?"--":record.teacherrating} ), @@ -1007,7 +1007,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.crossrating)>60&&parseInt(record.crossrating)<90?"#FF6800":'#747A7F'}}>{record.crossrating==="--"||record.crossrating==="未批阅"?"--":parseInt(record.crossrating)} + 90?'#DD1717':parseInt(record.crossrating)>60&&parseInt(record.crossrating)<90?"#FF6800":'#747A7F'}}>{record.crossrating==="--"||record.crossrating==="未批阅"?"--":record.crossrating} ), @@ -1019,7 +1019,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.finalscore)>60&&parseInt(record.finalscore)<90?"#FF6800":'#747A7F'}}>{record.finalscore==="--"?"--":parseInt(record.finalscore)} + 90?'#DD1717':parseInt(record.finalscore)>60&&parseInt(record.finalscore)<90?"#FF6800":'#747A7F'}}>{record.finalscore==="--"?"--":record.finalscore} ), @@ -1138,7 +1138,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.teacherrating)>60&&parseInt(record.teacherrating)<90?"#FF6800":'#747A7F'}}>{record.teacherrating==="--"||record.teacherrating==="未批阅"?"--":parseInt(record.teacherrating)} + 90?'#DD1717':parseInt(record.teacherrating)>60&&parseInt(record.teacherrating)<90?"#FF6800":'#747A7F'}}>{record.teacherrating==="--"||record.teacherrating==="未批阅"?"--":record.teacherrating} ), @@ -1150,7 +1150,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.crossrating)>60&&parseInt(record.crossrating)<90?"#FF6800":'#747A7F'}}>{record.crossrating==="--"||record.crossrating==="未批阅"?"--":parseInt(record.crossrating)} + 90?'#DD1717':parseInt(record.crossrating)>60&&parseInt(record.crossrating)<90?"#FF6800":'#747A7F'}}>{record.crossrating==="--"||record.crossrating==="未批阅"?"--":record.crossrating} ), @@ -1162,7 +1162,7 @@ class GraduationTaskssettinglist extends Component{ render: (text, record) => ( - 90?'#DD1717':parseInt(record.finalscore)>60&&parseInt(record.finalscore)<90?"#FF6800":'#747A7F'}}>{record.finalscore==="--"?"--":parseInt(record.finalscore)} + 90?'#DD1717':parseInt(record.finalscore)>60&&parseInt(record.finalscore)<90?"#FF6800":'#747A7F'}}>{record.finalscore==="--"?"--":record.finalscore} ), diff --git a/public/react/src/modules/courses/graduation/tasks/index.js b/public/react/src/modules/courses/graduation/tasks/index.js index 29610eb93..c044c1711 100644 --- a/public/react/src/modules/courses/graduation/tasks/index.js +++ b/public/react/src/modules/courses/graduation/tasks/index.js @@ -591,7 +591,7 @@ class GraduationTasks extends Component{ // console.log(this.props.isCourseidentity()===isNotMember) // console.log(category_id) return( - + {/*提示*/} - + ) } } diff --git a/public/react/src/modules/courses/graduation/topics/index.js b/public/react/src/modules/courses/graduation/topics/index.js index aaba86e9e..391bcac18 100644 --- a/public/react/src/modules/courses/graduation/topics/index.js +++ b/public/react/src/modules/courses/graduation/topics/index.js @@ -341,7 +341,7 @@ onBoardsNew=()=>{ // let {course_identity}=this.props.coursedata const isAdmin =this.props.isAdmin(); return( - + {
-
+ ) } } diff --git a/public/react/src/modules/login/EducoderLogin.js b/public/react/src/modules/login/EducoderLogin.js index 94341d7e2..3c3f47c87 100644 --- a/public/react/src/modules/login/EducoderLogin.js +++ b/public/react/src/modules/login/EducoderLogin.js @@ -60,21 +60,27 @@ class EducoderLogin extends Component { if( props.match.url === "/changepassword" ){ this.state = { showbool: false, + logini:3, } }else { if(props.match.url === "/login"){ this.state = { showbool: true, - loginstatus:true + loginstatus:true, + logini:1, + } }else if(props.match.url === "/register"){ this.state = { showbool: true, loginstatus:false, + logini:2, } }else{ this.state = { showbool: true, + logini:1, + } } @@ -86,6 +92,14 @@ class EducoderLogin extends Component { } + Setlogins=(i)=>{ + console.log("96ye"); + console.log(i) + this.setState({ + logini:i + }) + + } Setshowbool = () => { if (this.state.showbool === true) { @@ -102,7 +116,7 @@ class EducoderLogin extends Component { render() { - let {showbool} = this.state; + let {showbool,loginstatus,logini} = this.state; return (
+ id="game_left_contents" style={{ width: '35%'}}> {/* style={{width: '694px'}} */} {/* 左侧任务说明等功能的区域 */} @@ -82,6 +86,10 @@ class MainContent extends Component {
*/} + {/* { showIframeContent && vnc_url ? */} +
diff --git a/public/react/src/modules/page/MainContentContainer.js b/public/react/src/modules/page/MainContentContainer.js index 7595f933d..daa4b65b6 100644 --- a/public/react/src/modules/page/MainContentContainer.js +++ b/public/react/src/modules/page/MainContentContainer.js @@ -237,6 +237,10 @@ class MainContentContainer extends Component { // arg_path 点击文件目录树时,传入的点击节点对应的path fetchRepositoryCode( props, arg_path, type, isRetry) { const { challenge, showSnackbar, game, shixun, myshixun, hide_code } = props ? props : this.props; + if (shixun.vnc == true) { + // vnc模式下不需要加载代码 + return true; + } if ( // true || hide_code) { // 隐藏code的实训 diff --git a/public/react/src/modules/page/VNCDisplay.js b/public/react/src/modules/page/VNCDisplay.js new file mode 100644 index 000000000..b8840fe02 --- /dev/null +++ b/public/react/src/modules/page/VNCDisplay.js @@ -0,0 +1,154 @@ +// import React, { Component } from 'react'; + +// import RFB from '@novnc/novnc/lib/rfb.js'; + +// const $ = window.$; +// // const showIframeContent = window.location.search.indexOf('vnc=1') != -1; +// class VNCDisplay extends Component { +// componentDidMount() { +// console.log(RFB) + +// let rfb; +// let desktopName; +// // When this function is called we have +// // successfully connected to a server +// function connectedToServer(e) { +// status("Connected to " + desktopName); +// } +// // This function is called when we are disconnected +// function disconnectedFromServer(e) { +// if (e.detail.clean) { +// status("Disconnected"); +// } else { +// status("Something went wrong, connection is closed"); +// } +// } +// // When this function is called, the server requires +// // credentials to authenticate +// function credentialsAreRequired(e) { +// const password = prompt("Password Required:"); +// rfb.sendCredentials({ password: password }); +// } +// // When this function is called we have received +// // a desktop name from the server +// function updateDesktopName(e) { +// desktopName = e.detail.name; +// } +// // Since most operating systems will catch Ctrl+Alt+Del +// // before they get a chance to be intercepted by the browser, +// // we provide a way to emulate this key sequence. +// function sendCtrlAltDel() { +// rfb.sendCtrlAltDel(); +// return false; +// } +// // Show a status text in the top bar +// function status(text) { +// document.getElementById('status').textContent = text; +// } +// // This function extracts the value of one variable from the +// // query string. If the variable isn't defined in the URL +// // it returns the default value instead. +// function readQueryVariable(name, defaultValue) { +// // A URL with a query parameter can look like this: +// // https://www.example.com?myqueryparam=myvalue +// // +// // Note that we use location.href instead of location.search +// // because Firefox < 53 has a bug w.r.t location.search +// const re = new RegExp('.*[?&]' + name + '=([^&#]*)'), +// match = document.location.href.match(re); +// if (typeof defaultValue === 'undefined') { defaultValue = null; } +// if (match) { +// // We have to decode the URL since want the cleartext value +// return decodeURIComponent(match[1]); +// } +// return defaultValue; +// } +// document.getElementById('sendCtrlAltDelButton') +// .onclick = sendCtrlAltDel; +// // Read parameters specified in the URL query string +// // By default, use the host and port of server that served this file + +// // const host = readQueryVariable('host', window.location.hostname); +// // let port = readQueryVariable('port', window.location.port); +// // const password = readQueryVariable('password', ''); + +// const { vnc_url } = this.props; +// // http://117.50.12.63:43149/vnc_lite.html?password=headless +// let _ar1 = vnc_url.split('/'); +// let ipAndPort = _ar1[2].split(':') +// let passwordAr = _ar1[3].split('password=') +// const host = ipAndPort[0] +// let port = ipAndPort[1] +// const password = passwordAr[1].split('&')[0] + +// const path = readQueryVariable('path', 'websockify'); +// // | | | | | | +// // | | | Connect | | | +// // v v v v v v +// status("Connecting"); +// // Build the websocket URL used to connect +// let url; +// if (vnc_url.indexOf("https:") != -1) { +// url = 'wss'; +// } else { +// url = 'ws'; +// } +// url += '://' + host; +// if(port) { +// url += ':' + port; +// } +// url += '/' + path; +// // Creating a new RFB object will start a new connection +// rfb = new RFB(document.getElementById('screen'), url, +// { credentials: { password: password } }); +// // Add listeners to important events from the RFB module +// rfb.addEventListener("connect", connectedToServer); +// rfb.addEventListener("disconnect", disconnectedFromServer); +// rfb.addEventListener("credentialsrequired", credentialsAreRequired); +// rfb.addEventListener("desktopname", updateDesktopName); +// // Set parameters that can be changed on an active connection +// rfb.viewOnly = readQueryVariable('view_only', false); +// rfb.scaleViewport = readQueryVariable('scale', false); +// } + +// render() { +// const { challenge, vnc_url } = this.props + + +// return ( +//
+// +//
+//
Loading
+//
Send CtrlAltDel
+//
+//
+//
+// ); +// } +// } + +// export default VNCDisplay; diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index 7723af4fc..9d8adb920 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -213,6 +213,13 @@ export function TPMIndexHOC(WrappedComponent) { return this.state.coursedata&&this.state.coursedata.course_identity === 6 } + setTrialapplication = ()=>{ + this.setState({ + isRenders:true + }) + + } + /** 课堂权限相关方法,暂时写这里了 ----------------------------------------END @@ -285,7 +292,7 @@ export function TPMIndexHOC(WrappedComponent) { user_phone_binded === undefined? "" : - + } diff --git a/public/react/src/modules/user/FindPasswordComponent.js b/public/react/src/modules/user/FindPasswordComponent.js index f1823ddbe..41b8ec464 100644 --- a/public/react/src/modules/user/FindPasswordComponent.js +++ b/public/react/src/modules/user/FindPasswordComponent.js @@ -1,429 +1,431 @@ -import React, {Component} from 'react'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -import {getImageUrl, DragValidator} from 'educoder'; -import {Tabs, Input, Checkbox, Button, notification} from 'antd'; -import axios from 'axios'; -import './common.css' - -const TabPane = Tabs.TabPane -const loginInputsyl = { - "width": " 100%", - "height": "40px", -} - -//父组件 EducoderLogin.js -class LoginRegisterComponent extends Component { - constructor(props) { - super(props) - this.state = { - login: "", - password: "", - passwords: "", - seconds: 60, - codes: "", - getverificationcodes: true, - Phonenumberisnotco: undefined, - Phonenumberisnotcobool: false, - s: 'text', - classpass: "text", - readonlyInput: true, - } - } - - - openNotification = (messge) => { - notification.open({ - message: "提示", - description: - messge, - onClick: () => { - console.log('Notification Clicked!'); - }, - }); - }; - StudyMakeMoney = () => { // 调用父组件方法 - this.props.Setshowbool(); - - } - - // 点击表单后,改变type - changeType = () => { - this.setState({classpass: 'password'}); - } - changeTypey = () => { - - } - //倒计时 - getverificationcode = () => { - if (this.state.Phonenumberisnotcobool === false) { - if (this.state.login.length === 0) { - this.openNotification("请输入手机号或邮箱"); - return - } else { - this.openNotification("请输入正确的手机号或邮箱"); - } - return; - } - if (this.state.getverificationcodes === true) { - this.setState({ - getverificationcodes: undefined, - }) - let timer = setInterval(() => { - this.setState((preState) => ({ - seconds: preState.seconds - 1, - }), () => { - if (this.state.seconds == 0) { - clearInterval(timer); - this.setState({ - getverificationcodes: false, - seconds: 60, - }) - } - }); - }, 1000) - this.SMSverification(); - } else { - this.setState({ - getverificationcodes: undefined, - }) - let timer = setInterval(() => { - this.setState((preState) => ({ - seconds: preState.seconds - 1, - }), () => { - if (this.state.seconds == 0) { - clearInterval(timer); - this.setState({ - getverificationcodes: false, - seconds: 60, - - }) - } - }); - }, 1000) - this.SMSverification(); - } - } - //短信验证 - SMSverification = () => { - var url = `/accounts/get_verification_code.json`; - axios.get((url), { - params: { - login: this.state.login, - type: 2, - } - }).then((result) => { - //验证有问题{"status":1,"message":"success"} - console.log(result); - - - }).catch((error) => { - console.log(error); - - }) - } - - cancelReadOnly = () => { - this.setState({ - readonlyInput: false, - }) - } - //找回密码 - Retrievepassword = () => { - if (this.state.Phonenumberisnotcobool === false) { - if (this.state.login.length === 0) { - this.openNotification("请输入手机号或邮箱"); - return - } - this.openNotification("请输入正确的手机号或邮箱"); - return; - } - - if (this.state.login === undefined || this.state.login == "") { - this.openNotification(`请输入登录手机号码或邮箱`); - return - } else if (this.state.password === undefined || this.state.password == "") { - this.openNotification(`请输入密码`); - return - } else if (this.state.passwords === undefined || this.state.passwords == "") { - this.openNotification(`请输入密码`); - return - } else if (this.state.password !== this.state.passwords) { - this.openNotification(`两次密码不相同`); - return - } else if (this.state.codes === undefined || this.state.codes == "") { - this.openNotification(`请输入验证码`); - return - } - var url = "/accounts/reset_password.json"; - axios.post(url, { - login: this.state.login, - code: this.state.codes, - new_password: this.state.password, - new_password_confirmation: this.state.passwords, - }).then((result) => { - // console.log(result); - //登录成功,会生成session - this.openNotification("找回密码成功,请重新登入。"); - window.location.href = "/login" - }).catch((error) => { - - }) - - - } - openNotification = (messge) => { - notification.open({ - message: "提示", - description: - messge, - onClick: () => { - console.log('Notification Clicked!'); - }, - }); - }; - loginInputonChange = (e) => { - // console.log(e.target.value); - this.setState({ - login: e.target.value, - }) - - - } - loginInputonChanges = (e) => { - // console.log(e.target.value); - this.setState({ - password: e.target.value, - }) - - - } - loginInputonChangess = (e) => { - // console.log(e.target.value); - this.setState({ - passwords: e.target.value, - }) - - - } - //获取code - codesonChange = (e) => { - this.setState({ - codes: e.target.value - }) - } - inputOnBlur = (e) => { - this.isCorrectname(e.target.value); - // this.Emailphonenumberverification(e.target.value, id); - } - isCorrectname = (value) => { - console.log(value.length); - if (value.length === 0) { - this.setState({ - Phonenumberisnotco: undefined, - Phonenumberisnotcobool: false, - }) - return; - } - // var telephone = $("#telephoneAdd.tianjia_phone").val(); - var regph = /^[1][3,4,5,6,7,8][0-9]{9}$/; - // var email = $("#add_email.tianjia_email").val(); - var regemail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; - - // [1]手机号开头必须是1 [3,4,5,6,7,8] 第二位是3-8中的一个 [0-9]{9} 后边9位可以是0-9的任意数字。 - var stringdata = undefined; - if (!regph.test(value)) { - stringdata = "手机号格式不正确"; - this.setState({ - Phonenumberisnotco: stringdata, - Phonenumberisnotcobool: false, - }) - } else { - this.setState({ - Phonenumberisnotco: undefined, - Phonenumberisnotcobool: true, - }) - return - } - - if (!regemail.test(value)) { - if ((value.indexOf("@") != -1) === true) { - stringdata = "邮箱格式不正确"; - } else { - stringdata = "手机号格式不正确"; - - } - this.setState({ - Phonenumberisnotco: stringdata, - Phonenumberisnotcobool: false, - }) - - this.Emailphonenumberverification(value) - return - } else { - this.setState({ - Phonenumberisnotco: undefined, - Phonenumberisnotcobool: true, - }) - return - } - } - //邮箱手机号验证 - Emailphonenumberverification = (value) => { - var url = `/accounts/valid_email_and_phone.json`; - axios.get((url), { - params: { - login: value, - type: 2, - } - }).then((result) => { - //验证有问题{"status":1,"message":"success"} - console.log(result); - - - }).catch((error) => { - console.log(error); - // this.setState({ - // login:"", - // logins:"", - // }) - }) - } - - render() { - const { - activeKey, - // 登录 - autoLogin, - // 注册 - readAgreement, dragOk, - login, - password, - passwords, - classpass, - seconds, - getverificationcodes, - Phonenumberisnotco, - readonlyInput, - codes, - } = this.state - // height: 346px; - return ( - -
- - - - -
-
- 找回密码 -
-
- - this.inputOnBlur(e)} - onChange={this.loginInputonChange} style={{marginTop: '10px'}}> - { - Phonenumberisnotco && Phonenumberisnotco != "" ? -

- {Phonenumberisnotco} -

- :
- } - - - - -
- - - { - getverificationcodes === undefined ? - - : getverificationcodes === true ? - - : - - } - - -
- - -
-
- -
- ); - } -} - -export default (LoginRegisterComponent); +import React, {Component} from 'react'; + +import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; + +import {getImageUrl, DragValidator} from 'educoder'; +import {Tabs, Input, Checkbox, Button, notification} from 'antd'; +import axios from 'axios'; +import './common.css' + +const TabPane = Tabs.TabPane +const loginInputsyl = { + "width": " 100%", + "height": "40px", +} + +//父组件 EducoderLogin.js +class LoginRegisterComponent extends Component { + constructor(props) { + super(props) + this.state = { + login: "", + password: "", + passwords: "", + seconds: 60, + codes: "", + getverificationcodes: true, + Phonenumberisnotco: undefined, + Phonenumberisnotcobool: false, + s: 'text', + classpass: "text", + readonlyInput: true, + } + } + + + openNotification = (messge) => { + notification.open({ + message: "提示", + description: + messge, + onClick: () => { + console.log('Notification Clicked!'); + }, + }); + }; + StudyMakeMoney = () => { // 调用父组件方法 + this.props.Setshowbool(); + + } + + // 点击表单后,改变type + changeType = () => { + this.setState({classpass: 'password'}); + } + changeTypey = () => { + + } + //倒计时 + getverificationcode = () => { + if (this.state.Phonenumberisnotcobool === false ||this.state.Phonenumberisnotcobool === undefined) { + if (this.state.login&&this.state.login.length === 0) { + this.openNotification("请输入手机号或邮箱"); + return + } else { + this.openNotification("请输入正确的手机号或邮箱"); + } + return; + } + if (this.state.getverificationcodes === true) { + this.setState({ + getverificationcodes: undefined, + }) + let timer = setInterval(() => { + this.setState((preState) => ({ + seconds: preState.seconds - 1, + }), () => { + if (this.state.seconds == 0) { + clearInterval(timer); + this.setState({ + getverificationcodes: false, + seconds: 60, + }) + } + }); + }, 1000) + this.SMSverification(); + } else { + this.setState({ + getverificationcodes: undefined, + }) + let timer = setInterval(() => { + this.setState((preState) => ({ + seconds: preState.seconds - 1, + }), () => { + if (this.state.seconds == 0) { + clearInterval(timer); + this.setState({ + getverificationcodes: false, + seconds: 60, + + }) + } + }); + }, 1000) + this.SMSverification(); + } + } + //短信验证 + SMSverification = () => { + var url = `/accounts/get_verification_code.json`; + axios.get((url), { + params: { + login: this.state.login, + type: 2, + } + }).then((result) => { + //验证有问题{"status":1,"message":"success"} + console.log(result); + + + }).catch((error) => { + console.log(error); + + }) + } + + cancelReadOnly = () => { + this.setState({ + readonlyInput: false, + }) + } + //找回密码 + Retrievepassword = () => { + if (this.state.Phonenumberisnotcobool === false) { + if (this.state.login.length === 0) { + this.openNotification("请输入手机号或邮箱"); + return + } + this.openNotification("请输入正确的手机号或邮箱"); + return; + } + + if (this.state.login === undefined || this.state.login == "") { + this.openNotification(`请输入登录手机号码或邮箱`); + return + } else if (this.state.password === undefined || this.state.password == "") { + this.openNotification(`请输入密码`); + return + } else if (this.state.passwords === undefined || this.state.passwords == "") { + this.openNotification(`请输入密码`); + return + } else if (this.state.password !== this.state.passwords) { + this.openNotification(`两次密码不相同`); + return + } else if (this.state.codes === undefined || this.state.codes == "") { + this.openNotification(`请输入验证码`); + return + } + var url = "/accounts/reset_password.json"; + axios.post(url, { + login: this.state.login, + code: this.state.codes, + new_password: this.state.password, + new_password_confirmation: this.state.passwords, + }).then((result) => { + // console.log(result); + //登录成功,会生成session + this.openNotification("找回密码成功,请重新登入。"); + window.location.href = "/login" + }).catch((error) => { + + }) + + + } + openNotification = (messge) => { + notification.open({ + message: "提示", + description: + messge, + onClick: () => { + console.log('Notification Clicked!'); + }, + }); + }; + loginInputonChange = (e) => { + // console.log(e.target.value); + this.setState({ + login: e.target.value, + }) + + + } + loginInputonChanges = (e) => { + // console.log(e.target.value); + this.setState({ + password: e.target.value, + }) + + + } + loginInputonChangess = (e) => { + // console.log(e.target.value); + this.setState({ + passwords: e.target.value, + }) + + + } + //获取code + codesonChange = (e) => { + this.setState({ + codes: e.target.value + }) + } + inputOnBlur = (e) => { + this.isCorrectname(e.target.value); + // this.Emailphonenumberverification(e.target.value, id); + } + isCorrectname = (value) => { + console.log(value.length); + if (value.length === 0) { + this.setState({ + Phonenumberisnotco: undefined, + Phonenumberisnotcobool: false, + }) + return; + } + // var telephone = $("#telephoneAdd.tianjia_phone").val(); + var regph = /^[1][3,4,5,6,7,8][0-9]{9}$/; + // var email = $("#add_email.tianjia_email").val(); + var regemail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; + + // [1]手机号开头必须是1 [3,4,5,6,7,8] 第二位是3-8中的一个 [0-9]{9} 后边9位可以是0-9的任意数字。 + var stringdata = undefined; + if (!regph.test(value)) { + stringdata = "手机号格式不正确"; + this.setState({ + Phonenumberisnotco: stringdata, + Phonenumberisnotcobool: false, + }) + } else { + this.setState({ + Phonenumberisnotco: undefined, + Phonenumberisnotcobool: true, + }) + return + } + + if (!regemail.test(value)) { + if ((value.indexOf("@") != -1) === true) { + stringdata = "邮箱格式不正确"; + } else { + stringdata = "手机号格式不正确"; + + } + this.setState({ + Phonenumberisnotco: stringdata, + Phonenumberisnotcobool: false, + }) + + this.Emailphonenumberverification(value) + return + } else { + this.setState({ + Phonenumberisnotco: undefined, + Phonenumberisnotcobool: true, + }) + return + } + } + //邮箱手机号验证 + Emailphonenumberverification = (value) => { + var url = `/accounts/valid_email_and_phone.json`; + axios.get((url), { + params: { + login: value, + type: 2, + } + }).then((result) => { + //验证有问题{"status":1,"message":"success"} + console.log(result); + + + }).catch((error) => { + console.log(error); + // this.setState({ + // login:"", + // logins:"", + // }) + }) + } + + render() { + const { + activeKey, + // 登录 + autoLogin, + // 注册 + readAgreement, dragOk, + login, + password, + passwords, + classpass, + seconds, + getverificationcodes, + Phonenumberisnotco, + readonlyInput, + codes, + } = this.state + // height: 346px; + return ( + +
+ + + + +
+
+ 找回密码 +
+
+ + this.inputOnBlur(e)} + onChange={this.loginInputonChange} style={{marginTop: '10px',height: "38px"}}> + { + Phonenumberisnotco && Phonenumberisnotco != "" ? +

+ {Phonenumberisnotco} +

+ :
+ } + + + + +
+ + + { + getverificationcodes === undefined ? + + : getverificationcodes === true ? + + : + + } + + +
+ + +
+
+ +
+ ); + } +} + +export default (LoginRegisterComponent); diff --git a/public/react/src/modules/user/LoginRegisterComponent.js b/public/react/src/modules/user/LoginRegisterComponent.js index 846000984..d314effca 100644 --- a/public/react/src/modules/user/LoginRegisterComponent.js +++ b/public/react/src/modules/user/LoginRegisterComponent.js @@ -10,8 +10,12 @@ import axios from 'axios'; import './common.css' const { TabPane } = Tabs; const loginInputsyl = { - "width": " 100%", - "height": "40px", +"width":"434px", +"height": "462px", +"-webkit-box-shadow": "3px 10px 21px 0px rgba(76,76,76,0.15)", +"box-shadow": "3px 10px 21px 0px rgba(76,76,76,0.15)", +"border-radius": "6px", +"background": "#fff" } //父组件EducoderLogin.js @@ -135,6 +139,7 @@ class LoginRegisterComponent extends Component { ; StudyMakeMoney = () => { // 调用父组件方法 this.props.Setshowbool(); + // this.props.Setlogins(3); this.setState({ login: "", password: "", @@ -407,8 +412,9 @@ class LoginRegisterComponent extends Component { //倒计时 getverificationcode = () => { - if (this.state.Phonenumberisnotcobool === false) { - if (this.state.logins.length === 0) { + debugger + if (this.state.Phonenumberisnotcobool === false ||this.state.Phonenumberisnotcobool === undefined) { + if (this.state.logins&&this.state.logins.length === 0) { this.openNotification("请输入手机号或邮箱",2); return }else { @@ -503,6 +509,13 @@ class LoginRegisterComponent extends Component { this.setState({ tab:e.key }) + // console.log(e.key); + // if(e.key === 0){ + // this.props.Setlogins(1); + // }else{ + // this.props.Setlogins(2); + // + // } // this.props.history.push(`/courses/${this.props.match.params.coursesId}/exercises/${this.props.match.params.Id}/student_exercise_list?tab=`+e.key) @@ -532,7 +545,7 @@ class LoginRegisterComponent extends Component { // console.log(activeKey); return ( -
+
@@ -576,62 +589,65 @@ class LoginRegisterComponent extends Component { + className="font-14 color-grey-9" + style={{marginTop: '30px', height: '38px'}}> { Phonenumberisnotco && Phonenumberisnotco != "" ?

{Phonenumberisnotco}

- :
+ :
} - -
+
下次自动登录 - 找回密码 + 找回密码
-
} { parseInt(tab[0])==1 &&
- this.inputOnBlur(e, 2)} - style={{marginTop: '30px'}}> + style={{marginTop: '30px' , height: '38px',color:'#999999',fontSize:"14px"}}> { Phonenumberisnotcos && Phonenumberisnotcos != "" ? -

+

+ {/*{Phonenumberisnotcos}*/} - {Phonenumberisnotcos} + 请输入手机号码

- :
+ :
} -
- + { getverificationcodes === undefined ? - : getverificationcodes === true ? - + : - } @@ -655,8 +671,9 @@ class LoginRegisterComponent extends Component { {/* style={{height: '0', width: '0', border: 'none', display: "none"}}/>*/} {/**/} - 我已阅读并同意服务协议条款 - + >我已阅读并同意服务协议条款 +