!299 用户注册页面

Merge pull request !299 from 肖诗雅/regist
pull/299/MERGE
肖诗雅 5 years ago committed by ChenX
parent 2e5268ad8c
commit 795360d446

@ -0,0 +1,8 @@
{
"tabWidth": 4,
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"jsxBracketSameLine": true,
"printWidth": 150
}

@ -14,4 +14,6 @@
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
"javascript.format.enable": true,
"files.insertFinalNewline": true,
//
"formattingToggle.activateFor": ["formatOnPaste", "formatOnSave"]
}

@ -3,6 +3,8 @@ export const SignUrl = {
login: CURRENT_HOST + "/CAD-login",
loginOut: CURRENT_HOST + "/CAD-loginOut",
heart: CURRENT_HOST + "/CAD-heart",
regist: CURRENT_HOST + "/CAD-reg",
SMSCode: CURRENT_HOST + "/CAD-checkCode",
}
export const ImgsUrl = {
get: CURRENT_HOST + "/CAD-imageList",

@ -8,7 +8,7 @@ export enum ZINDEX
ToolBar = "2", //工具栏
BluePortal = "30", //蓝图模态框默认值
RightMenu = "30",//右键菜单
Portal = "34",//PopOver 见"DoorModal.less"
Portal = "38",//PopOver 见"DoorModal.less"
ToolsBlock_small = "32",
CommandInput = "28",
TransparentTerminal = "0",

@ -115,7 +115,7 @@ export default class Login extends React.Component<{ store?: TopPanelStore }, IL
textDecoration: "none",
}}
target="_blank"
href="http://www.ihome6.cf/user-regCompany"></a>
onClick={() => this.props.store.openRegist = true}></a>
</div>
</div>
</div>

@ -71,7 +71,7 @@
.login-input{
padding: 0 40px;
.bp3-icon,{
.bp3-icon{
top: 5px;
svg{
color: @color3;
@ -135,6 +135,34 @@
}
}
}
.regist{
overflow: auto;
min-width: 660px;
.regist-content{
position: relative;
top: 30%;
transform: translateY(-30%);
}
.item{
display: flex;
>label{
display: inline-block;
width: 90px;
text-align: right;
&>span:first-child{
color: red;
}
}
}
.center{
justify-content: center;
margin-top: 10px;
}
a{
text-decoration: none;
color: #106ba3;
}
}
.content{
position: absolute;
left: 0;

@ -12,6 +12,7 @@ import { userConfig } from '../../../Editor/UserConfig';
import { userConfigStore } from '../../Store/UserConfigStore';
import { BoardModalType } from '../Board/BoardModal';
import { DrillStore } from '../../Store/DrillStore';
import Regist from './Regist';
@inject('store')
@observer
@ -43,9 +44,12 @@ export class MainContent extends React.Component<{ store?: TopPanelStore }>
}}
>
{
this.props.store.isLogin ?
<ContentComponent />
: <Login />
this.props.store.openRegist ?
<Regist />
:
this.props.store.isLogin ?
<ContentComponent />
: <Login />
}
</Card>
}

