微信登录 end

competitions
杨树明 5 years ago
parent 5348725dc0
commit 11094bf00f

@ -64,6 +64,12 @@ const EducoderLogin = Loadable({
loader: () => import('./modules/login/EducoderLogin'),
loading: Loading,
})
//微信登录
const Otherlogin=Loadable({
loader: () => import('./modules/login/Otherlogin'),
loading: Loading,
})
const TestIndex = Loadable({
loader: () => import('./modules/test'),
loading: Loading,
@ -406,6 +412,9 @@ class App extends Component {
<Route
path="/register" component={EducoderLogin}
/>
<Route
path="/otherlogin" component={Otherlogin}
/>
<Route path="/users/:username"
render={
(props) => {

@ -1702,3 +1702,46 @@ input.ant-input-number-input:focus {
.yslinputcourput .ant-form-explain{
padding-left: 0px !important;
}
.wechatloginfont{
font-size: 14px;
font-family: PingFangSC-Regular,PingFangSC;
font-weight: 400;
color: #555555;
line-height: 20px;
margin-top: 10px;
}
.wechatdiv{
margin-top: 40px !important;
width: 800px !important;
}
.wechatContent{
padding: 0px 50px;
}
.wechatpass{
width: 300px;
height: 46px;
}
.wechatnewchat{
width: 62px;
height: 62px;
background: rgba(255,170,170,1);
border-radius: 50%;
text-align: center;
line-height: 62px;
color: #fff;
margin: 0 auto;
}
.wechatweoldchat{
width: 62px;
height: 62px;
background:rgba(164,211,255,1);
border-radius: 50%;
text-align: center;
line-height: 62px;
color: #fff;
margin: 0 auto;
}

@ -638,7 +638,7 @@ class LoginDialog extends Component {
frameBorder="0"
sandbox="allow-scripts allow-same-origin allow-top-navigation"
scrolling="no"
src="https://open.weixin.qq.com/connect/qrconnect?appid=wx6b119e2d829c13fa&redirect_uri=https%3a%2f%2fwww.educoder.net%2f&response_type=code&scope=snsapi_login#wechat_redirect"></iframe>:""}
src="https://open.weixin.qq.com/connect/qrconnect?appid=wx6b119e2d829c13fa&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherlogin&response_type=code&scope=snsapi_login#wechat_redirect"></iframe>:""}
{weixinlogin===true?<p className="clearfix">
<a className={"startlogin color-blue"} onClick={()=>this.hideweixinlogin()}>返回账号登录</a>
</p>:""}

@ -0,0 +1,313 @@
import React, {Component} from "react";
import {
Form,
Select,
Input,
Button,
Checkbox,
Upload,
Icon,
message,
Modal,
Table,
Divider,
InputNumber,
Tag,
DatePicker,
Radio,
Tooltip,
notification,
Layout,
Spin
} from "antd";
import axios from 'axios';
const { Header, Footer, Sider, Content } = Layout;
import { getImageUrl } from 'educoder'
import {Link, Switch, Route, Redirect} from 'react-router-dom';
import '../courses/css/members.css';
import "../courses/common/formCommon.css"
import '../courses/css/Courses.css';
import beijintulogontwo from '../../../src/images/login/beijintulogontwo.png';
import educodernet from '../../../src/images/login/educodernet.png';
//educoder登入页面
var sectionStyle = {
"height": "100%",
"width": "100%",
"min-width": "1000px",
// makesure here is String确保这里是一个字符串以下是es6写法
};
var imgback = {
" background-size":"cover",
"background-repeat":"no-repeat",
backgroundImage: `url(${beijintulogontwo})`,
}
var imgmian ={
width: "100%",
background: `url(${beijintulogontwo})`,
position: "relative",
}
var newContainer={
// background: `url(${beijintulogontwo})`,
backgroundPosition: "center" ,
backgroundRepeat: "no-repeat",
backgroundAttachment: "fixed",
backgroundSize: "100% 100%",
height:" 100%",
width:" 100%",
position: "absolute",
top: "0px",
bottom: "0px",
minHeight: "100%",
paddingTop: "40px",
}
class Otherlogin extends Component {
constructor(props) {
super(props);
this.state={
login:undefined,
password:undefined,
data:undefined,
logintypes:undefined,
spinnings:true
}
}
getinfo=()=>{
let url = `/users/get_user_info.json`
axios.get(url).then((result)=> {
console.log(result);
if(result){
this.setState({
data:result.data,
spinnings:false
})
}
}).catch((error)=>{
this.setState({
spinnings:false
})
})
}
componentDidMount() {
let query=this.props.location.search;
const type = query.split('?code=');
const types = type[1].split('&state=');
let codeurl = `/auth/wechat/callback.json`
axios.get(codeurl,{params:{
code:types[0]
}}).then((result)=> {
if(result){
if(result.data.status===0){
if(result.data.true===false){
this.getinfo()
}else{
// this.getinfo()
window.location.href="/"
}
}
}
}).catch((error)=>{
this.setState({
spinnings:false
})
})
}
loginInputonChange=(e)=>{
if(e.target.value===undefined||e.target.value===""||e.target.value===null){
}else{
if(this.state.logintypes==="username"){
this.setState({
logintypes:undefined
})
}
}
this.setState({
login:e.target.value,
})
}
passwordonChange=(e)=>{
if(e.target.value===undefined||e.target.value===""||e.target.value===null){
}else{
if(this.state.logintypes==="password"){
this.setState({
logintypes:undefined
})
}
}
this.setState({
password:e.target.value,
})
}
postwechatlogin=(type,username,password)=>{
if(type===false){
if(username===undefined||username===""||username===null){
this.setState({
logintypes:"username"
})
return
}
if(password===undefined||password===""||password===null){
this.setState({
logintypes:"password"
})
return
}
}
let url = "/bind_user.json";
axios.post(url, {
type: 'wechat',
not_bind:type,
username:username,
password:password
}).then((response) => {
if(response.data.status===0){
window.location.href="/"
}
}).catch((error) => {
console.log(error)
});
}
render() {
let {data,logintypes,spinnings} = this.state;
console.log(logintypes)
return (
<div style={newContainer} className=" clearfix" >
<Spin size="large" spinning={spinnings} >
<style>
{
`
#root{
background:#fff !important;
}
`
}
</style>
<div>
<div style={{
"width": "100%"
}}>
<div >
<div className={"textcenter"} >
<img src={getImageUrl(data&&data.image_url)}/>
</div>
<div className={"textcenter wechatloginfont"}>
为了更好的为您服务请关联一个EduCoder账号
</div>
</div>
<div className={"educontent clearfix wechatdiv"}>
<style>
{
`
.ant-layout,.ant-layout-sider,.ant-layout-content{
background: #FFF;
}
.ant-layout-header {
height: 50px;
padding: 0 48px;
line-height: inherit;
background: #001529;
background: #FFF;
font-size: 14px;
font-family: PingFangSC-Regular,PingFangSC;
font-weight: 400;
color: rgba(0,0,0,1);
}
.ant-layout-footer {
padding: 0px 50px;
background: #FFF;
}
.wechattiyan{
width:300px;
height:46px;
background:rgba(25,144,255,1);
border-radius:4px;
}
`
}
</style>
<p>
<Layout>
<Sider>
<div className={"wechatnewchat"}>
新用户
</div>
</Sider>
<Layout>
<Header>欢迎来到EduCoder新用户登录EduCoder可以到账号管理-安全设置中绑定手机/邮箱以后可以用绑定的手机/邮箱设置的密码登录EduCoder了</Header>
<Content className={"wechatContent"}>立即体验表示您已经同意我们的 <span><a href="https://forge.educoder.net/help?index=4" target="_blank" className={"color-blue"}> 服务协议条款</a></span></Content>
<Footer>
<Button className="login_btn font-16 wechattiyan" type="primary" style={{height:"46px"}} onClick={() => this.postwechatlogin(true)}
size={"large"}>立即体验</Button>
</Footer>
</Layout>
</Layout>
</p>
<Divider />
<p>
<Layout>
<Sider>
<div className={"wechatweoldchat"}>
老用户
</div>
</Sider>
<Layout>
<Header>已有EduCoder账号可以输入您的账号和密码将您的微信账号与EduCoder账号进行绑定</Header>
<Content className={"wechatContent"}>
<Input placeholder="请输入手机号/邮箱/登录名"
value={this.state.login}
onInput={this.loginInputonChange}
className={this.state.logintypes==="username"?"bor-red mb20 wechatpass":" mb20 wechatpass"}
></Input>
<Input value={this.state.password}
onInput={this.passwordonChange}
className={this.state.logintypes==="password"?"bor-red wechatpass":" wechatpass"}
placeholder="请输入密码"></Input>
</Content>
{this.state.logintypes==="username"?<span className={"color-red ml50"}>请填写账号</span>:this.state.logintypes==="password"?<span className={"color-red ml50"}></span>:""}
<Footer>
<Button className="login_btn font-16 wechattiyan" type="primary" style={{height:"46px"}} onClick={() => this.postwechatlogin(false,this.state.login,this.state.password)}
size={"large"}>绑定</Button>
</Footer>
</Layout>
</Layout>
</p>
</div>
</div>
<div style={{
display: "flex",
justifyContent: "center",
width: "100%",
}}>
<div className="font-14 color-grey-9 " style={{marginTop:"20px"}}><span className="font-18">©</span>&nbsp;2019&nbsp;EduCoder<span className="ml15 mr15">ICP17009477</span><a href="https://team.trustie.net" style={{"color":"#888"}} target="_blank">Trustie</a>&nbsp;&nbsp;&nbsp;&amp;&nbsp;&nbsp;&nbsp;IntelliDE inside.</div>
</div>
</div>
</Spin>
</div>
)
}
}
export default Otherlogin;

@ -1163,7 +1163,7 @@ class LoginRegisterComponent extends Component {
color: '#676767',
}}>我已阅读并同意
<span>
<a href={'/help?index=4'} target="_blank" className={"color-blue"}>服务协议条款</a>
<a href={'https://forge.educoder.net/help?index=4'} target="_blank" className={"color-blue"}>服务协议条款</a>
</span></span></Checkbox>
<Button className=" font-16 mb20" type="primary" style={{height:"46px", width: "100%",marginTop:"26px"}} onClick={() => this.postregistered()}
size={"large"}>注册</Button>
@ -1184,7 +1184,7 @@ class LoginRegisterComponent extends Component {
frameBorder="0"
sandbox="allow-scripts allow-same-origin allow-top-navigation"
scrolling="no"
src="https://open.weixin.qq.com/connect/qrconnect?appid=wx6b119e2d829c13fa&redirect_uri=https%3a%2f%2fwww.educoder.net%2f&response_type=code&scope=snsapi_login#wechat_redirect"></iframe>:""}
src="https://open.weixin.qq.com/connect/qrconnect?appid=wx6b119e2d829c13fa&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherlogin&response_type=code&scope=snsapi_login#wechat_redirect"></iframe>:""}
{weixinlogin===true?<p className="clearfix mb20 textcenter">
<a className={"startlogin color-blue"} onClick={()=>this.hideweixinlogin()}>返回登录注册</a>
</p>:""}

Loading…
Cancel
Save