暫無描述

scripts.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. jQuery(document).ready(function() {
  2. /*
  3. Fullscreen background
  4. */
  5. $.backstretch("/template/pc/js/botstrap-step/cb10b62fa1f10acac99339fcfc511914_1.jpg");
  6. $('#top-navbar-1').on('shown.bs.collapse', function(){
  7. $.backstretch("resize");
  8. });
  9. $('#top-navbar-1').on('hidden.bs.collapse', function(){
  10. $.backstretch("resize");
  11. });
  12. /*
  13. Form
  14. */
  15. $('.registration-form fieldset:first-child').fadeIn('slow');
  16. $('.registration-form input[type="text"], .registration-form input[type="password"], .registration-form textarea').on('focus', function() {
  17. $(this).removeClass('input-error');
  18. });
  19. // next step
  20. $('.registration-form .btn-next').on('click', function() {
  21. //校验字段
  22. var a = $('#choose2').val();
  23. console.log(a);
  24. if(a == 0){
  25. $('#myModal .modal-body p').html('请选择申报专业');
  26. $('#myModal').modal('show');
  27. return false;
  28. }
  29. var b = $('#choose3').val();
  30. console.log(a);
  31. if(b == 0){
  32. $('#myModal .modal-body p').html('请选择申报等级');
  33. $('#myModal').modal('show');
  34. return false;
  35. }
  36. console.log($(this).index());
  37. //调用专业
  38. if($(this).index() == 3) {
  39. $('#loadingModal').modal('show');
  40. $.ajax({
  41. url: '/api/Diyajax/getZcZyList',
  42. method: 'POST',
  43. dataType: 'json', // 指定响应数据为JSON
  44. data: {
  45. id: a
  46. },
  47. success: function (data) {
  48. // 请求成功后隐藏加载状态
  49. $('#loadingModal').modal('hide');
  50. // 处理返回的数据
  51. console.log('Ajax response:', data);
  52. console.log(data.data);
  53. var html = '';
  54. $.each(data.data, function (i, e) {
  55. console.log(e);
  56. html += '<p class="form-control-static" style="min-height:20px;padding-top:5px;padding-bottom:0px;"><label class="checkbox-inline"><input type="checkbox" name="zy[]" id="inlineCheckbox'+i+'" value="'+e.id+'"> '+e.title+'</label></p>';
  57. });
  58. if(html == ''){
  59. html = '暂无相关要求';
  60. }
  61. $('#zys').empty();
  62. $('#zys').append(html);
  63. },
  64. error: function (xhr, status, error) {
  65. // 请求失败后隐藏加载状态
  66. $('#loadingModal').modal('hide');
  67. // 处理错误
  68. console.error('Ajax error:', status, error);
  69. }
  70. });
  71. }
  72. //填完个人资料 点击下一步
  73. if($(this).index() == 6) {
  74. var b = $('#choose6').val();
  75. console.log(a);
  76. if(b == 0){
  77. $('#myModal .modal-body p').html('请选择年龄');
  78. $('#myModal').modal('show');
  79. return false;
  80. }
  81. var b = $('#choose5').val();
  82. console.log(a);
  83. if(b == 0){
  84. $('#myModal .modal-body p').html('请选择学历');
  85. $('#myModal').modal('show');
  86. return false;
  87. }
  88. var b = $('#choose7').val();
  89. console.log(a);
  90. if(b == 0){
  91. $('#myModal .modal-body p').html('请选择学校类型');
  92. $('#myModal').modal('show');
  93. return false;
  94. }
  95. //调用证书
  96. $('#loadingModal').modal('show');
  97. $.ajax({
  98. url: '/api/Diyajax/getZcZsList',
  99. method: 'POST',
  100. dataType: 'json', // 指定响应数据为JSON
  101. data: {
  102. id: a
  103. },
  104. success: function (data) {
  105. // 请求成功后隐藏加载状态
  106. $('#loadingModal').modal('hide');
  107. // 处理返回的数据
  108. console.log('Ajax response:', data);
  109. console.log(data.data);
  110. var html = '';
  111. var options = '';
  112. for(i=1;i<=30;i++) {
  113. options += '<option value="'+i+'">'+i+'年</option>';
  114. }
  115. $.each(data.data, function (i, e) {
  116. console.log(e);
  117. html += '<p class="form-control-static" style="min-height:20px;padding-top:5px;padding-bottom:0px;"><label class="checkbox-inline"><input type="checkbox" name="zs[]" id="inlineCheckbox' + i + '" value="' + e.id + '"> ' + e.title + '</label><font style="margin-left:15px;"><select className="form-control-s" name="zsnx[]">'+options+'</select></font></p>';
  118. });
  119. if(html == ''){
  120. html = '暂无相关要求,请进行下一步';
  121. }
  122. $('#zss').empty();
  123. $('#zss').append(html);
  124. },
  125. error: function (xhr, status, error) {
  126. // 请求失败后隐藏加载状态
  127. $('#loadingModal').modal('hide');
  128. // 处理错误
  129. console.error('Ajax error:', status, error);
  130. }
  131. });
  132. }
  133. if($(this).index() == 2) {
  134. //获取表单令牌 不能用接口直接过去 得用内部调用
  135. /*$('#loadingModal').modal('show');
  136. $.ajax({
  137. url: '/api/v1/api/get_token',
  138. method: 'POST',
  139. dataType: 'json', // 指定响应数据为JSON
  140. data: {},
  141. success: function (data) {
  142. // 请求成功后隐藏加载状态
  143. $('#loadingModal').modal('hide');
  144. // 处理返回的数据
  145. console.log('Ajax response:', data);
  146. console.log(data.data);
  147. $('#token').val(data.value);
  148. },
  149. error: function (xhr, status, error) {
  150. // 请求失败后隐藏加载状态
  151. $('#loadingModal').modal('hide');
  152. // 处理错误
  153. console.error('Ajax error:', status, error);
  154. }
  155. });*/
  156. }
  157. //继续下一屏切换
  158. var parent_fieldset = $(this).parents('fieldset');
  159. var next_step = true;
  160. parent_fieldset.find('input[type="text"], input[type="password"], textarea').each(function() {
  161. if( $(this).val() == "" ) {
  162. $(this).addClass('input-error');
  163. next_step = false;
  164. }
  165. else {
  166. $(this).removeClass('input-error');
  167. }
  168. });
  169. if( next_step ) {
  170. parent_fieldset.fadeOut(400, function() {
  171. $(this).next().fadeIn();
  172. });
  173. }
  174. });
  175. // previous step
  176. $('.registration-form .btn-previous').on('click', function() {
  177. $(this).parents('fieldset').fadeOut(400, function() {
  178. $(this).prev().fadeIn();
  179. });
  180. });
  181. // submit
  182. $('.registration-form').on('submit', function(e) {
  183. /*$(this).find('input[type="text"], input[type="password"], textarea').each(function() {
  184. if( $(this).val() == "" ) {
  185. e.preventDefault();
  186. $(this).addClass('input-error');
  187. }
  188. else {
  189. $(this).removeClass('input-error');
  190. }
  191. });*/
  192. function isValidPhoneNumber(phoneNumber) {
  193. var regex = /^1[3-9]\d{9}$/; // 中国手机号码正则表达式,以1开头,第二位是3-9,后面跟着9位数字
  194. return regex.test(phoneNumber);
  195. }
  196. //开始手动验证
  197. var a = $('#per-name').val();
  198. var b = $('#per-phone').val();
  199. var c = $('#per-code').val();
  200. if(a == ''){
  201. $('#myModal .modal-body p').html('请输入您的称呼');
  202. $('#myModal').modal('show');
  203. return false;
  204. }
  205. if(b == ''){
  206. $('#myModal .modal-body p').html('请输入您的手机号码');
  207. $('#myModal').modal('show');
  208. return false;
  209. }
  210. console.log(isValidPhoneNumber(b));
  211. if(isValidPhoneNumber(b) === false){
  212. $('#myModal .modal-body p').html('请输入正确的手机号码格式');
  213. $('#myModal').modal('show');
  214. return false;
  215. }
  216. if(c == ''){
  217. $('#myModal .modal-body p').html('请输入验证码');
  218. $('#myModal').modal('show');
  219. return false;
  220. }
  221. //发送表单信息到后台
  222. $('#loadingModal .visually-hidden').html('获取结果中...');
  223. $('#loadingModal').modal('show');
  224. var formData = $('.registration-form').serializeArray();
  225. console.log(formData);
  226. $.ajax({
  227. url: '/api/Diyajax/insData',
  228. method: 'POST',
  229. dataType: 'json', // 指定响应数据为JSON
  230. data: formData,
  231. success: function(data) {
  232. // 请求成功后隐藏加载状态
  233. $('#loadingModal').modal('hide');
  234. // 处理返回的数据
  235. console.log('Ajax response:', data);
  236. $('#loadingModal .visually-hidden').html(data.msg);
  237. $('#loadingModal').modal('show');
  238. if(data.code == 0){
  239. setTimeout(function() {
  240. $('#loadingModal').modal('hide');
  241. }, 3000); // 5秒后取消定时器
  242. }else{
  243. //成功
  244. setTimeout(function() {
  245. $('#loadingModal').modal('hide');
  246. //跳转到结果页
  247. location.href = 'https://www.zc10000.com/cp?h='+data.data.code;
  248. }, 2000); // 5秒后取消定时器
  249. }
  250. },
  251. error: function(xhr, status, error) {
  252. // 请求失败后隐藏加载状态
  253. $('#loadingModal').modal('hide');
  254. // 处理错误
  255. console.error('Ajax error:', status, error);
  256. }
  257. });
  258. return false;
  259. });
  260. });