dev_bj
daiao 5 years ago
commit 63f9a3cac1

@ -2,7 +2,7 @@
class Competition < ActiveRecord::Base
# status 0下架 1上架
attr_accessible :end_time, :identifier, :name, :online_time, :start_time, :status, :visits, :competition_lists_count,
:min_num, :max_num, :enroll_end_time, :sub_title
:min_num, :max_num, :enroll_end_time, :sub_title, :published_at
has_many :competition_modules, :dependent => :destroy
has_many :competition_stages, :dependent => :destroy

@ -1,47 +1,71 @@
<div class="openSource_1" style="background: url('/images/educoder/competition/qg/qg_open_1.png') no-repeat top center;"></div>
<div class="openSource_2" style="background: url('/images/educoder/competition/qg/qg_open_2.png') no-repeat top center;"></div>
<div class="openSource_3" style="background: url('/images/educoder/competition/qg/qg_open_3.png') no-repeat top center;">
<% index = 0 %>
<div class="openSource_1" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_2" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<% @competition.competition_stages.each_with_index do |stage, i| %>
<div class="openSource_<%= index + 1 %>" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;">
<%
first_section = stage.competition_stage_sections[0]
second_section = stage.competition_stage_sections[1]
%>
<div class="enter_panel" style="height: 285px">
<ul>
<p class="font-22 enter_title padding30 clearfix">
<span class="fl ml30">
<span class="mr20 font-bd">开源任务征集</span>
<span>2019年7月1日~2019年7月20日</span>
<span class="mr20 font-bd"><%= first_section.try(:name) %></span>
<span><%= first_section.start_time.try(:strftime, '%Y年%m月%d日') %> ~ <%= first_section.end_time.try(:strftime, '%Y年%m月%d日') %></span>
</span>
<span class="fr mr30">
<span class="mr20 font-bd">开源任务发布</span>
<span>2019年7月21日</span>
<span class="mr20 font-bd"><%= second_section.try(:name) %></span>
<span><%= second_section.try(:start_time).try(:strftime, '%Y年%m月%d日') %> ~ <%= second_section.try(:end_time).try(:strftime, '%Y年%m月%d日') %></span>
</span>
</p>
<li class="inline enter_btn mt20">
<a href="javascript:void(0);" class="li-1">项目名称1</a>
<a href="javascript:void(0);" class="li-1">项目名称2</a>
<a href="javascript:void(0);" class="li-1">项目名称3</a>
<% is_start = Time.now > first_section.start_time %>
<% first_section.competition_entries.each_with_index do |entry, j| %>
<%
competition_url = User.current.logged? ? "#{entry.url}?eid=#{User.current.id}" : "#{entry.url}"
btn_url = is_start ? "#{competition_url}" : "javascript:void(0);"
%>
<a class="li-1 <%= is_start ? 'active' : '' %>"
href="javascript:void(0);"
data-url="<%= btn_url %>"><%= entry.name %></a>
<% end %>
</li>
</ul>
</div>
</div>
<div class="openSource_4" style="background: url('/images/educoder/competition/qg/qg_open_4.png') no-repeat top center;">
<div class="enter_panel" style="height: 285px">
<ul>
<p class="font-22 enter_title padding30 clearfix">
<span class="fl ml30">
<span class="mr20 font-bd">开源开发阶段</span>
<span>2019年7月1日~2019年7月20日</span>
</span>
<span class="fr mr30">
<span class="mr20 font-bd">成绩发布阶段</span>
<span>2019年7月21日</span>
</span>
</p>
<li class="inline enter_btn mt20">
<a href="javascript:void(0);" class="li-1">项目名称1</a>
<a href="javascript:void(0);" class="li-1">项目名称2</a>
<a href="javascript:void(0);" class="li-1">项目名称3</a>
</li>
</ul>
</div>
</div>
<div class="openSource_5" style="background: url('/images/educoder/competition/qg/qg_open_5.png') no-repeat top center;"></div>
<div class="openSource_6" style="background: url('/images/educoder/competition/qg/qg_open_6.png') no-repeat top center;"></div>
<div class="openSource_7" style="background: url('/images/educoder/competition/qg/qg_open_7.png') no-repeat top center;"></div>
<% index += 1 %>
<% end %>
<div class="openSource_5" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_6" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_7" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<script>
$(function(){
var userLogged = <%= @user.present? && @user.logged? %>;
var userEnrolled = <%= @enrolled %>;
$(".enter_btn .li-1.active").on("click", function(){
var url = $(this).data("url");
if (!userLogged) {
location.href = "<%= signin_url(back_url: competition_path(id: params[:id])) %>";
return;
}
if (!userEnrolled) {
sure_box_redirect_without_newtab_btn("<%= enroll_competition_path(id: params[:id]) %>", "完成报名后即可参赛", "我要报名");
return;
}
var newTab = window.open("_blank");
newTab.location = url;
})
})
</script>

