123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
-
- jQuery(document).ready(function() {
-
- /*
- Fullscreen background
- */
- $.backstretch("/template/pc/js/botstrap-step/cb10b62fa1f10acac99339fcfc511914_1.jpg");
-
- $('#top-navbar-1').on('shown.bs.collapse', function(){
- $.backstretch("resize");
- });
- $('#top-navbar-1').on('hidden.bs.collapse', function(){
- $.backstretch("resize");
- });
-
- /*
- Form
- */
- $('.registration-form fieldset:first-child').fadeIn('slow');
-
- $('.registration-form input[type="text"], .registration-form input[type="password"], .registration-form textarea').on('focus', function() {
- $(this).removeClass('input-error');
- });
-
- // next step
- $('.registration-form .btn-next').on('click', function() {
-
-
- //校验字段
- var a = $('#choose2').val();
- console.log(a);
- if(a == 0){
- $('#myModal .modal-body p').html('请选择申报专业');
- $('#myModal').modal('show');
- return false;
- }
-
- var b = $('#choose3').val();
- console.log(a);
- if(b == 0){
- $('#myModal .modal-body p').html('请选择申报等级');
- $('#myModal').modal('show');
- return false;
- }
-
-
- console.log($(this).index());
- //调用专业
- if($(this).index() == 3) {
- $('#loadingModal').modal('show');
- $.ajax({
- url: '/api/Diyajax/getZcZyList',
- method: 'POST',
- dataType: 'json', // 指定响应数据为JSON
- data: {
- id: a
- },
- success: function (data) {
- // 请求成功后隐藏加载状态
- $('#loadingModal').modal('hide');
- // 处理返回的数据
- console.log('Ajax response:', data);
- console.log(data.data);
- var html = '';
- $.each(data.data, function (i, e) {
- console.log(e);
- 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>';
- });
-
- if(html == ''){
- html = '暂无相关要求';
- }
-
- $('#zys').empty();
- $('#zys').append(html);
- },
- error: function (xhr, status, error) {
- // 请求失败后隐藏加载状态
- $('#loadingModal').modal('hide');
- // 处理错误
- console.error('Ajax error:', status, error);
- }
- });
- }
-
- //填完个人资料 点击下一步
- if($(this).index() == 6) {
-
- var b = $('#choose6').val();
- console.log(a);
- if(b == 0){
- $('#myModal .modal-body p').html('请选择年龄');
- $('#myModal').modal('show');
- return false;
- }
- var b = $('#choose5').val();
- console.log(a);
- if(b == 0){
- $('#myModal .modal-body p').html('请选择学历');
- $('#myModal').modal('show');
- return false;
- }
- var b = $('#choose7').val();
- console.log(a);
- if(b == 0){
- $('#myModal .modal-body p').html('请选择学校类型');
- $('#myModal').modal('show');
- return false;
- }
-
-
- //调用证书
- $('#loadingModal').modal('show');
- $.ajax({
- url: '/api/Diyajax/getZcZsList',
- method: 'POST',
- dataType: 'json', // 指定响应数据为JSON
- data: {
- id: a
- },
- success: function (data) {
- // 请求成功后隐藏加载状态
- $('#loadingModal').modal('hide');
- // 处理返回的数据
- console.log('Ajax response:', data);
- console.log(data.data);
- var html = '';
-
- var options = '';
- for(i=1;i<=30;i++) {
- options += '<option value="'+i+'">'+i+'年</option>';
- }
-
- $.each(data.data, function (i, e) {
- console.log(e);
- 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>';
- });
-
- if(html == ''){
- html = '暂无相关要求,请进行下一步';
- }
-
- $('#zss').empty();
- $('#zss').append(html);
- },
- error: function (xhr, status, error) {
- // 请求失败后隐藏加载状态
- $('#loadingModal').modal('hide');
- // 处理错误
- console.error('Ajax error:', status, error);
- }
- });
- }
-
- if($(this).index() == 2) {
- //获取表单令牌 不能用接口直接过去 得用内部调用
- /*$('#loadingModal').modal('show');
- $.ajax({
- url: '/api/v1/api/get_token',
- method: 'POST',
- dataType: 'json', // 指定响应数据为JSON
- data: {},
- success: function (data) {
- // 请求成功后隐藏加载状态
- $('#loadingModal').modal('hide');
- // 处理返回的数据
- console.log('Ajax response:', data);
- console.log(data.data);
-
- $('#token').val(data.value);
- },
- error: function (xhr, status, error) {
- // 请求失败后隐藏加载状态
- $('#loadingModal').modal('hide');
- // 处理错误
- console.error('Ajax error:', status, error);
- }
- });*/
- }
-
-
- //继续下一屏切换
- var parent_fieldset = $(this).parents('fieldset');
- var next_step = true;
-
- parent_fieldset.find('input[type="text"], input[type="password"], textarea').each(function() {
- if( $(this).val() == "" ) {
- $(this).addClass('input-error');
- next_step = false;
- }
- else {
- $(this).removeClass('input-error');
- }
- });
-
- if( next_step ) {
- parent_fieldset.fadeOut(400, function() {
- $(this).next().fadeIn();
- });
- }
-
- });
-
- // previous step
- $('.registration-form .btn-previous').on('click', function() {
- $(this).parents('fieldset').fadeOut(400, function() {
- $(this).prev().fadeIn();
- });
- });
-
- // submit
- $('.registration-form').on('submit', function(e) {
-
- /*$(this).find('input[type="text"], input[type="password"], textarea').each(function() {
- if( $(this).val() == "" ) {
- e.preventDefault();
- $(this).addClass('input-error');
- }
- else {
- $(this).removeClass('input-error');
- }
- });*/
-
- function isValidPhoneNumber(phoneNumber) {
- var regex = /^1[3-9]\d{9}$/; // 中国手机号码正则表达式,以1开头,第二位是3-9,后面跟着9位数字
- return regex.test(phoneNumber);
- }
-
- //开始手动验证
- var a = $('#per-name').val();
- var b = $('#per-phone').val();
- var c = $('#per-code').val();
-
- if(a == ''){
- $('#myModal .modal-body p').html('请输入您的称呼');
- $('#myModal').modal('show');
- return false;
- }
- if(b == ''){
- $('#myModal .modal-body p').html('请输入您的手机号码');
- $('#myModal').modal('show');
- return false;
- }
- console.log(isValidPhoneNumber(b));
- if(isValidPhoneNumber(b) === false){
- $('#myModal .modal-body p').html('请输入正确的手机号码格式');
- $('#myModal').modal('show');
- return false;
- }
- if(c == ''){
- $('#myModal .modal-body p').html('请输入验证码');
- $('#myModal').modal('show');
- return false;
- }
-
- //发送表单信息到后台
- $('#loadingModal .visually-hidden').html('获取结果中...');
- $('#loadingModal').modal('show');
- var formData = $('.registration-form').serializeArray();
- console.log(formData);
- $.ajax({
- url: '/api/Diyajax/insData',
- method: 'POST',
- dataType: 'json', // 指定响应数据为JSON
- data: formData,
- success: function(data) {
- // 请求成功后隐藏加载状态
- $('#loadingModal').modal('hide');
- // 处理返回的数据
- console.log('Ajax response:', data);
-
- $('#loadingModal .visually-hidden').html(data.msg);
- $('#loadingModal').modal('show');
-
- if(data.code == 0){
- setTimeout(function() {
- $('#loadingModal').modal('hide');
- }, 3000); // 5秒后取消定时器
- }else{
- //成功
- setTimeout(function() {
- $('#loadingModal').modal('hide');
- //跳转到结果页
- location.href = 'https://www.zc10000.com/cp?h='+data.data.code;
- }, 2000); // 5秒后取消定时器
- }
- },
- error: function(xhr, status, error) {
- // 请求失败后隐藏加载状态
- $('#loadingModal').modal('hide');
- // 处理错误
- console.error('Ajax error:', status, error);
- }
- });
- return false;
- });
- });
|