前段html js:
<!-- 百度语音 -->
<div id="yuyinbb" style="display:none;">
<audio id="music" >
您的浏览器不支持 audio 标签。
</audio>
</div>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
<script>
setInterval("wlphp()",1000); //每隔一秒去post给服务端
function wlphp(){undefined
$.post("",{act:'wlphp'},function (data){undefined
var music="尊敬的后台管理员,客户张三付款了 ,单号:1283328328832,请及时发货谢谢!";
var str="http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text="+encodeURIComponent(music);
$("#music").attr("src",str);
var music = document.getElementById("music");
music.play();
//这个地方还可以通过jquery 在网页上显示出data返回的文字等
});
}
</script>
服务端代码示例:
$sql="select * from goods_order_info WHERE pay_time<=unix_timestamp(now()) and pay_time>='{$_SESSION['just']}' and pay_time!='' and pay_status=1 LIMIT 1";
$rs=mysql_query($sql);
$orderinfo=mysql_fetch_array($rs);
if(!empty($orderinfo)){undefined
echo "尊敬的后台管理员,客户".$orderinfo['consignee']."付款了,单号:".$orderinfo['order_sn'].",请及时发货谢谢!";
}
$_SESSION['just']=time();
die();