Merge branch 'develop' into dev_aliyun

chromesetting
daiao 5 years ago
commit 303ac9fd1d

@ -291,10 +291,14 @@ class ApplicationController < ActionController::Base
# Returns the current user or nil if no user is logged in # Returns the current user or nil if no user is logged in
# and starts a session if needed # and starts a session if needed
def find_current_user def find_current_user
uid_logger("user setup start: session[:user_id] is #{session[:user_id]}") re_subdomain = "#{request.subdomain.split('.').first}_user_id"
if session[:user_id]
Rails.logger.info("find current_user: subdomain is #{re_subdomain} and user session is #{session[:user_id]} -- #{session[:"#{re_subdomain}"]}")
Rails.logger.info("-----------------------------")
Rails.logger.info("domain session is: #{session[:"#{request.subdomain.split('.').first}_user_id"]}")
if session[:"#{re_subdomain}"]
# existing session # existing session
(User.active.find(session[:user_id]) rescue nil) (User.active.find(session[:"#{re_subdomain}"]) rescue nil)
elsif autologin_user = try_to_autologin elsif autologin_user = try_to_autologin
autologin_user autologin_user
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth? elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?

@ -62,7 +62,21 @@ module LoginHelper
end end
def start_user_session(user) def start_user_session(user)
session[:user_id] = user.id re_subdomain = "#{request.subdomain.split('.').first}_user_id"
session[:"#{re_subdomain}"] = nil
session[:user_id] = nil
# session[:"#{re_subdomain}"] = user.id
Rails.logger.info("domain_user_id session is: 3333332222111#{session[:"#{re_subdomain}"]}")
Rails.logger.info("user_id session is: 3333332222111#{session[:user_id]}")
# if current_laboratory.main_site?
# session[:user_id] = user.id
# else
# session[:"#{request.subdomain}_user_id"] = user.id
# end
# session[:user_id] = user.id
session[:ctime] = Time.now.utc.to_i session[:ctime] = Time.now.utc.to_i
session[:atime] = Time.now.utc.to_i session[:atime] = Time.now.utc.to_i
end end

@ -27,7 +27,7 @@ class HacksController < ApplicationController
# 筛选过滤与排序 # 筛选过滤与排序
params_filter_or_order params_filter_or_order
# 我解决的编程题数 # 我解决的编程题数
user_codes = HackUserLastestCode.mine(current_user).passed.joins(:hack) user_codes = HackUserLastestCode.joins(:hack).mine(current_user).passed
@simple_count = user_codes.where(hacks: {difficult: 1}).count @simple_count = user_codes.where(hacks: {difficult: 1}).count
@medium_count = user_codes.where(hacks: {difficult: 2}).count @medium_count = user_codes.where(hacks: {difficult: 2}).count
@diff_count = user_codes.where(hacks: {difficult: 3}).count @diff_count = user_codes.where(hacks: {difficult: 3}).count

@ -58,7 +58,7 @@ class ConclusionEvaluation extends Component {
<span> <span>
<Tooltip placement="bottom" title={ <Tooltip placement="bottom" title={
<pre> <pre>
分数{record.eff_scores.eff_score}/总分{record.eff_score_full} 分数{record.eff_scores.eff_score}/总分{record.eff_scores.eff_score_full}
</pre> </pre>
}> }>
<span style={{color:'#FF6800'}}>{record.eff_scores.eff_score}</span><span className={"color-grey-9"}>/{record.eff_scores.eff_score_full}</span> <span style={{color:'#FF6800'}}>{record.eff_scores.eff_score}</span><span className={"color-grey-9"}>/{record.eff_scores.eff_score_full}</span>

@ -149,9 +149,9 @@ class ShixunsHome extends Component {
<style> <style>
{ {
` `
.shixunsHome .educontent { .shixunsHome .educontent {
width: 1223px; width: 1250px;
} }
.banners{ .banners{
overflow: hidden; overflow: hidden;
} }
@ -242,7 +242,7 @@ class ShixunsHome extends Component {
</div> </div>
<Link to={"/paths"} className="moreitem">更多<i className="fa fa-angle-right ml5"></i></Link> <Link to={"/paths"} className="moreitem">更多<i className="fa fa-angle-right ml5"></i></Link>
<div className="square-list clearfix" style={{width:'102%'}}> <div className="square-list clearfix" style={{width:'100%'}}>
{homedatalist===undefined?"":homedatalist.subjects.map((item,key)=>{ {homedatalist===undefined?"":homedatalist.subjects.map((item,key)=>{
@ -321,7 +321,7 @@ class ShixunsHome extends Component {
</div> </div>
<Link to={"/shixuns"} className="moreitem">更多<i className="fa fa-angle-right ml5"></i></Link> <Link to={"/shixuns"} className="moreitem">更多<i className="fa fa-angle-right ml5"></i></Link>
<div className="square-list clearfix" style={{width:'102%'}}> <div className="square-list clearfix" style={{width:'100%'}}>
<style> <style>
{ {
` `

@ -117,7 +117,16 @@ class Osshackathon extends Component {
this.props.showProfileCompleteDialog() this.props.showProfileCompleteDialog()
return return
} }
//判断是否绑定邮箱
if(this.props.user.email===null){
this.props.showhideAccountPhoneemailDialog()
return
}
if(this.props.user.phone===null){
this.props.showhideAccountPhoneemailDialog()
return
}
this.props.confirm({ this.props.confirm({
content: `是否确认报名?`, content: `是否确认报名?`,
onOk: () => { onOk: () => {

@ -11,7 +11,7 @@ import { Spin } from 'antd';
import './TPMIndex.css'; import './TPMIndex.css';
import LoginDialog from '../login/LoginDialog'; import LoginDialog from '../login/LoginDialog';
import AccountProfile from '../user/AccountProfile'; import AccountProfile from '../user/AccountProfile';
import AccountPhoneemail from '../user/AccountPhoneemail';
import Trialapplication from "../login/Trialapplication"; import Trialapplication from "../login/Trialapplication";
// import "antd/dist/antd.css"; // import "antd/dist/antd.css";
// import '../../css/educoder/edu-common.css' // import '../../css/educoder/edu-common.css'
@ -80,7 +80,7 @@ export function TPMIndexHOC(WrappedComponent) {
isRender: false, isRender: false,
AccountProfiletype: false, AccountProfiletype: false,
AccountPhoneemailtype:false,
globalLoading: false, globalLoading: false,
dataquerys:{}, dataquerys:{},
isloginCancel:undefined, isloginCancel:undefined,
@ -532,6 +532,17 @@ export function TPMIndexHOC(WrappedComponent) {
AccountProfiletype: true AccountProfiletype: true
}) })
} }
showhideAccountPhoneemailDialog = () => {
this.dialogObj = {}
this.setState({
AccountPhoneemailtype: true
})
}
hideAccountPhoneemailtype=()=>{
this.setState({
AccountPhoneemailtype:false
})
}
//验证是否完善资料 //验证是否完善资料
checkIfProfileCompleted = () => { checkIfProfileCompleted = () => {
return this.state.current_user && this.state.current_user.profile_completed return this.state.current_user && this.state.current_user.profile_completed
@ -625,7 +636,7 @@ export function TPMIndexHOC(WrappedComponent) {
} }
render() { render() {
let{Headertop,Footerdown, isRender, AccountProfiletype,mygetHelmetapi}=this.state; let{Headertop,Footerdown, isRender, AccountProfiletype,AccountPhoneemailtype}=this.state;
const common = { const common = {
isSuperAdmin:this.isSuperAdmin, isSuperAdmin:this.isSuperAdmin,
isAdminOrCreator:this.isAdminOrCreator, isAdminOrCreator:this.isAdminOrCreator,
@ -645,6 +656,7 @@ export function TPMIndexHOC(WrappedComponent) {
showLoginDialog: this.showLoginDialog, showLoginDialog: this.showLoginDialog,
checkIfLogin: this.checkIfLogin, checkIfLogin: this.checkIfLogin,
showProfileCompleteDialog: this.showProfileCompleteDialog, showProfileCompleteDialog: this.showProfileCompleteDialog,
showhideAccountPhoneemailDialog:this.showhideAccountPhoneemailDialog,
checkIfProfileCompleted: this.checkIfProfileCompleted, checkIfProfileCompleted: this.checkIfProfileCompleted,
checkIfProfessionalCertification: this.checkIfProfessionalCertification, checkIfProfessionalCertification: this.checkIfProfessionalCertification,
showProfessionalCertificationDialog: this.showProfessionalCertificationDialog, showProfessionalCertificationDialog: this.showProfessionalCertificationDialog,
@ -677,6 +689,13 @@ export function TPMIndexHOC(WrappedComponent) {
{...this.state} {...this.state}
{...this.dialogObj} {...this.dialogObj}
/>:""} />:""}
{/*验证是否注册手机邮箱*/}
{AccountPhoneemailtype===true?<AccountPhoneemail
hideAccountProfile={()=>this.hideAccountPhoneemailtype()}
{...this.props}
{...this.state}
{...this.dialogObj}
/>:""}
<SiderBar <SiderBar
{...this.props} {...this.props}
{...this.state} {...this.state}

@ -0,0 +1,79 @@
import React, { Component } from 'react';
import {getImageUrl} from 'educoder';
import {Modal} from 'antd';
import axios from 'axios';
class AccountPhoneemail extends Component {
constructor(props) {
super(props);
this.state = {
AccountPhoneemailtype:false
}
}
componentDidMount() {
if(this.props.AccountPhoneemailtype!=undefined){
this.setState({
AccountPhoneemailtype:this.props.AccountPhoneemailtype
})
}
axios.interceptors.response.use((response) => {
if (response != undefined)
if (response && response.data.status === 402) {
this.setState({
AccountPhoneemailtype: true
})
}
return response;
}, (error) => {
});
}
gotoback=()=>{
if(this.props.AccountPhoneemailtype!=undefined){
this.setState({
AccountPhoneemailtype:false
})
this.props.hideAccountProfile()
}else{
window.location.href="/";
this.setState({
AccountPhoneemailtype:false
})
}
}
/**
content: '您需要去完成您的职业认证,才能使用此功能',
okText: '立即完成',
okHref: '/account/certification'
*/
render() {
const { content, okText, okHref } = this.props;
return(
<Modal
keyboard={false}
title="提示"
visible={this.state.AccountPhoneemailtype}
closable={false}
footer={null}
destroyOnClose={true}
centered={true}
width="530px"
>
<div className="task-popup-content">
<p className="task-popup-text-center font-16"> 您需要完成手机号码和邮箱的绑定才能使用此功能</p>
<div className="clearfix mt30 edu-txt-center">
<a className="task-btn mr30" onClick={()=>this.gotoback()}>稍后完善</a>
<a className="task-btn task-btn-orange" href={ "/account/secure" }> {'立即完善'}</a>
</div>
</div>
</Modal>
)
}
}
export default AccountPhoneemail;

@ -154,7 +154,7 @@ class LoginRegisterComponent extends Component {
// console.log(this.props); // console.log(this.props);
let pcipns=this.IsPC(); let pcipns=this.IsPC();
if (this.props.match.url === "/login") { if (this.props.match.url === "/login") {
console.log("11111111111111111111111111");
// this.state = { // this.state = {
// tab:["0"], // tab:["0"],
// //
@ -163,7 +163,7 @@ class LoginRegisterComponent extends Component {
tab:["0"] tab:["0"]
}) })
} else if (this.props.match.url === "/register") { } else if (this.props.match.url === "/register") {
console.log("11111111111111111111111111");
// this.state = { // this.state = {
// tab:["1"], // tab:["1"],
// //
@ -968,6 +968,7 @@ class LoginRegisterComponent extends Component {
// window.location.href='http://www.cnblogs.com/a-cat/'; // window.location.href='http://www.cnblogs.com/a-cat/';
} }
return ( return (
<div className="login_register_content login_register_contents" <div className="login_register_content login_register_contents"
@ -1077,7 +1078,7 @@ class LoginRegisterComponent extends Component {
<Button className="login_btn font-16" type="primary" style={{height:"46px"}} onClick={() => this.postLogin()} <Button className="login_btn font-16" type="primary" style={{height:"46px"}} onClick={() => this.postLogin()}
size={"large"}>登录</Button> size={"large"}>登录</Button>
{this.props.user&&this.props.user.main_site===true?this.state.isphone===true?<p className="clearfix mb10 textcenter"> {this.props.mygetHelmetapi&&this.props.mygetHelmetapi.main_site===true?this.state.isphone===true?<p className="clearfix mb10 textcenter">
<span className={"startlogin"}> 快速登录 </span> <span className={"startlogin"}> 快速登录 </span>
<div className={"mt10"}> <div className={"mt10"}>
@ -1252,7 +1253,7 @@ class LoginRegisterComponent extends Component {
<Button className=" font-16 mb20" type="primary" style={this.props.mygetHelmetapi&&this.props.mygetHelmetapi.main_site===true?{height:"46px", width: "100%",marginTop:"26px"}:{height:"46px", width: "100%"}} onClick={() => this.postregistered()} <Button className=" font-16 mb20" type="primary" style={this.props.mygetHelmetapi&&this.props.mygetHelmetapi.main_site===true?{height:"46px", width: "100%",marginTop:"26px"}:{height:"46px", width: "100%"}} onClick={() => this.postregistered()}
size={"large"}>注册</Button> size={"large"}>注册</Button>
{this.props.user&&this.props.user.main_site===true?this.state.isphone===true?<p className="clearfix mb10 textcenter"> {this.props.mygetHelmetapi&&this.props.mygetHelmetapi.main_site===true?this.state.isphone===true?<p className="clearfix mb10 textcenter">
<span className={"startlogin"}> 快速登录 </span> <span className={"startlogin"}> 快速登录 </span>
<div className={"mt10"}> <div className={"mt10"}>

Loading…
Cancel
Save