recharge.js 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. define(['jquery', 'bootstrap', 'frontend'], function ($, undefined, Frontend) {
  2. var Controller = {
  3. recharge: function () {
  4. $(document).on("click", ".row-money label[data-type]", function () {
  5. $(".row-money label[data-type]").removeClass("active");
  6. $(this).addClass("active");
  7. $("#col-custom").toggleClass("hidden", $(this).data("type") === "fixed");
  8. $("input[name=money]").val($(this).data("value"));
  9. if ($(this).data("type") === 'custom') {
  10. $("input[name=custommoney]").trigger("focus").trigger("change");
  11. }
  12. });
  13. $(document).on("click", ".row-paytype label", function () {
  14. $(".row-paytype label").removeClass("active");
  15. $(this).addClass("active");
  16. $("input[name=paytype]").val($(this).data("value"));
  17. });
  18. $(document).on("keyup change", ".custommoney", function () {
  19. $("input[name=money]").val($(this).val());
  20. });
  21. $("#recharge-form").on("submit", function () {
  22. var price = parseFloat($("input[name=money]").val());
  23. if (isNaN(price) || price <= 0) {
  24. Layer.msg("充值金额不正确");
  25. return false;
  26. }
  27. });
  28. }
  29. };
  30. return Controller;
  31. });