feat(agent-report): 注单查询新增今日注单自动刷新开关(默认开,10秒刷新当前查询)
原自动刷新仅在线管理(online=1)进入时生效;现普通注单查询页也支持, 带开关(localStorage持久化)+倒计时显示,免手动点刷新。
This commit is contained in:
@@ -77,7 +77,10 @@
|
||||
<div class="gap">
|
||||
<button class="layui-btn search-btn" id="search" onclick="showShadow()">{$lang['search']}</button>
|
||||
<a class="layui-btn search-btn" onclick="showShadow()" href="javascript:location.replace(location.href);">{$lang['refresh']}</a>
|
||||
<button class="layui-btn search-btn countDown">5</button>
|
||||
<label style="margin-left:6px;line-height:38px;cursor:pointer;font-weight:normal;vertical-align:middle;">
|
||||
<input type="checkbox" id="autoRefresh" style="vertical-align:middle;"> 自动刷新
|
||||
</label>
|
||||
<button type="button" class="layui-btn search-btn countDown" style="display:none;">10</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -187,16 +190,44 @@
|
||||
$(function(){
|
||||
var online = $('#online').val();
|
||||
var refreshUrl = $('#refreshUrl').val();
|
||||
var countDown = 10;
|
||||
if(online == 1){
|
||||
$('.countDown').show();
|
||||
setInterval(function(){
|
||||
var INTERVAL = 10; // 自动刷新间隔(秒)
|
||||
var countDown = INTERVAL;
|
||||
var autoTimer = null;
|
||||
|
||||
function startAuto(reloadFn){
|
||||
countDown = INTERVAL;
|
||||
$('.countDown').show().html(countDown);
|
||||
autoTimer = setInterval(function(){
|
||||
countDown = countDown - 1;
|
||||
$('.countDown').html(countDown);
|
||||
if(countDown == 0){
|
||||
location.href = refreshUrl;
|
||||
if(countDown <= 0){
|
||||
reloadFn();
|
||||
}
|
||||
},1000);
|
||||
}, 1000);
|
||||
}
|
||||
function stopAuto(){
|
||||
if(autoTimer){ clearInterval(autoTimer); autoTimer = null; }
|
||||
$('.countDown').hide();
|
||||
}
|
||||
|
||||
if(online == 1){
|
||||
// 从“在线管理”进入:保持原有自动刷新行为
|
||||
startAuto(function(){ location.href = refreshUrl; });
|
||||
}else{
|
||||
// 注单查询:可开关的今日实时自动刷新(默认开,刷新当前查询条件)
|
||||
var saved = localStorage.getItem('bet_auto_refresh');
|
||||
var enabled = (saved === null) ? true : (saved === '1');
|
||||
$('#autoRefresh').prop('checked', enabled);
|
||||
if(enabled){ startAuto(function(){ location.replace(location.href); }); }
|
||||
$('#autoRefresh').on('change', function(){
|
||||
if($(this).is(':checked')){
|
||||
localStorage.setItem('bet_auto_refresh','1');
|
||||
startAuto(function(){ location.replace(location.href); });
|
||||
}else{
|
||||
localStorage.setItem('bet_auto_refresh','0');
|
||||
stopAuto();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user