Merge branches 'dev_aliyun', 'yslcompetition' and 'ysm1' of https://bdgit.educoder.net/Hjqreturn/educoder into yslcompetition

dev_sync_trustie
杨树林 5 years ago
commit a8c55e8b28

@ -107,6 +107,19 @@ $(document).on('turbolinks:load', function(){
}
});
//添加主办方或者开放范围
function addSponsor(item){
var html='<div class="sponsor_label">\n' +
' <input type="hidden" value="school_id" />\n' +
' <span>caicai</span>\n' +
' <a href="javascript:void(0)" onclick="del_sponsor(this)">×</a>\n' +
' </div>';
$(item).parents(".sponsorPanel").append(html);
}
//删除
function del_sponsor(item){
$(item).parents(".sponsor_label").remove();
}
$(function () {
//MD编辑

@ -40,6 +40,33 @@
line-height: 20px;
}
.sponsor_label{
border:1px solid #4CACFF;
border-radius: 5px;
background-color: rgba(76,172,255,0.3);
color: #333;
padding:0px 4px;
height: 30px;
line-height: 30px;
float: left;
margin: 4px 5px;
span{
display: block;
float: left;
height: 28px;
line-height: 28px;
margin-right: 5px;
}
a{
font-size: 18px;
float: left;
height: 28px;
line-height: 28px;
}
}
.large_panel{
padding:0px 15px;

@ -29,6 +29,7 @@ input.form-control {
.flex-1 {
flex: 1;
}
.fl{float: left}
.no_padding{padding: 0px!important;}
.font-12 { font-size: 12px !important; }
.font-14 { font-size: 14px !important; }

@ -121,6 +121,7 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
@all_count = teams.count
@all_teams = paginate(teams.includes(:user, users: { user_extension: :school }))
@all_member_count = current_competition.team_members.count
end
def user_competition_teams

@ -69,7 +69,7 @@ class Competitions::CompetitionsController < Competitions::BaseController
end
def update_md_content
tip_exception("标题和内容不能为空") if params[:name].blank? || params[:content].blank?
tip_exception("内容不能为空") if params[:content].blank?
tip_exception("缺少competition_module_id") if params[:competition_module_id].blank?
ActiveRecord::Base.transaction do
com_module = current_competition.competition_modules.find_by!(id: params[:competition_module_id])

@ -0,0 +1,51 @@
class Weapps::VerificationCodesController < Weapps::BaseController
before_action :require_wechat_login!
def create
params[:type] == 'register' ? check_can_register : check_can_reset_password
end
private
def check_can_register
login = params[:login].to_s.strip
if login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
user = User.find_by(mail: login)
return render_error('该邮箱已注册') if user.present?
elsif login =~ /^1\d{10}$/
user = User.find_by(phone: params[:login])
return render_error('该手机号已注册') if user.present?
else
return render_error('请输入正确的邮箱或手机号')
end
code = %W(0 1 2 3 4 5 6 7 8 9)
verification_code = code.sample(6).join
send_type = login =~ /^1\d{10}$/ ? 1 : 8
# 记录验证码
check_verification_code(verification_code, send_type, login)
render_ok
end
def check_can_reset_password
login = params[:login].to_s.strip
if login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
user = User.find_by(mail: login)
return render_error('该邮箱尚未注册') if user.blank?
elsif login =~ /^1\d{10}$/
user = User.find_by(phone: login)
return render_error('该手机号尚未注册') if user.blank?
else
return render_error('请输入正确的邮箱或手机号')
end
code = %W(0 1 2 3 4 5 6 7 8 9)
verification_code = code.sample(6).join
send_type = login =~ /^1\d{10}$/ ? 2 : 3
# 记录验证码
check_verification_code(verification_code, send_type, login)
render_ok
end
end

@ -3,7 +3,7 @@ class CompetitionModule < ApplicationRecord
belongs_to :competition
has_one :competition_module_md_content, dependent: :destroy
has_many :competition_module_md_contents, dependent: :destroy
def module_url
result_url = url.present? ? url : case module_type

@ -93,12 +93,31 @@
</div>
</div>
<div class="row align-items-center mb-2">
<div class="row align-items-center d-flex mb-2">
<div class="col-1 text-right">
主办方
</div>
<div class="col-5 text-left">
<div class="flex-1 text-left sponsorPanel">
<a href="javascript:void(0)" class="btn btn-white fl ml10" onclick="addSponsor(this)">+</a>
<div class="sponsor_label">
<input type="hidden" value="school_id" />
<span>caicai</span>
<a href="javascript:void(0)" onclick="del_sponsor(this)">×</a>
</div>
</div>
</div>
<div class="row align-items-center d-flex mb-2">
<div class="col-1 text-right">
开放范围
</div>
<div class="flex-1 text-left sponsorPanel">
<a href="javascript:void(0)" class="btn btn-white fl ml10" onclick="addSponsor(this)">+</a>
<div class="sponsor_label">
<input type="hidden" value="school_id" />
<span>caicai</span>
<a href="javascript:void(0)" onclick="del_sponsor(this)">×</a>
</div>
</div>
</div>
@ -324,7 +343,7 @@
<div class="card-body">
<div id="large_panel" class="large_panel">
<% if @competition.competition_stages.count > 0 %>
<% @competition.competition_stages.each do |stage| %>
<% @competition.competition_stages.each_with_index do |stage, index| %>
<%= form_tag(admins_competition_competition_stage_path(competition_id: @competition.id, id: stage.id), method: :put, class: 'stage_update_form flex-1', remote: true) do %>
<div class="large_panel_part" attr_line="1">
<div class="row d-flex">
@ -345,42 +364,44 @@
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">保存</a>
</div>
<div id="small_panel_1" class="small_panel">
<div class="row d-flex small_panel_item" attr_line="sub_1_1" count="1">
<span class="col-1 mt-2 subName">第1阶段</span>
<div class="flex-1">
<div class="row">
<span class="mt-2 ml20">有效时间:</span>
<div class="col-2 no_padding input_middle">
<input class="use_time_begin_1_1 form-control" placeholder="有效开始时间"/>
</div>
<span class="mt-2">~</span>
<div class="col-2 no_padding input_middle">
<input class="use_time_end_1_1 form-control" placeholder="有效结束时间"/>
</div>
<span class="col-2 text-right mt-2 no_padding">任务完成要求:</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control" name="task_require_small_1_1"/>
</div>
<span class="mt-2 ml10 mr10">/</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control task_all" onchange="change_total(this)" name="task_require_all_1_1"/>
</div>
<span class=" mt-2">(总任务)</span>
<span class="col-1 text-right mt-2 no_padding">成绩来源:</span>
<div class="col-2 no_padding input_middle">
<select class="form-control" name="source_1_1">
<option>经验值</option>
<option>预测准确率</option>
</select>
<div id="small_panel_<%= index + 1 %>" class="small_panel">
<% stage.competition_stage_sections.each_with_index do |section, j| %>
<div class="row d-flex small_panel_item" attr_line="sub_1_1" count="<%= j + 1 %>">
<span class="col-1 mt-2 subName">第<%= j + 1 %>阶段</span>
<div class="flex-1">
<div class="row">
<span class="mt-2 ml20">有效时间:</span>
<div class="col-2 no_padding input_middle">
<%= text_field_tag 'stage[][start_time]', section.start_time&.strftime('%Y-%m-%d %H:%M'), autocomplete: 'off', class: 'section_start_time form-control', placeholder: '有效开始时间' %>
</div>
<span class="mt-2">~</span>
<div class="col-2 no_padding input_middle">
<%= text_field_tag 'stage[][end_time]', section.end_time&.strftime('%Y-%m-%d %H:%M'), autocomplete: 'off', class: 'section_end_time form-control', placeholder: '有效结束时间' %>
</div>
<span class="col-2 text-right mt-2 no_padding">任务完成要求:</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control" name="stage[][end_time]"/>
</div>
<span class="mt-2 ml10 mr10">/</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control task_all" onchange="change_total(this)" name="task_require_all_1_1"/>
</div>
<span class=" mt-2">(总任务)</span>
<span class="col-1 text-right mt-2 no_padding">成绩来源:</span>
<div class="col-2 no_padding input_middle">
<select class="form-control" name="source_1_1">
<option>经验值</option>
<option>预测准确率</option>
</select>
</div>
</div>
<div class="row mt-2" id="task_Input_sub_1_1"></div>
</div>
<div class="row mt-2" id="task_Input_sub_1_1"></div>
</div>
<span>
<span>
<a href="javascript:void(0)" class="btn btn-default ml20 small_panel_item_del">删除</a>
</span>
</div>
</div>
<% end %>
</div>
</div>
<% end %>

@ -1,6 +1,6 @@
json.extract! @module, :id, :name, :position, :url
md = @module.competition_module_md_content
md = @module.competition_module_md_contents.take
if md.present?
json.md_id md.id
json.md_name md.name

@ -1,4 +1,5 @@
json.count @all_count
json.members_count @all_member_count
json.personal @personal
json.competition_name @competition.name
json.competition_teams do

@ -21,6 +21,7 @@ json.stages
if @competition.mode == 2
json.course_id @competition.competition_mode_setting&.course_id
json.invite_code @competition.competition_mode_setting&.course&.invite_code
json.member_of_course @user.member_of_course?(@competition.competition_mode_setting&.course)
end

@ -852,6 +852,7 @@ Rails.application.routes.draw do
resource :home, only: [:show]
resource :session, only: [:create]
resource :register, only: [:create]
resource :verification_code, only: [:create]
resource :code_session, only: [:create]
resource :verify, only: [:create]
resource :check_account, only: [:create]

@ -1,10 +0,0 @@
class AddColumnToStageSections < ActiveRecord::Migration[5.2]
def change
def change
add_column :competition_stage_sections, :mission_count, :integer, default: 0
add_column :competition_stage_sections, :score_source, :integer, default: 0
add_column :competition_entries, :shixun_identifier, :string
end
end
end

@ -0,0 +1,8 @@
class AddColumnToStageSections < ActiveRecord::Migration[5.2]
def change
add_column :competition_stage_sections, :mission_count, :integer, default: 0
add_column :competition_stage_sections, :score_source, :integer, default: 0
add_column :competition_entries, :shixun_identifier, :string
end
end

@ -60,6 +60,23 @@ class CompetitionCommon extends Component{
}).catch((error) => {
console.log(error)
})
//console.log(this.props)
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)=>{
@ -80,7 +97,7 @@ class CompetitionCommon extends Component{
})
}
getrightdata=(id,typeid,module_url,has_url)=>{
console.log(id,typeid,module_url,has_url)
this.setState({
module_id:id,
module_type:typeid
@ -122,10 +139,47 @@ class CompetitionCommon extends Component{
}
gotocourse=(url)=>{
if(this.props.checkIfLogin()===false){
this.props.showLoginDialog()
return
}
if(this.props.checkIfProfileCompleted()===false){
this.props.showProfileCompleteDialog()
return
}
if(url===undefined){
let {data,signupdata}=this.state;
if(signupdata.enrolled===true){
this.props.history.replace(`/courses/${data.course_id}`);
}else{
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,
student:1
}
).then((response) => {
if(response.data.status===0){
this.props.history.replace(`/courses/${data.course_id}`);
}
})
}
}
}else{
this.props.history.replace(url);
}
}
render() {
let {data,bannerdata,module_type,Competitionedittype,mdContentdata}=this.state;
console.log(module_type)
return (
data===undefined?"":<div className={"educontent clearfix mt20 "}>
@ -174,7 +228,7 @@ class CompetitionCommon extends Component{
<div className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516">{data.competition_status==="nearly_published"?"--":data&&data.visits_count}</div>
</Col>
<Col className="gutter-row" span={6}>
<div className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516">{data.competition_status==="nearly_published"?"--":data&&data.member_count}</div>
<div className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516" onClick={()=>this.gotocourse(`/newcompetitions/${this.props.match.params.identifier}/enroll`)}>{data.competition_status==="nearly_published"?"--":data&&data.member_count}</div>
</Col>
</Row>
</Col>
@ -204,10 +258,9 @@ class CompetitionCommon extends Component{
<Button type="primary" block className={"Competitionfontsize22"} disabled={true}>
已结束
</Button>:
<Button type="primary" block className={"Competitionfontsize22"}>
{data.competition_status==="nearly_published"?
this.props.current_user&&this.props.current_user.admin===true?<Link to={`/newcompetitions/${this.props.match.params.identifier}/enroll`}>立即报名</Link>:this.props.current_user&&this.props.current_user.business===true?<Link to={`/newcompetitions/${this.props.match.params.identifier}/enroll`}></Link>:<a></a>:<Link to={`/newcompetitions/${this.props.match.params.identifier}/enroll`}></Link>}
</Button>}
data.competition_status==="progressing"?<Button type="primary" block className={"Competitionfontsize22"}>
{data.mode===2?<a onClick={()=>this.gotocourse()}>立即报名</a>:<a onClick={()=>this.gotocourse(`/newcompetitions/${this.props.match.params.identifier}/enroll`)}></a>}
</Button>:""}
</Col>
<Col className={"mt10 Competitionfontsize16"}>{data&&data.enroll_end_time===null?"":`报名截止时间:${data&&data.enroll_end_time}`}</Col>
</Col>

@ -100,7 +100,6 @@ class CompetitionContentsMd extends Component{
md_content_id:this.props.mdContentdata.md_id,
competition_module_id:this.props.mdContentdata.id,
content:mdContnet,
name:"编辑",
attachment_ids:attachment_ids
}
).then((response) => {

Loading…
Cancel
Save