modify trainings

dev_trainings
p31729568 6 years ago
parent aeb3fe9b0e
commit 3a301499ca

@ -17,10 +17,22 @@ class TrainingsController < ApplicationController
def show
@training = current_training
if @training.training_payinfo.present? && params[:disable_redirect].blank?
redirect_to result_training_path(id: friendly_id)
return
end
render 'trainingsInfo'
end
def enroll
@training = current_training || Training.new
if @training.training_payinfo.present? && params[:disable_redirect].blank?
redirect_to result_training_path(id: friendly_id)
return
end
end
def pay
@ -80,6 +92,11 @@ class TrainingsController < ApplicationController
def result
@training = current_training
if @training.training_payinfo.blank?
redirect_to training_path(id: friendly_id)
return
end
end
def create
@ -89,18 +106,14 @@ class TrainingsController < ApplicationController
save_training
flash[:message] = '报名成功'
redirect_to training_path(id: friendly_id)
redirect_to training_path(id: friendly_id, disable_redirect: true)
end
def update
@training = current_training
save_training
flash[:message] = '保存成功'
redirect_to training_path(id: friendly_id)
redirect_to training_path(id: friendly_id, disable_redirect: true)
end

@ -46,6 +46,10 @@ class TrainingPayinfo < ActiveRecord::Base
status.nil? || status == Status_None
end
def offline_pay?
pay_type.to_i == PayType_bank
end
def payed?
status == Status_Payed
end