@ -69,13 +69,14 @@
</div>
</div>
<% elsif competition.published_at.present? %>
<% url = admin_or_business? ? competition_path(competition) : 'javascript:void(0)' %>
<div class="competitionsList-item mb20">
<div class="edu-back-white">
<a href="javascript:void(0)" class="competition-Img">
<a href="<%= url %>" class="competition-Img">
<%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %>
</a>
<div class="pt20 pl20 mb10 clearfix">
<a href="javascript:void(0)" style="max-width: 400px;" class="font-16 task-hide fl"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<a href="<%= url %>" style="max-width: 400px;" class="font-16 task-hide fl"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<div class="fr status-orange">
<img src="/images/educoder/competition/home/orange.png" class="fl">
<span class="status-tag fl">即将发布</span>
@ -83,6 +84,11 @@
</div>
<p class="color-grey-B3 clearfix pl20 pr20 pb20"></p>
</div>
<div class="competitionsList-item-tip strongNone">
<div class="color-white font-26">
<p>即将发布</p><p>敬请期待</p>
</div>
</div>
</div>
<% end %>
<% end %>
@ -91,3 +97,14 @@
<%= render :partial => "welcome/no_data" %>
<% end %>
</div>
<script>
$(function(){
<% unless admin_or_business? %>
$(".competitionsList-item").hover(function(){
$(this).find(".competitionsList-item-tip").removeClass("strongNone");
},function(){
$(this).find(".competitionsList-item-tip").addClass("strongNone");
});
<% end %>
})
</script>

@ -13,5 +13,7 @@
<%= render :partial => "gq_second_code_competition" %>
<% elsif @competition.identifier == "gcc-course-2019" %>
<%= render :partial => "qg_second_course_competition" %>
<% elsif @competition.identifier == "gcc-project-2019" %>
<%= render :partial => "qg_second_opensource" %>
<% end %>
</div>

@ -898,9 +898,14 @@ table.tBodyScroll thead th{
.homePageBtn{position: absolute;width: 100%;top: 510px;}
.homeBtn{display: block;float: left;border-radius: 30px;width: 168px;height: 60px;line-height: 60px;background-color: #21B351;font-size: 30px;color: #fff!important;text-align: center}
.competitionsList-item{width: 50%;float: left;box-sizing: border-box;}
.competitionsList-item{width: 50%;float: left;box-sizing: border-box;position: relative}
.competitionsList-item:nth-of-type(odd){padding-right: 10px;}
.competitionsList-item:nth-of-type(even){padding-left: 10px;}
.competitionsList-item-tip{
position: absolute;top: 0px;left: 0px;height: 100%;background: rgba(0,0,0,0.5);right: 10px;justify-content: center;
align-items: center;display: -webkit-flex;
}
.strongNone{display: none!important;}
.competition-Img{width: 100%;height: 340px;}
.competition-Img img{border-radius: 4px 4px 0px 0px;}
.status-tag {display: block;height: 30px;line-height: 30px;color: #fff;padding: 0px 20px;}

Loading…
Cancel
Save