Ajax进度条
使用:Easy Mock创建api接口
注意:若弹出该invalid or unexpected token错误提示信息,说明编写的数据格式有问题,修改为正确格式即可创建成。随后可以在postman中进行验证:
ajax通过GET方法获取数据:
根据获取出来得阶段数据来更改相对应得进度:
-
<!DOCTYPE html>
-
<html lang="en">
-
-
<head>
-
<meta charset="UTF-8">
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
-
<title>Document</title>
-
<link rel="stylesheet" href="2.css">
-
<script src="2.js"></script>
-
<script src="jquery.min.js"></script>
-
</head>
-
-
<body>
-
<div class="box">
-
<div class="pr1">
-
<span class="circle">1</span>
-
<span class="line"></span>
-
<span class="cont1">科研人员申报</span>
-
</div>
-
<div class="pr1">
-
<span class="circle">2</span>
-
<span class="line"></span>
-
<span class="cont2">院系申报</span>
-
</div>
-
<div class="pr1">
-
<span class="circle">3</span>
-
<span class="line"></span>
-
<span class="cont2">专家评审</span>
-
</div>
-
<div class="pr1_last">
-
<span class="circle">4</span>
-
<span class="cont2">校级审核</span>
-
</div>
-
</div>
-
-
</body>
-
-
</html>
-
window.onload = function() {
-
$(function() {
-
function fn1() { //1未开始
-
-
}
-
-
function fn2() { //2申报中
-
$('.cont1').css('color', 'skyblue')
-
$('.circle').eq(0).css('background-color', 'skyblue')
-
}
-
-
function fn3() { //3院系审核中
-
$('.line').eq(0).css('border-color', 'green')
-
$('.line').eq(0).css('border-style', 'solid')
-
$('.circle').eq(0).html('√')
-
$('.circle').eq(0).css('background-color', 'green')
-
$('.cont1').css('color', 'green')
-
$('.circle').eq(1).css('background-color', 'skyblue')
-
$('.cont2').eq(0).css('color', 'skyblue')
-
}
-
-
function fn4() { //4专家审核中
-
fn3()
-
$('.circle').eq(1).html('√')
-
$('.cont2').eq(0).css('color', 'green')
-
$('.circle').eq(1).css('background-color', 'green')
-
$('.line').eq(1).css('border-color', 'green')
-
$('.line').eq(1).css('border-style', 'solid')
-
$('.circle').eq(2).css('background-color', 'skyblue')
-
$('.cont2').eq(1).css('color', 'skyblue')
-
}
-
-
function fn5() { //5校级审核中
-
-
fn4()
-
$('.circle').eq(2).html('√')
-
$('.cont2').eq(1).css('color', 'green')
-
$('.circle').eq(2).css('background-color', 'green')
-
$('.line').eq(2).css('border-color', 'green')
-
$('.line').eq(2).css('border-style', 'solid')
-
$('.circle').eq(3).css('background-color', 'skyblue')
-
$('.cont2').eq(2).css('color', 'skyblue')
-
}
-
-
function fn6() {
-
//6已结束
-
fn5()
-
$('.circle').eq(3).html('√')
-
$('.circle').eq(3).css('background-color', 'green')
-
$('.cont2').eq(2).css('color', 'green')
-
-
}
-
var b
-
//使用ajax获取api中得数据,看是那个阶段
-
function fn() {
-
$.ajax({
-
type: 'GET',
-
url: 'https://mock.mengxuegu.com/mock/624d8ce9f56fd246b02bfcaf/process/getinfo',
-
success: function(res) {
-
console.log(res.BatchState);
-
b = res.BatchState;
-
//利用b数据去改变状态//1未开始,2申报中,3院系审核中,4专家审核中,5校级审核中,6已结束
-
if (b == 1) {
-
fn1()
-
}
-
if (b == 2) {
-
fn2()
-
}
-
if (b == 3) {
-
fn3()
-
}
-
if (b == 4) {
-
fn4()
-
}
-
if (b == 5) {
-
fn5()
-
}
-
if (b == 6) {
-
fn6()
-
}
-
}
-
})
-
}
-
-
-
//将文本框中的内容通过ajax传递给api,修改阶段
-
$('button').on('click', function() {
-
var a = $('input').val().trim()
-
let params = {
-
BatchState: a,
-
DelareCount: 0,
-
PermitCount: 3,
-
StateSituation: [{
-
Stage: 1,
-
TotalCount: 1,
-
AuditCount: 1
-
}]
-
}
-
params = JSON.stringify(params)
-
$.ajax({
-
url: "https://mock.mengxuegu.com/mock/624d8ce9f56fd246b02bfcaf/process/addinfo",
-
type: "POST",
-
data: params,
-
contentType: "application/json",
-
success: function(params) { console.log(params); }
-
});
-
fn()
-
})
-
fn()
-
})
-
}
-
* {
-
margin: 0px;
-
padding: 0px;
-
}
-
-
.box {
-
width: 305px;
-
height: 40px;
-
margin: 20px auto;
-
line-height: 40px;
-
}
-
-
.circle {
-
position: absolute;
-
top: 10px;
-
left: 0px;
-
display: inline-block;
-
width: 20px;
-
height: 20px;
-
border-radius: 50%;
-
-moz-border-radius: 50%;
-
-webkit-border-radius: 50%;
-
background-color: grey;
-
line-height: 20px;
-
text-align: center;
-
color: white
-
}
-
-
.line {
-
position: absolute;
-
top: 20px;
-
left: 19px;
-
display: inline-block;
-
width: 70px;
-
height: 0px;
-
border-top: grey 1px;
-
margin: 0px;
-
border-top-style: dotted
-
}
-
-
.pr1 {
-
float: left;
-
width: 90px;
-
height: 40px;
-
position: relative;
-
text-align: center;
-
}
-
-
.pr1_last {
-
float: left;
-
width: 35px;
-
height: 40px;
-
position: relative;
-
text-align: center;
-
}
-
-
.cont1 {
-
position: absolute;
-
top: 18px;
-
left: -20px;
-
font-size: 10px;
-
color: grey
-
}
-
-
.cont2 {
-
position: absolute;
-
top: 18px;
-
left: -10px;
-
font-size: 10px;
-
color: grey
-
}
对传递的参数进行序列化: params = JSON.stringify(params)
mock里面的数据是写死了的,
更改都无法实现
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhfgefki
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
excel下划线不显示怎么办
PHP中文网 06-23 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
怎样阻止微信小程序自动打开
PHP中文网 06-13 -
photoshop蒙版画笔没反应怎么办
PHP中文网 06-24