html 代码
<audio id="audio" src="/addons/diancan_lxy/notice.mp3" preload="auto" style="display:none;"></audio>
<script>
var audio = $("#audio")[0];
var time = 0;
$(document).ready(function(){
settime();
});
function settime(){
if(time == 12){
notice();
time = 0;settime();
}else{
setTimeout(function(){time++;settime();},1000);
}
}
function notice(){
$.ajax({
type:'post',
url:"{php echo url('site/entry/notice', array('m' => 'diancan_lxy'));}",
dataType:'json',
data:{},
success:function(json){
//alert(json);
if(json.success == 1){
notice_window();
}
//console.log(json);
},
error:function(){
}
});
}
function notice_window(){
$('#notice').click();audio.play();setTimeout(function(){$('#notice').click();},10000);
}
php
global $_W;
$time = time() - 15;
$res = pdo_fetch("SELECT * FROM ".tablename('diancan_order')." where weid = ".$_W['uniacid']." and create_time > ".$time);
if($res){
$arr['success'] = 1;
}else{
$arr['success'] = 0;
}
echo json_encode($arr);