-
Notifications
You must be signed in to change notification settings - Fork 6.4k
/
progress.html
77 lines (72 loc) · 2.83 KB
/
progress.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<div class="page">
<div class="page__hd">
<h1 class="page__title">Progress</h1>
<p class="page__desc">进度条</p>
</div>
<div class="page__bd page__bd_spacing">
<div class="weui-progress">
<div class="weui-progress__bar">
<div class="weui-progress__inner-bar js_progress" style="width: 0%;"></div>
</div>
<a href="javascript:" role="button" class="weui-wa-hotarea weui-progress__opr">
<i role="img" aria-label="取消" class="weui-icon-cancel"></i>
</a>
<span id="js_current" role="alert" class="weui-hidden_abs">0%</span>
</div>
<br>
<div class="weui-progress">
<div class="weui-progress__bar">
<div class="weui-progress__inner-bar js_progress" style="width: 50%;"></div>
</div>
<a href="javascript:" role="button" class="weui-wa-hotarea weui-progress__opr">
<i role="img" aria-label="取消" class="weui-icon-cancel"></i>
</a>
<span id="js_current" role="alert" class="weui-hidden_abs">50%</span>
</div>
<br>
<div class="weui-progress">
<div class="weui-progress__bar">
<div class="weui-progress__inner-bar js_progress" style="width: 80%;"></div>
</div>
<a href="javascript:" role="button" class="weui-progress__opr">
<i role="img" aria-label="取消" class="weui-icon-cancel"></i>
</a>
<span id="js_current" role="alert" class="weui-hidden_abs">80%</span>
</div>
<div class="weui-btn-area">
<button type="button" class="weui-btn weui-btn_primary" id="btnUpload">上传</button>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
var $progress = $('.js_progress'),
$btnUpload = $('#btnUpload');
var progress = 0;
var $current = $('#js_current');
var currentDate = +new Date();
window.test=$current;
function next() {
if(progress > 10){
if (+new Date() - currentDate > 3000) {
$current.text('已上传百分之' + progress);
currentDate = +new Date()
}
}
if(progress === 100){
$current.text('已上传百分之' + progress);
progress = 0;
$btnUpload.removeClass('weui-btn_disabled');
return;
}
$progress.css({width: progress + '%'});
progress = ++progress;
setTimeout(next, 20);
}
$btnUpload.on('click', function(){
if ($btnUpload.hasClass('weui-btn_disabled')) return;
$btnUpload.addClass('weui-btn_disabled');
next();
});
});
</script>