geetest.blade.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script src="/base/js/jquery-2.1.1.min.js"></script>
  2. <script src="https://static.geetest.com/static/tools/gt.js"></script>
  3. <div id="{{ $captchaid }}"></div>
  4. <p id="wait-{{ $captchaid }}" class="show">正在加载验证码...</p>
  5. @define use Illuminate\Support\Facades\Config
  6. <script>
  7. var geetest = function(url) {
  8. var handlerEmbed = function(captchaObj) {
  9. $("#{{ $captchaid }}").closest('form').submit(function(e) {
  10. var validate = captchaObj.getValidate();
  11. if (!validate) {
  12. alert('{{ Config::get('geetest.client_fail_alert')}}');
  13. e.preventDefault();
  14. }
  15. });
  16. captchaObj.appendTo("#{{ $captchaid }}");
  17. captchaObj.onReady(function() {
  18. $("#wait-{{ $captchaid }}")[0].className = "hide";
  19. });
  20. if ('{{ $product }}' == 'popup') {
  21. captchaObj.bindOn($('#{{ $captchaid }}').closest('form').find(':submit'));
  22. captchaObj.appendTo("#{{ $captchaid }}");
  23. }
  24. };
  25. $.ajax({
  26. url: url + "?t=" + (new Date()).getTime(),
  27. type: "get",
  28. dataType: "json",
  29. success: function(data) {
  30. initGeetest({
  31. gt: data.gt,
  32. challenge: data.challenge,
  33. product: "{{ $product?$product:Config::get('geetest.product', 'float') }}",
  34. offline: !data.success,
  35. new_captcha: data.new_captcha,
  36. lang: '{{ Config::get('geetest.lang', 'zh-cn') }}',
  37. http: '{{ Config::get('geetest.protocol', 'http') }}' + '://'
  38. }, handlerEmbed);
  39. }
  40. });
  41. };
  42. (function() {
  43. geetest('{{ $url?$url:Config::get('geetest.url', 'geetest') }}');
  44. })();
  45. </script>
  46. <style>
  47. .hide {
  48. display: none;
  49. }
  50. </style>