@ -36,10 +36,20 @@
</div>
</div>
<div class="infoBar mb10">
<p class="clearfix" id="billLine" NavShow>
<span class="grey fl">发票</span>
<label class="fr" id="billDemand" status=2 style="margin-right: 24px;">不需要</label>
<i class="iconfont icon-gengduo1 rightArrow" style="color: #323232;right: 14px"></i>
<!-- <p class="clearfix" id="billLine" NavShow>-->
<!-- <span class="grey fl">发票</span>-->
<!-- <label class="fr" id="billDemand" status=2 style="margin-right: 24px;">不需要</label>-->
<!-- <i class="iconfont icon-gengduo1 rightArrow" style="color: #323232;right: 14px"></i>-->
<!-- </p>-->
<p class="clearfix" id="billRemark">
<span class="grey fl">发票抬头</span>
<input type="text" name="invoice_title" class="right_input" placeholder="请填写发票抬头"
value="<%= @training.training_payinfo.try(:invoice_title) || @training.school %>"/>
</p>
<p class="clearfix" id="billRemark">
<span class="grey fl">税务登记号</span>
<input type="text" name="invoice_no" class="right_input" placeholder="请填写税务登记号"
value="<%= @training.training_payinfo.try(:invoice_no) %>"/>
</p>
<p class="clearfix" id="billRemark">
<span class="grey fl">发票内容</span>
@ -79,39 +89,38 @@
</div>
<p style="height: 44px;"></p>
<div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i == 1 ? "none" : "" %>" id="offlinePaySubmitBtn">
<a href="<%= training_path(id: @friendly_id) %>" class="leftbtn">返回</a>
<a href="<%= training_path(id: @friendly_id, disable_redirect: true) %>" class="leftbtn">返回</a>
<a href="javascript:void(0)" class="rightbtn" id="submitFormBtn">完成转账</a>
</div>
<div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i == 1 ? "" : "none" %>" id="paySubmitBtn">
<a href="<%= training_path(id: @friendly_id) %>" class="leftbtn">返回</a>
<a href="<%= training_path(id: @friendly_id, disable_redirect: true) %>" class="leftbtn">返回</a>
<a href="javascript:void(0)" class="rightbtn" id="payBtn">立即支付</a>
</div>
</div>
<div class="billDownNav downNav">
<div class="pr billPanel">
<p class="clearfix mb10">
<span class="fl billBigTitle">发票抬头</span>
<a href="javascript:void(0)" class="fr" id="closeTypeNav"><i class="iconfont icon-guanbi billClose"></i></a>
</p>
<ul class="clearfix billType">
<li>单位</li>
<li>个人</li>
<li class="active">不需要</li>
</ul>
<p class="clearfix needWrite none">
<span class="fl billSmallTitle mb10">发票抬头</span>
</p>
<ul class="clearfix needWrite none">
<input placeholder="请填写公司单位名称" name="invoice_title" class="billInput billUnit"/>
<input placeholder="请填写税务登记号" name="invoice_no" class="billInput taxNumber"/>
</ul>
<p style="height:48px;"></p>
<a href="javascript:void(0)" class="submitBillInfo" id="commonSubmit" onclick="submitBillInfo();">确定</a>
</div>
</div>
<!-- <div class="billDownNav downNav">-->
<!-- <div class="pr billPanel">-->
<!-- <p class="clearfix mb10">-->
<!-- <span class="fl billBigTitle">发票类型</span>-->
<!-- <a href="javascript:void(0)" class="fr" id="closeTypeNav"><i class="iconfont icon-guanbi billClose"></i></a>-->
<!-- </p>-->
<!-- <ul class="clearfix billType">-->
<!-- <li>个人</li>-->
<!-- <li>单位</li>-->
<!-- </ul>-->
<!-- <p class="clearfix needWrite none">-->
<!-- <span class="fl billSmallTitle mb10">发票信息</span>-->
<!-- </p>-->
<!-- <ul class="clearfix needWrite none">-->
<!-- <input placeholder="请填写公司单位名称" name="invoice_title" class="billInput billUnit"/>-->
<!-- <input placeholder="请填写税务登记号" name="invoice_no" class="billInput taxNumber"/>-->
<!-- </ul>-->
<!-- <p style="height:48px;"></p>-->
<!-- <a href="javascript:void(0)" class="submitBillInfo" id="commonSubmit" onclick="submitBillInfo();">确定</a>-->
<!-- </div>-->
<!-- </div>-->
<div class="payTypeDownNav downNav">
<div class="pr billPanel">
@ -151,24 +160,24 @@
invoiceNo: '<%= @training.training_payinfo.invoice_no %>'
};
//点击弹出发票弹框
aboutBillType(userInfo);
// aboutBillType(userInfo);
//点击弹出支付方式弹框
aboutPayType();
//初始化发票类型
InitBill(userInfo);
// InitBill(userInfo);
//切换发票类型
$(".billType li").on("click", function () {
$(".billType li").removeClass("active");
$(this).addClass("active");
billTypeShowFun(parseInt($(this).index()), userInfo);
})
//关闭弹窗
$(".billClose").on("click", function () {
hideNav($(".downNav"));
});
// $(".billType li").on("click", function () {
// $(".billType li").removeClass("active");
// $(this).addClass("active");
// billTypeShowFun(parseInt($(this).index()), userInfo);
// })
// //关闭弹窗
// $(".billClose").on("click", function () {
// hideNav($(".downNav"));
// });
//延迟支付,直接提交
$('#delayPayBtn').on('click', function () {
@ -298,16 +307,12 @@
}
//页面加载时,初始化发票类型
function InitBill(userInfo){
var index=0;
$("#billDemand").html("单位").attr("status",0);
var index=1;
$("#billDemand").html("单位").attr("status",1);
if (!userInfo.newPayinfo) {
if(userInfo.invoiceTitle == "" && userInfo.invoiceNo == ""){
index=2;
$("#billDemand").html("不需要").attr("status",2);
}
if(userInfo.invoiceTitle != "" && userInfo.invoiceNo == ""){
index=1;
$("#billDemand").html("个人").attr("status",1);
index=0;
$("#billDemand").html("个人").attr("status",0);
}
}
$(".billType li").removeClass("active");
@ -315,17 +320,14 @@
billTypeShowFun(index,userInfo);
}
function billTypeShowFun(index, userInfo){
if (parseInt(index) == 0) {
if (parseInt(index) == 1) {
$(".needWrite").removeClass("none");
$(".billUnit").attr("placeholder", "请填写公司单位名称").val(userInfo.invoiceTitle || userInfo.school);
$(".taxNumber").removeClass("none").val(userInfo.invoiceNo);
} else if (parseInt(index) == 1) {
} else if (parseInt(index) == 0) {
$(".needWrite").removeClass("none");
$(".billUnit").attr("placeholder", "请填写姓名").val(userInfo.name);
$(".taxNumber").val('').addClass("none");
} else {
$(".needWrite").addClass("none");
$(".billInput").val('');
}
}
@ -408,23 +410,16 @@
}
function checkBillInfo() {
var bill = $("#billLine");
var billNav = $(".billDownNav");
var status = $("#billDemand").attr("status");
if(status == 2){
$(".billInput").val('');
if ($("input[name='invoice_title']").val() == '') {
alert("请填写发票抬头");
return false;
}
var billUnit = $('.billUnit').val();
var taxNumber = $('.taxNumber').val();
if(status == 1 && billUnit == ''){
alert('请将发票信息填写完整');
showNav(bill, billNav, "down");
if ($("input[name='invoice_no']").val() == '') {
alert("请填写税务登记号");
return false;
}
if(status == 0 && (billUnit == '' || taxNumber == '')){
alert('请将发票信息填写完整');
showNav(bill, billNav, "down");
if ($("input[name='invoice_content']").val() == '') {
alert("请填写发票内容");
return false;
}

@ -102,10 +102,10 @@
<div class="bottomBtn">
<% if @training.training_payinfo.wechat_wait_pay? %>
<%= link_to "返回", training_path(id: @friendly_id), class: 'leftbtn' %>
<%= link_to "返回", training_path(id: @friendly_id, disable_redirect: true), class: 'leftbtn' %>
<a href="javascript:void(0)" class="rightbtn" id="wechatPayBtn">立即支付</a>
<% else%>
<%= link_to "返回", pay_training_path(id: @friendly_id), class: 'rightbtn', style: 'width: 100%' %>
<%= link_to "返回", training_path(id: @friendly_id, disable_redirect: true), class: 'rightbtn', style: 'width: 100%' %>
<% end %>
</div>
</div>

@ -1,40 +1,47 @@
<div class="InfoTop">
<div>
<p class="font-22 color-white" style="text-align: center;"><span class="inline"><i class="iconfont icon-wancheng font-30 color-white mr10 fl"></i>报名成功</span></p>
</div>
</div>
<div class="Infos">
<p class="Infos_title">基本信息</p>
<li class="clearfix">
<span>姓名</span>
<span>胡莎莎</span>
</li>
<li class="clearfix">
<span>性别</span>
<span>女</span>
</li>
<li class="clearfix">
<span>单位</span>
<span>国防科技大学</span>
</li>
<li class="clearfix">
<span>职称</span>
<span>助教</span>
</li>
<li class="clearfix">
<span>手机号</span>
<span>181****2757</span>
</li>
<div>
<p class="font-22 color-white" style="text-align: center;"><span class="inline"><i class="iconfont icon-wancheng font-30 color-white mr10 fl" style="font-size: 20px;"></i>报名成功</span></p>
</div>
</div>
<div class="Infos">
<p class="Infos_title">基本信息</p>
<li class="clearfix">
<span>姓名</span>
<span><%= @training.name %></span>
</li>
<li class="clearfix">
<span>性别</span>
<span><%= @training.sex == 1 ? '男' : '女' %></span>
</li>
<li class="clearfix">
<span>单位</span>
<span><%= @training.school %></span>
</li>
<li class="clearfix">
<span>职称</span>
<span><%= @training.position %></span>
</li>
<li class="clearfix">
<span>手机号</span>
<span><%= @training.phone %></span>
</li>
</div>
<% if @training.training_type == 3 %>
<div class="Infos clearfix">
<p class="Infos_title">您关注的课程类型</p>
<a href="javascript:void(0)" class="Infos_tag">程序设计</a>
<a href="javascript:void(0)" class="Infos_tag">操作系统</a>
<a href="javascript:void(0)" class="Infos_tag">软件工程</a>
<a href="javascript:void(0)" class="Infos_tag">程序设计</a>
<% @training.research_field.to_s.split(',').each do |name| %>
<a href="javascript:void(0)" class="Infos_tag"><%= name %></a>
<% end %>
</div>
<% end %>
<%= link_to('修改资料', enroll_training_path(id: @friendly_id, disable_redirect: true), class: 'info_updateBtn') %>
<% if @training.training_payinfo.blank? %>
<div class="bottomBtn">
<%= link_to '转账支付', pay_training_path(id: @friendly_id, pay_type: 3), class: 'leftbtn' %>
<%#= link_to '微信支付', pay_training_path(id: @friendly_id, pay_type: 1), class: 'rightbtn' %>
<a href="javascript:void(0)" onclick="alert('即将开通');" class="rightbtn">微信支付</a>
</div>
<a href="javascript:void(0)" class="info_updateBtn">修改资料</a>
<div class="Infos_btn">
<a href="javascript:void(0)">转账支付</a>
<a href="javascript:void(0)">微信支付</a>
</div>
<% end %>

@ -269,7 +269,7 @@ input[type='text'].right_input{
/* 支付信息 */
.InfoTop{width: 100%;height: 6.5rem;background: linear-gradient(to right, #4CC6FF , #6588F8);justify-content: center;
align-items: center;display: -webkit-flex;}
align-items: center;display: -webkit-flex;font-size: 1.6rem;color: white;}
.info_updateBtn{
display: block;
width: 60%;
@ -278,7 +278,7 @@ input[type='text'].right_input{
text-align: center;
border: 1px solid #4CC6FF;
border-radius: 24px;
font-size: 2.2rem;
font-size: 1.6rem;
color: #4CC6FF!important;
margin-top: 1rem;margin:2rem auto;
}
@ -290,8 +290,8 @@ input[type='text'].right_input{
.Infos li{margin-bottom: 8px;}
.Infos li span:first-child{color: #666666;font-size: 1.4rem;float: left;}
.Infos li span:last-child{color: #333;font-size: 1.4rem;float: right;}
.Infos .Infos_tag{float: left;height:2.8rem;padding: 0px 0.5rem;box-sizing: border-box;line-height: 2.8rem;
background: #E6F3FF;color: #4CACFF;cursor: default;margin-right: 1.5rem;
.Infos .Infos_tag{float: left;height:2.0rem;padding: 0px 0.5rem;box-sizing: border-box;line-height: 2.0rem;
background: #E6F3FF;color: #4CACFF;cursor: default;margin-right: 1.5rem;margin-bottom: 1.0rem;
}
.Infos_btn {background: #fff;height: 5rem;line-height: 5rem;position: absolute;bottom: 0px;left:0px;width: 100%;}
.Infos_btn a{

Loading…
Cancel
Save