modify trainings

dev_trainings
p31729568 6 years ago
parent aeb3fe9b0e
commit 3a301499ca

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

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

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

@ -102,10 +102,10 @@
<div class="bottomBtn"> <div class="bottomBtn">
<% if @training.training_payinfo.wechat_wait_pay? %> <% 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> <a href="javascript:void(0)" class="rightbtn" id="wechatPayBtn">立即支付</a>
<% else%> <% 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 %> <% end %>
</div> </div>
</div> </div>

@ -1,40 +1,47 @@
<div class="InfoTop"> <div class="InfoTop">
<div> <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> <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> </div>
<div class="Infos"> <div class="Infos">
<p class="Infos_title">基本信息</p> <p class="Infos_title">基本信息</p>
<li class="clearfix"> <li class="clearfix">
<span>姓名</span> <span>姓名</span>
<span>胡莎莎</span> <span><%= @training.name %></span>
</li> </li>
<li class="clearfix"> <li class="clearfix">
<span>性别</span> <span>性别</span>
<span>女</span> <span><%= @training.sex == 1 ? '男' : '' %></span>
</li> </li>
<li class="clearfix"> <li class="clearfix">
<span>单位</span> <span>单位</span>
<span>国防科技大学</span> <span><%= @training.school %></span>
</li> </li>
<li class="clearfix"> <li class="clearfix">
<span>职称</span> <span>职称</span>
<span>助教</span> <span><%= @training.position %></span>
</li> </li>
<li class="clearfix"> <li class="clearfix">
<span>手机号</span> <span>手机号</span>
<span>181****2757</span> <span><%= @training.phone %></span>
</li> </li>
</div> </div>
<% if @training.training_type == 3 %>
<div class="Infos clearfix"> <div class="Infos clearfix">
<p class="Infos_title">您关注的课程类型</p> <p class="Infos_title">您关注的课程类型</p>
<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">操作系统</a> <a href="javascript:void(0)" class="Infos_tag"><%= name %></a>
<a href="javascript:void(0)" class="Infos_tag">软件工程</a> <% end %>
<a href="javascript:void(0)" class="Infos_tag">程序设计</a>
</div> </div>
<a href="javascript:void(0)" class="info_updateBtn">修改资料</a> <% end %>
<div class="Infos_btn">
<a href="javascript:void(0)">转账支付</a> <%= link_to('修改资料', enroll_training_path(id: @friendly_id, disable_redirect: true), class: 'info_updateBtn') %>
<a href="javascript:void(0)">微信支付</a>
<% 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> </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; .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{ .info_updateBtn{
display: block; display: block;
width: 60%; width: 60%;
@ -278,7 +278,7 @@ input[type='text'].right_input{
text-align: center; text-align: center;
border: 1px solid #4CC6FF; border: 1px solid #4CC6FF;
border-radius: 24px; border-radius: 24px;
font-size: 2.2rem; font-size: 1.6rem;
color: #4CC6FF!important; color: #4CC6FF!important;
margin-top: 1rem;margin:2rem auto; margin-top: 1rem;margin:2rem auto;
} }
@ -290,8 +290,8 @@ input[type='text'].right_input{
.Infos li{margin-bottom: 8px;} .Infos li{margin-bottom: 8px;}
.Infos li span:first-child{color: #666666;font-size: 1.4rem;float: left;} .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 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; .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; 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 {background: #fff;height: 5rem;line-height: 5rem;position: absolute;bottom: 0px;left:0px;width: 100%;}
.Infos_btn a{ .Infos_btn a{

Loading…
Cancel
Save