diff --git a/app/controllers/trainings_controller.rb b/app/controllers/trainings_controller.rb index 2a9ed1c2..834509d3 100644 --- a/app/controllers/trainings_controller.rb +++ b/app/controllers/trainings_controller.rb @@ -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 diff --git a/app/models/training_payinfo.rb b/app/models/training_payinfo.rb index fbb7e9dc..9882c095 100644 --- a/app/models/training_payinfo.rb +++ b/app/models/training_payinfo.rb @@ -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 diff --git a/app/views/trainings/pay.html.erb b/app/views/trainings/pay.html.erb index 4cebcc83..9ec09189 100644 --- a/app/views/trainings/pay.html.erb +++ b/app/views/trainings/pay.html.erb @@ -36,10 +36,20 @@
-

- 发票 - - + + + + + +

+ 发票抬头 + +

+

+ 税务登记号 +

发票内容 @@ -79,39 +89,38 @@

" id="offlinePaySubmitBtn"> - 返回 + 返回 完成转账
" id="paySubmitBtn"> - 返回 + 返回 立即支付
-
-
-

- 发票抬头 - -

- -

- 发票抬头 -

- -

- 确定 -
-
+ + + + + + + + + + + + + + + + + + + + +
@@ -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; } diff --git a/app/views/trainings/result.html.erb b/app/views/trainings/result.html.erb index c397ce31..6a660ca1 100644 --- a/app/views/trainings/result.html.erb +++ b/app/views/trainings/result.html.erb @@ -102,10 +102,10 @@
<% 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' %> 立即支付 <% 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 %>
diff --git a/app/views/trainings/trainingsInfo.html.erb b/app/views/trainings/trainingsInfo.html.erb index 7fd2840c..f6292b6f 100644 --- a/app/views/trainings/trainingsInfo.html.erb +++ b/app/views/trainings/trainingsInfo.html.erb @@ -1,40 +1,47 @@
-
-

报名成功

-
-
-
-

基本信息

-
  • - 姓名 - 胡莎莎 -
  • -
  • - 性别 - -
  • -
  • - 单位 - 国防科技大学 -
  • -
  • - 职称 - 助教 -
  • -
  • - 手机号 - 181****2757 -
  • +
    +

    报名成功

    +
    +
    +

    基本信息

    +
  • + 姓名 + <%= @training.name %> +
  • +
  • + 性别 + <%= @training.sex == 1 ? '男' : '女' %> +
  • +
  • + 单位 + <%= @training.school %> +
  • +
  • + 职称 + <%= @training.position %> +
  • +
  • + 手机号 + <%= @training.phone %> +
  • +
    + +<% if @training.training_type == 3 %>

    您关注的课程类型

    - 程序设计 - 操作系统 - 软件工程 - 程序设计 + <% @training.research_field.to_s.split(',').each do |name| %> + <%= name %> + <% end %> +
    +<% end %> + +<%= link_to('修改资料', enroll_training_path(id: @friendly_id, disable_redirect: true), class: 'info_updateBtn') %> + +<% if @training.training_payinfo.blank? %> +
    + <%= 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' %> + 微信支付
    - 修改资料 -
    - 转账支付 - 微信支付 -
    \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/public/stylesheets/educoder/trainings.css b/public/stylesheets/educoder/trainings.css index 1823c264..e9a73727 100644 --- a/public/stylesheets/educoder/trainings.css +++ b/public/stylesheets/educoder/trainings.css @@ -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{