No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scripts.js 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. jQuery(document).ready(function() {
  2. checkBrowserWidth();
  3. $(window).resize(checkBrowserWidth); // 当窗口大小改变时重新检查
  4. function checkBrowserWidth() {
  5. var browserWidth = $(window).width();
  6. if (browserWidth < 1001) {
  7. //alert('浏览器宽度小于600像素');
  8. $.backstretch("/template/pc/js/botstrap-step/bg2.png");
  9. }else{
  10. $.backstretch("/template/pc/js/botstrap-step/bg.jpg");
  11. }
  12. }
  13. /*
  14. Fullscreen background
  15. */
  16. //$.backstretch("/template/pc/js/botstrap-step/bg.jpg");
  17. $('#top-navbar-1').on('shown.bs.collapse', function(){
  18. $.backstretch("resize");
  19. });
  20. $('#top-navbar-1').on('hidden.bs.collapse', function(){
  21. $.backstretch("resize");
  22. });
  23. /*
  24. Form
  25. */
  26. $('.registration-form fieldset:first-child').fadeIn('slow');
  27. $('.registration-form input[type="text"], .registration-form input[type="password"], .registration-form textarea').on('focus', function() {
  28. $(this).removeClass('input-error');
  29. });
  30. // next step
  31. $('.registration-form .btn-next').on('click', function() {
  32. var a11 = $('#choose11').val();
  33. var a12 = $('#choose12').val();
  34. if(a11 == 0 || a12 == 0){
  35. $('#myModal .modal-body p').html('请选择您所在城市');
  36. $('#myModal').modal('show');
  37. return false;
  38. }
  39. //校验字段
  40. var a = $('#choose2').val();
  41. console.log(a);
  42. if(a == 0){
  43. $('#myModal .modal-body p').html('请选择申报专业');
  44. $('#myModal').modal('show');
  45. return false;
  46. }
  47. var b = $('#choose3').val();
  48. console.log(a);
  49. if(b == 0){
  50. $('#myModal .modal-body p').html('请选择申报等级');
  51. $('#myModal').modal('show');
  52. return false;
  53. }
  54. console.log($(this).index());
  55. //调用专业
  56. if($(this).index() == 4) {
  57. //隐藏查询表单
  58. $('#sele-box').hide();
  59. $('.ssl-box').hide();
  60. $('#loadingModal').modal('show');
  61. $.ajax({
  62. url: '/api/Diyajax/getZcZyList',
  63. method: 'POST',
  64. dataType: 'json', // 指定响应数据为JSON
  65. data: {
  66. id: a
  67. },
  68. success: function (data) {
  69. // 请求成功后隐藏加载状态
  70. $('#loadingModal').modal('hide');
  71. // 处理返回的数据
  72. console.log('Ajax response:', data);
  73. console.log(data.data);
  74. var html = '';
  75. var html2 = '';
  76. $.each(data.data, function (i, e) {
  77. console.log(e);
  78. 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>';
  79. html2 += '<span class="hjk">'+e.title+'</span>';
  80. });
  81. if(html == ''){
  82. //隐藏
  83. $('#zy_box').hide();
  84. html = '暂无相关要求';
  85. }
  86. if(html2 == ''){
  87. //隐藏
  88. $('#zy_box').hide();
  89. html2 = '暂无相关要求';
  90. }
  91. $('#zys').empty();
  92. $('#zys').append(html);
  93. $('#zys-list').empty();
  94. $('#zys-list').append(html2);
  95. },
  96. error: function (xhr, status, error) {
  97. // 请求失败后隐藏加载状态
  98. $('#loadingModal').modal('hide');
  99. // 处理错误
  100. console.error('Ajax error:', status, error);
  101. }
  102. });
  103. }
  104. //填完个人资料 点击下一步
  105. if($(this).index() == 7) {
  106. var b = $('#choose6').val();
  107. console.log(a);
  108. if(b == 0){
  109. $('#myModal .modal-body p').html('请选择年龄');
  110. $('#myModal').modal('show');
  111. return false;
  112. }
  113. var b = $('#choose5').val();
  114. console.log(a);
  115. if(b == 0){
  116. $('#myModal .modal-body p').html('请选择学历');
  117. $('#myModal').modal('show');
  118. return false;
  119. }
  120. var b = $('#choose7').val();
  121. console.log(a);
  122. if(b == 0){
  123. $('#myModal .modal-body p').html('请选择学校类型');
  124. $('#myModal').modal('show');
  125. return false;
  126. }
  127. var b33 = $('#choose33').val();
  128. console.log(a);
  129. if(b33 == 0){
  130. $('#myModal .modal-body p').html('请选择毕业时间');
  131. $('#myModal').modal('show');
  132. return false;
  133. }
  134. //调用证书
  135. $('#loadingModal').modal('show');
  136. $.ajax({
  137. url: '/api/Diyajax/getZcZsList',
  138. method: 'POST',
  139. dataType: 'json', // 指定响应数据为JSON
  140. data: {
  141. id: a
  142. },
  143. success: function (data) {
  144. // 请求成功后隐藏加载状态
  145. $('#loadingModal').modal('hide');
  146. // 处理返回的数据
  147. console.log('Ajax response:', data);
  148. console.log(data.data);
  149. var html = '';
  150. var options = '';
  151. for(i=1;i<=30;i++) {
  152. options += '<option value="'+i+'">'+i+'年</option>';
  153. }
  154. $.each(data.data, function (i, e) {
  155. console.log(e);
  156. html += '<p class="form-control-static" style="min-height:20px;padding-top:5px;padding-bottom:0px;"><label class="checkbox-inline" style="margin-top: -4px;font-size: 15px;"><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>';
  157. });
  158. if(html == ''){
  159. html = '暂无相关要求(0.5s后自动进行下一步)';
  160. //直接点击跳转下一步
  161. //ajax异步是一个线程
  162. //定时器也是一个独立线程
  163. //ajax直接执行点击有问题 放到定时器里面即可
  164. $('#zss').attr('data','no');
  165. setTimeout(function() {
  166. $('#jumpBtn').trigger('click');
  167. //$('#jumpBtn').parent().parent().hide();
  168. }, 500); //大于400
  169. }else{
  170. $('#zss').attr('data','yes');
  171. }
  172. $('#zss').empty();
  173. $('#zss').append(html);
  174. },
  175. error: function (xhr, status, error) {
  176. // 请求失败后隐藏加载状态
  177. $('#loadingModal').modal('hide');
  178. // 处理错误
  179. console.error('Ajax error:', status, error);
  180. }
  181. });
  182. }
  183. if($(this).index() == 2) {
  184. //获取表单令牌 不能用接口直接过去 得用内部调用
  185. /*$('#loadingModal').modal('show');
  186. $.ajax({
  187. url: '/api/v1/api/get_token',
  188. method: 'POST',
  189. dataType: 'json', // 指定响应数据为JSON
  190. data: {},
  191. success: function (data) {
  192. // 请求成功后隐藏加载状态
  193. $('#loadingModal').modal('hide');
  194. // 处理返回的数据
  195. console.log('Ajax response:', data);
  196. console.log(data.data);
  197. $('#token').val(data.value);
  198. },
  199. error: function (xhr, status, error) {
  200. // 请求失败后隐藏加载状态
  201. $('#loadingModal').modal('hide');
  202. // 处理错误
  203. console.error('Ajax error:', status, error);
  204. }
  205. });*/
  206. }
  207. //继续下一屏切换
  208. var parent_fieldset = $(this).parents('fieldset');
  209. var next_step = true;
  210. parent_fieldset.find('input[type="text"], input[type="password"], textarea').each(function() {
  211. if( $(this).val() == "" ) {
  212. $(this).addClass('input-error');
  213. next_step = false;
  214. }
  215. else {
  216. $(this).removeClass('input-error');
  217. }
  218. });
  219. if( next_step ) {
  220. parent_fieldset.fadeOut(400, function() {
  221. $(this).next().fadeIn();
  222. });
  223. }
  224. });
  225. // previous step
  226. $('.registration-form .btn-previous').on('click', function() {
  227. console.log($(this).index());
  228. if($(this).index() == 6){
  229. //隐藏查询表单
  230. $('#sele-box').show();
  231. //$('.ssl-box').show();
  232. }
  233. if($(this).index() == 4){
  234. //判断是否空证书
  235. var a = $('#zss').attr('data');
  236. if(a == 'no'){
  237. setTimeout(function() {
  238. $('#jumpBtn2').trigger('click');
  239. //$('#jumpBtn').parent().parent().hide();
  240. }, 500); //大于400
  241. }
  242. }
  243. $(this).parents('fieldset').fadeOut(400, function() {
  244. $(this).prev().fadeIn();
  245. });
  246. });
  247. // submit
  248. $('.registration-form').on('submit', function(e) {
  249. /*$(this).find('input[type="text"], input[type="password"], textarea').each(function() {
  250. if( $(this).val() == "" ) {
  251. e.preventDefault();
  252. $(this).addClass('input-error');
  253. }
  254. else {
  255. $(this).removeClass('input-error');
  256. }
  257. });*/
  258. function isValidPhoneNumber(phoneNumber) {
  259. var regex = /^1[3-9]\d{9}$/; // 中国手机号码正则表达式,以1开头,第二位是3-9,后面跟着9位数字
  260. return regex.test(phoneNumber);
  261. }
  262. //开始手动验证
  263. var a = $('#per-name').val();
  264. var b = $('#per-phone').val();
  265. var c = $('#per-code').val();
  266. if(a == ''){
  267. $('#myModal .modal-body p').html('请输入您的称呼');
  268. $('#myModal').modal('show');
  269. return false;
  270. }
  271. if(b == ''){
  272. $('#myModal .modal-body p').html('请输入您的手机号码');
  273. $('#myModal').modal('show');
  274. return false;
  275. }
  276. console.log(isValidPhoneNumber(b));
  277. if(isValidPhoneNumber(b) === false){
  278. $('#myModal .modal-body p').html('请输入正确的手机号码格式');
  279. $('#myModal').modal('show');
  280. return false;
  281. }
  282. if(c == ''){
  283. $('#myModal .modal-body p').html('请输入验证码');
  284. $('#myModal').modal('show');
  285. return false;
  286. }
  287. //循环所有checkbox 重新构建数组
  288. //var zhengshu = [];
  289. var zhengshu = '';
  290. $('#zss input[type=checkbox]').each(function() {
  291. if ($(this).is(':checked')) {
  292. // 至少有一个checkbox被选中
  293. //zhengshu.push($(this).val());
  294. zhengshu += $(this).val()+',';
  295. } else {
  296. // 没有任何checkbox被选中
  297. //zhengshu.push("0");
  298. zhengshu += '0,';
  299. }
  300. });
  301. $('#zhengshu_val').val(zhengshu);
  302. //发送表单信息到后台
  303. $('#loadingModal .visually-hidden').html('获取结果中...');
  304. $('#loadingModal').modal('show');
  305. var formData = $('.registration-form').serializeArray();
  306. console.log(formData);
  307. //return false;
  308. $.ajax({
  309. url: '/api/Diyajax/insData',
  310. method: 'POST',
  311. dataType: 'json', // 指定响应数据为JSON
  312. data: formData,
  313. success: function(data) {
  314. // 请求成功后隐藏加载状态
  315. $('#loadingModal').modal('hide');
  316. // 处理返回的数据
  317. console.log('Ajax response:', data);
  318. $('#loadingModal .visually-hidden').html(data.msg);
  319. $('#loadingModal').modal('show');
  320. if(data.code == 0){
  321. setTimeout(function() {
  322. $('#loadingModal').modal('hide');
  323. }, 3000); // 5秒后取消定时器
  324. }else{
  325. //重置表单数据
  326. //$('.registration-form').reset();
  327. $('.registration-form')[0].reset();
  328. //成功
  329. setTimeout(function() {
  330. $('#loadingModal').modal('hide');
  331. //跳转到结果页
  332. location.href = 'https://www.zc10000.com/cp?h='+data.data.code;
  333. }, 1000); // 5秒后取消定时器
  334. }
  335. },
  336. error: function(xhr, status, error) {
  337. // 请求失败后隐藏加载状态
  338. $('#loadingModal').modal('hide');
  339. // 处理错误
  340. console.error('Ajax error:', status, error);
  341. }
  342. });
  343. return false;
  344. });
  345. /**
  346. * 获取验证码
  347. */
  348. /*$('#cx-rel-code').on('click',function (){
  349. });*/
  350. /**
  351. * 查询提交的事件
  352. */
  353. $('#cx-submit').on('click',function (){
  354. function isValidPhoneNumber(phoneNumber) {
  355. var regex = /^1[3-9]\d{9}$/; // 中国手机号码正则表达式,以1开头,第二位是3-9,后面跟着9位数字
  356. return regex.test(phoneNumber);
  357. }
  358. var a = $('#cx-code').val();
  359. if(a == ''){
  360. $('#myModal .modal-body p').html('请输入验证码');
  361. $('#myModal').modal('show');
  362. return false;
  363. }
  364. var b = $('#ffnp').val();
  365. if(isValidPhoneNumber(b) === false){
  366. $('#myModal .modal-body p').html('请输入正确的手机号码格式');
  367. $('#myModal').modal('show');
  368. return false;
  369. }
  370. var t = $('#times').val();
  371. //请求ajax
  372. $.ajax({
  373. url: '/api/Diyajax/cxCode',
  374. method: 'POST',
  375. dataType: 'json', // 指定响应数据为JSON
  376. data: {
  377. 'code': a,
  378. 'mobile': b,
  379. },
  380. success: function(data) {
  381. // 请求成功后隐藏加载状态
  382. $('#loadingModal').modal('hide');
  383. // 处理返回的数据
  384. console.log('Ajax response:', data);
  385. $('#loadingModal .visually-hidden').html(data.msg);
  386. $('#loadingModal').modal('show');
  387. if(data.code == 0){
  388. setTimeout(function() {
  389. $('#loadingModal').modal('hide');
  390. }, 3000); // 5秒后取消定时器
  391. }else{
  392. //重置表单数据
  393. $('#cx-code').val('');
  394. //成功
  395. setTimeout(function() {
  396. $('#loadingModal').modal('hide');
  397. //跳转到结果页
  398. location.href = 'https://www.zc10000.com/cp?p='+b+'&t='+t;
  399. }, 2000); // 5秒后取消定时器
  400. }
  401. },
  402. error: function(xhr, status, error) {
  403. // 请求失败后隐藏加载状态
  404. $('#loadingModal').modal('hide');
  405. // 处理错误
  406. console.error('Ajax error:', status, error);
  407. }
  408. });
  409. $('.form-inline').trigger('click');
  410. return false;
  411. });
  412. // 获取长度为len的随机字符串
  413. function _getRandomString(len) {
  414. len = len || 32;
  415. var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; // 默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1
  416. var maxPos = $chars.length;
  417. var pwd = '';
  418. for (i = 0; i < len; i++) {
  419. pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  420. }
  421. return pwd;
  422. }
  423. var timestamp = new Date().getTime();
  424. var times= timestamp + _getRandomString(32);
  425. console.log(times);
  426. $('#times').val(times);
  427. /**
  428. * 点击显示成功 示例
  429. */
  430. var browserWidth = $(window).width();
  431. if (browserWidth < 1001) {
  432. //手机端生效
  433. $('.but-success').removeClass('but-success2');
  434. }
  435. $('.but-success').click(function (){
  436. //$('.ssl-box').toggle();
  437. //.fadeOut();
  438. //.fadeIn();
  439. if($('.ssl-box').is(":hidden")){
  440. $('.ssl-box').fadeIn().show();
  441. $('.but-success').addClass('but-success2');
  442. }else{
  443. $('.ssl-box').fadeOut().hide();
  444. $('.but-success').removeClass('but-success2');
  445. }
  446. var browserWidth = $(window).width();
  447. if (browserWidth < 1001) {
  448. //手机端生效
  449. $('.but-success').removeClass('but-success2');
  450. $('.ssl-box').fadeOut().hide();
  451. $('#myModal').addClass('sss-box');
  452. /*$('#myModal .modal-title').html('详情');*/
  453. var html = $('.ssl-box').html();
  454. $('#myModal .modal-body p').html(html);
  455. $('#myModal').modal('show');
  456. }
  457. });
  458. });