@ -0,0 +1,549 @@
import * as React from 'react';
import { KeyBoard } from '../../../Common/KeyEnum';
import { InputGroup, Label, Classes, Button, Checkbox, Dialog, Intent, Tooltip, Position } from '@blueprintjs/core';
import { TopPanelStore } from '../../Store/TopPanelStore';
import { inject, observer } from 'mobx-react';
import { IObservableValue, observable } from 'mobx';
import { request, RequestStatus } from '../../../Common/Request';
import { SignUrl } from '../../../Common/HostUrl';
import { AppToaster } from '../Toaster';
interface IRegistState
{
user_phone: string;
pass_word: string;
check_code: string;
pswConfirm: string;
agreement_checked: boolean;
}
interface InputIntent
{
PSW: Intent;
ComfirmPSW: Intent;
PHONE: Intent;
}
enum InputType
{
PSW = 0,
ComfirmPSW = 1,
PHONE = 2,
OK = 3,
}
@inject("store")
@observer
export default class Regist extends React.Component<{ store?: TopPanelStore }, IRegistState> {
@observable private errMsg: string = "";
@observable private flag: InputType = InputType.OK;
@observable private inputIntent: InputIntent;
@observable private SMSBtnText: string = "获取短信验证码";
private openAgreement = observable.box(false);
private phoneRegex = new RegExp(`\^1\\d{10}$`);
private pswRegex = new RegExp(`\^[^\\u4e00-\\u9fa5]+$`);
constructor(props)
{
super(props);
this.state = {
user_phone: "",
pass_word: "",
check_code: "",
pswConfirm: "",
agreement_checked: false,
};
this.inputIntent = {
PSW: Intent.NONE,
ComfirmPSW: Intent.NONE,
PHONE: Intent.NONE,
};
}
handleRegist = async () =>
{
if (this.inputIntent.PSW !== Intent.SUCCESS)
{
AppToaster.show({
message: "密码设置有误,请核验",
intent: Intent.DANGER,
timeout: 1000,
});
return;
}
if (this.inputIntent.ComfirmPSW !== Intent.SUCCESS)
{
AppToaster.show({
message: "重复密码有误,请核验",
intent: Intent.DANGER,
timeout: 1000,
});
return;
}
if (this.inputIntent.PHONE !== Intent.SUCCESS)
{
AppToaster.show({
message: "手机号输入有误,请核验",
intent: Intent.DANGER,
timeout: 1000,
});
return;
}
if (this.state.check_code === "")
{
AppToaster.show({
message: "验证码不能为空",
intent: Intent.DANGER,
timeout: 1000,
});
return;
}
if (!this.state.agreement_checked)
{
AppToaster.show({
message: "需同意注册协议方可注册",
intent: Intent.DANGER,
timeout: 1000,
});
return;
}
let data = await request(SignUrl.regist, {
body: JSON.stringify(this.state),
});
if (data.err_code === RequestStatus.Ok)
{
//注册成功 跳转到登陆
AppToaster.show({
message: "注册成功",
intent: Intent.SUCCESS,
timeout: 1000,
});
this.props.store.openRegist = false;
}
}
handleSMS = async () =>
{
let num = 120;
this.SMSBtnText = `${num}s后重新获取`;
//120秒倒数
let tim = setInterval(() =>
{
num--;
this.SMSBtnText = `${num}s后重新获取`;
if (num === 1)
{
clearInterval(tim);
this.SMSBtnText = "获取短信验证码";
}
return "";
}, 1000);
let data = await request(SignUrl.SMSCode, {
body: JSON.stringify({
user_phone: this.state.user_phone
})
});
if (data.err_code === RequestStatus.Ok)
{
//发送短信成功
AppToaster.show({
message: "短信已发送,请注意查收",
timeout: 1000,
});
}
}
valueTest = (type: InputType, text: string) =>
{
switch (type)
{
case InputType.PSW:
if (text.length >= 6 && text.length <= 20)
{
if (this.pswRegex.test(text))
{
this.flag = InputType.OK;
this.errMsg = "";
this.inputIntent.PSW = Intent.SUCCESS;
}
else
{
this.errMsg = "密码不可包含中文";
this.flag = InputType.PSW;
this.inputIntent.PSW = Intent.DANGER;
}
}
else
{
this.errMsg = "密码长度应在6-20之间";
this.flag = InputType.PSW;
this.inputIntent.PSW = Intent.DANGER;
}
if (this.state.pswConfirm === text)
this.inputIntent.ComfirmPSW = Intent.SUCCESS;
else
this.inputIntent.ComfirmPSW = Intent.DANGER;
break;
case InputType.ComfirmPSW:
if (text === this.state.pass_word)
{
this.flag = InputType.OK;
this.errMsg = "";
this.inputIntent.ComfirmPSW = Intent.SUCCESS;
}
else
{
this.errMsg = "密码与确认密码不一致";
this.flag = InputType.ComfirmPSW;
this.inputIntent.ComfirmPSW = Intent.DANGER;
}
break;
case InputType.PHONE:
if (this.phoneRegex.test(text))
{
this.flag = InputType.OK;
this.errMsg = "";
this.inputIntent.PHONE = Intent.SUCCESS;
}
else
{
this.errMsg = "请输入正确的11位手机号码";
this.flag = InputType.PHONE;
this.inputIntent.PHONE = Intent.DANGER;
}
break;
}
}
render()
{
const infoBlockStyle: React.CSSProperties = {
background: "#fff",
border: "1px solid lightgrey",
width: "70%",
margin: "10px auto",
padding: "20px",
minWidth: "480px",
};
return (
<div
className="regist"
style={{
background: "#f2f2f2",
width: "75%",
height: "100%",
margin: "0 auto",
}}
onKeyDown={e =>
{
if (e.keyCode === KeyBoard.Enter)
{
this.handleRegist();
e.stopPropagation();
}
}}>
<div className="regist-content">
<div
className="regist-header"
style={{ textAlign: "center" }}>
<img
style={{
width: "80px",
height: "auto",
verticalAlign: "middle",
marginRight: "10px",
}}
src="http://t.qcad.cc/opzMainContent/fonts/03c1577dde7a97651283e2fde81928d2.png"
alt=""
/>
<h1>
<span style={{ color: "#2f7cff" }}></span>
</h1>
</div>
<div className="info-block" style={infoBlockStyle}>
<div style={{ width: "60%", minWidth: 395, margin: "0 auto" }}>
<div className="item">
<Label className={Classes.INLINE}>
<span>* </span>
<span></span>
</Label>
<Tooltip
content={this.errMsg}
position={Position.TOP}
intent={Intent.WARNING}
isOpen={this.flag === InputType.PSW}>
<InputGroup
type="password"
value={this.state.pass_word}
intent={this.inputIntent.PSW}
onChange={e =>
{
this.setState({ pass_word: e.target.value });
this.valueTest(InputType.PSW, e.target.value)
}}
onBlur={() => (this.flag = InputType.OK)}
/>
</Tooltip>
</div>
<div className="item">
<Label className={Classes.INLINE}>
<span>* </span>
<span></span>
</Label>
<Tooltip
content={this.errMsg}
position={Position.TOP}
intent={Intent.WARNING}
isOpen={this.flag === InputType.ComfirmPSW}>
<InputGroup
type="password"
value={this.state.pswConfirm}
intent={this.inputIntent.ComfirmPSW}
onChange={e =>
{
this.setState({ pswConfirm: e.target.value });
this.valueTest(InputType.ComfirmPSW, e.target.value);
}}
onBlur={() => (this.flag = InputType.OK)}
/>
</Tooltip>
</div>
<div className="item">
<Label className={Classes.INLINE}>
<span>* </span>
<span></span>
</Label>
<Tooltip
content={this.errMsg}
position={Position.TOP}
intent={Intent.WARNING}
isOpen={this.flag === InputType.PHONE}
>
<InputGroup
value={this.state.user_phone}
intent={this.inputIntent.PHONE}
onChange={e =>
{
this.setState({ user_phone: e.target.value });
this.valueTest(InputType.PHONE, e.target.value)
}}
onBlur={() => (this.flag = InputType.OK)}
/>
</Tooltip>
<Button
disabled={!(this.inputIntent.PHONE === Intent.SUCCESS) || !(this.SMSBtnText === "获取短信验证码")}
style={{ height: 30, marginLeft: 10 }}
text={this.SMSBtnText}
intent={Intent.NONE}
onClick={this.handleSMS}
/>
</div>
<div className="item">
<Label className={Classes.INLINE}>
<span>* </span>
<span></span>
</Label>
<InputGroup
value={this.state.check_code}
onChange={e =>
{
this.setState({ check_code: e.target.value });
}}
/>
</div>
</div>
</div>
<div className="regist-footer" style={infoBlockStyle}>
<div className="item center">
<div style={{ display: "flex" }}>
<Checkbox
checked={this.state.agreement_checked}
onChange={() =>
{
this.setState({ agreement_checked: !this.state.agreement_checked });
}}
/>
<span>
<a
target="_blank"
onClick={() => { this.openAgreement.set(true); }}
>
</a>
</span>
</div>
</div>
<div className="item center">
<Button
style={{ width: 173 }}
text="注册"
className="bp3-intent-success"
onClick={this.handleRegist}
/>
</div>
<div className="item center">
<a
target="_blank"
onClick={() => { this.props.store.openRegist = !this.props.store.openRegist; }}
>
</a>
</div>
</div>
</div>
<UserAgreement isOpen={this.openAgreement} />
</div>
);
}
}
interface IUserAgreementProps
{
isOpen: IObservableValue<boolean>;
}
@observer
class UserAgreement extends React.Component<IUserAgreementProps, {}> {
render()
{
return (
<Dialog
icon="info-sign"
className="user-agreement"
title="晨丰用户注册协议"
isOpen={this.props.isOpen.get()}
onClose={e => { this.props.isOpen.set(false); }}
>
<div
className={Classes.DIALOG_BODY}
style={{ padding: 20 }}
>
<p><strong></strong></p>
<p></p>
<p></p>
<p>"注册"</p>
<p>使使
<a
style={{ textDecoration: "none", color: "#106ba3" }}
href="http://www.ihome6.com"
>http://www.ihome6.com
</a>
使使</p>
<p><strong>1</strong></p>
<p></p>
<p><strong>2</strong></p>
<p>(1) </p>
<p>(2) </p>
<p>(3) 使AUTOCAD</p>
<p><strong>3</strong></p>
<p>(1) </p>
<p>(2) </p>
<p>(3) </p>
<p>(4) </p>
<p>(5) </p>
<p>(6) </p>
<p>(7) </p >
<p>(8) </p >
<p>(9) </p >
<p><strong> 4 </strong></p>
<p></p>
<p>(1) </p>
<p>(2) </p>
<p>(3) </p>
<p>(4) </p>
<p>(a) </p>
<p>(b) 使</p>
<p><strong>5. </strong></p>
<p>使</p>
<p><strong>6 </strong></p>
<p>使</p>
<p><strong>7 </strong></p>
<p></p>
<p>(1) </p>
<p>(2) </p>
<p>(3) </p>
<p>(4) </p>
<p><strong>8</strong></p>
<p>8.1 使</p>
<p>8.2 使使使使使使</p>
<p>8.3 </p>
<p>8.4 </p>
<p><strong>9 </strong></p>
<p>使 </p>
<p><strong>10</strong></p>
<p>使</p>
<p><strong>11</strong></p>
<p></p>
<p><strong>12</strong></p>
<p></p>
<p>(1) 使</p>
<p>(2) </p>
<p>(3) 使</p>
<p><strong>13</strong></p>
<p>使使</p>
<p><strong>14</strong></p>
<p>使</p>
<p>(1) 使</p>
<p>(2) </p>
<p>使</p>
<p>6使(使)</p>
<p><strong>15</strong></p>
<p></p>
<p><strong>16</strong></p>
<p>广广使</p>
<p><strong>17</strong></p>
<p>
</p>
</div>
<div className={Classes.DIALOG_FOOTER}
style={{ textAlign: "center" }}
>
<Button
text="同意协议并继续注册"
intent={Intent.DANGER}
onClick={e => this.props.isOpen.set(false)}
/>
</div>
</Dialog>
);
}
}

@ -1,5 +1,5 @@
.bp3-portal{
z-index: 34;
z-index: 38;
}
#commonModal .door{
.boardSize .bp3-input{

@ -10,6 +10,7 @@ export class TopPanelStore extends Singleton
@observable m_FileList: FileInfo[] = [];
@observable isLogin = false;
@observable openRegist = false;
@observable openMain = true;
constructor()
{

Loading…
Cancel
Save