• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Ajax进度条

武飞扬头像
一夕ξ
帮助3

使用:Easy Mock创建api接口

 学新通

注意:若弹出该invalid or unexpected token错误提示信息,说明编写的数据格式有问题,修改为正确格式即可创建成。随后可以在postman中进行验证:学新通

ajax通过GET方法获取数据:

学新通

根据获取出来得阶段数据来更改相对应得进度:

学新通

  1.  
    <!DOCTYPE html>
  2.  
    <html lang="en">
  3.  
     
  4.  
    <head>
  5.  
    <meta charset="UTF-8">
  6.  
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7.  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8.  
    <title>Document</title>
  9.  
    <link rel="stylesheet" href="2.css">
  10.  
    <script src="2.js"></script>
  11.  
    <script src="jquery.min.js"></script>
  12.  
    </head>
  13.  
     
  14.  
    <body>
  15.  
    <div class="box">
  16.  
    <div class="pr1">
  17.  
    <span class="circle">1</span>
  18.  
    <span class="line"></span>
  19.  
    <span class="cont1">科研人员申报</span>
  20.  
    </div>
  21.  
    <div class="pr1">
  22.  
    <span class="circle">2</span>
  23.  
    <span class="line"></span>
  24.  
    <span class="cont2">院系申报</span>
  25.  
    </div>
  26.  
    <div class="pr1">
  27.  
    <span class="circle">3</span>
  28.  
    <span class="line"></span>
  29.  
    <span class="cont2">专家评审</span>
  30.  
    </div>
  31.  
    <div class="pr1_last">
  32.  
    <span class="circle">4</span>
  33.  
    <span class="cont2">校级审核</span>
  34.  
    </div>
  35.  
    </div>
  36.  
     
  37.  
    </body>
  38.  
     
  39.  
    </html>
学新通
  1.  
    window.onload = function() {
  2.  
    $(function() {
  3.  
    function fn1() { //1未开始
  4.  
     
  5.  
    }
  6.  
     
  7.  
    function fn2() { //2申报中
  8.  
    $('.cont1').css('color', 'skyblue')
  9.  
    $('.circle').eq(0).css('background-color', 'skyblue')
  10.  
    }
  11.  
     
  12.  
    function fn3() { //3院系审核中
  13.  
    $('.line').eq(0).css('border-color', 'green')
  14.  
    $('.line').eq(0).css('border-style', 'solid')
  15.  
    $('.circle').eq(0).html('√')
  16.  
    $('.circle').eq(0).css('background-color', 'green')
  17.  
    $('.cont1').css('color', 'green')
  18.  
    $('.circle').eq(1).css('background-color', 'skyblue')
  19.  
    $('.cont2').eq(0).css('color', 'skyblue')
  20.  
    }
  21.  
     
  22.  
    function fn4() { //4专家审核中
  23.  
    fn3()
  24.  
    $('.circle').eq(1).html('√')
  25.  
    $('.cont2').eq(0).css('color', 'green')
  26.  
    $('.circle').eq(1).css('background-color', 'green')
  27.  
    $('.line').eq(1).css('border-color', 'green')
  28.  
    $('.line').eq(1).css('border-style', 'solid')
  29.  
    $('.circle').eq(2).css('background-color', 'skyblue')
  30.  
    $('.cont2').eq(1).css('color', 'skyblue')
  31.  
    }
  32.  
     
  33.  
    function fn5() { //5校级审核中
  34.  
     
  35.  
    fn4()
  36.  
    $('.circle').eq(2).html('√')
  37.  
    $('.cont2').eq(1).css('color', 'green')
  38.  
    $('.circle').eq(2).css('background-color', 'green')
  39.  
    $('.line').eq(2).css('border-color', 'green')
  40.  
    $('.line').eq(2).css('border-style', 'solid')
  41.  
    $('.circle').eq(3).css('background-color', 'skyblue')
  42.  
    $('.cont2').eq(2).css('color', 'skyblue')
  43.  
    }
  44.  
     
  45.  
    function fn6() {
  46.  
    //6已结束
  47.  
    fn5()
  48.  
    $('.circle').eq(3).html('√')
  49.  
    $('.circle').eq(3).css('background-color', 'green')
  50.  
    $('.cont2').eq(2).css('color', 'green')
  51.  
     
  52.  
    }
  53.  
    var b
  54.  
    //使用ajax获取api中得数据,看是那个阶段
  55.  
    function fn() {
  56.  
    $.ajax({
  57.  
    type: 'GET',
  58.  
    url: 'https://mock.mengxuegu.com/mock/624d8ce9f56fd246b02bfcaf/process/getinfo',
  59.  
    success: function(res) {
  60.  
    console.log(res.BatchState);
  61.  
    b = res.BatchState;
  62.  
    //利用b数据去改变状态//1未开始,2申报中,3院系审核中,4专家审核中,5校级审核中,6已结束
  63.  
    if (b == 1) {
  64.  
    fn1()
  65.  
    }
  66.  
    if (b == 2) {
  67.  
    fn2()
  68.  
    }
  69.  
    if (b == 3) {
  70.  
    fn3()
  71.  
    }
  72.  
    if (b == 4) {
  73.  
    fn4()
  74.  
    }
  75.  
    if (b == 5) {
  76.  
    fn5()
  77.  
    }
  78.  
    if (b == 6) {
  79.  
    fn6()
  80.  
    }
  81.  
    }
  82.  
    })
  83.  
    }
  84.  
     
  85.  
     
  86.  
    //将文本框中的内容通过ajax传递给api,修改阶段
  87.  
    $('button').on('click', function() {
  88.  
    var a = $('input').val().trim()
  89.  
    let params = {
  90.  
    BatchState: a,
  91.  
    DelareCount: 0,
  92.  
    PermitCount: 3,
  93.  
    StateSituation: [{
  94.  
    Stage: 1,
  95.  
    TotalCount: 1,
  96.  
    AuditCount: 1
  97.  
    }]
  98.  
    }
  99.  
    params = JSON.stringify(params)
  100.  
    $.ajax({
  101.  
    url: "https://mock.mengxuegu.com/mock/624d8ce9f56fd246b02bfcaf/process/addinfo",
  102.  
    type: "POST",
  103.  
    data: params,
  104.  
    contentType: "application/json",
  105.  
    success: function(params) { console.log(params); }
  106.  
    });
  107.  
    fn()
  108.  
    })
  109.  
    fn()
  110.  
    })
  111.  
    }
学新通
  1.  
    * {
  2.  
    margin: 0px;
  3.  
    padding: 0px;
  4.  
    }
  5.  
     
  6.  
    .box {
  7.  
    width: 305px;
  8.  
    height: 40px;
  9.  
    margin: 20px auto;
  10.  
    line-height: 40px;
  11.  
    }
  12.  
     
  13.  
    .circle {
  14.  
    position: absolute;
  15.  
    top: 10px;
  16.  
    left: 0px;
  17.  
    display: inline-block;
  18.  
    width: 20px;
  19.  
    height: 20px;
  20.  
    border-radius: 50%;
  21.  
    -moz-border-radius: 50%;
  22.  
    -webkit-border-radius: 50%;
  23.  
    background-color: grey;
  24.  
    line-height: 20px;
  25.  
    text-align: center;
  26.  
    color: white
  27.  
    }
  28.  
     
  29.  
    .line {
  30.  
    position: absolute;
  31.  
    top: 20px;
  32.  
    left: 19px;
  33.  
    display: inline-block;
  34.  
    width: 70px;
  35.  
    height: 0px;
  36.  
    border-top: grey 1px;
  37.  
    margin: 0px;
  38.  
    border-top-style: dotted
  39.  
    }
  40.  
     
  41.  
    .pr1 {
  42.  
    float: left;
  43.  
    width: 90px;
  44.  
    height: 40px;
  45.  
    position: relative;
  46.  
    text-align: center;
  47.  
    }
  48.  
     
  49.  
    .pr1_last {
  50.  
    float: left;
  51.  
    width: 35px;
  52.  
    height: 40px;
  53.  
    position: relative;
  54.  
    text-align: center;
  55.  
    }
  56.  
     
  57.  
    .cont1 {
  58.  
    position: absolute;
  59.  
    top: 18px;
  60.  
    left: -20px;
  61.  
    font-size: 10px;
  62.  
    color: grey
  63.  
    }
  64.  
     
  65.  
    .cont2 {
  66.  
    position: absolute;
  67.  
    top: 18px;
  68.  
    left: -10px;
  69.  
    font-size: 10px;
  70.  
    color: grey
  71.  
    }
学新通

学新通

对传递的参数进行序列化: params = JSON.stringify(params)

学新通

 mock里面的数据是写死了的,学新通

更改都无法实现 

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfgefki
系列文章
更多 icon
同类精品
更多 icon
继续加载