页面初始化加载:
$(function() {
makeAll();
makeAllOrder();
});
var orderNumber=0;
function makeAll(){
$.ajax({
type : "post",
dataType: "json",
data : {
},
url : "${pageContext.request.contextPath }/quser/JSDAY.do",
success : function(data) {
//
}
});
}
function makeAllOrder(){
$.ajax({
type : "post",
dataType: "json",
data : {
},
url : "${pageContext.request.contextPath }/quser/JSListOrder.do",
success : function(data) {
//订单消息提醒
var listOrder=data.listOrder;
if(listOrder.length>orderNumber){
//语音提示
speckText("您有新的待处理订单");
}
orderNumber = listOrder.length;
$("#weichuli1").html(listOrder.length);
$("#quanbu1").html(listOrder.length);
//拼接列表
$("#xiaoxicon1").empty();
var str1="";
str1+="<li class='nav-header'>";
str1+="<i class='icon-envelope'></i> <span id='quanbu1'>"+listOrder.length+"</span> 条待确认订单";
str1+="</li>";
for(var i = 0; i < listOrder.length; i++) {
str1+="<li><a style='text-align: center;'>";
//str1+="<span class='msg-body'>";
str1+="<span class='msg-title'>"+listOrder[i].CONTENT+"</span>";
str1+="</span>";
//str1+="</span>";
str1+="</a>";
str1+="</li>";
}
str1+="<li><a>";
str1+="<span class='msg-body'>";
str1+="<span class='msg-title'>待确认订单列表</span>";
str1+="</span>";
str1+="</span>";
str1+="</a>";
str1+="</li>";
$("#xiaoxicon1").append(str1);
}
});
}
声音播放文本内容:
function speckText(str){
var url = "http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text=" + encodeURI(str);
var n = new Audio(url);
n.src = url;
n.play();
}
定时方法:
setInterval("makeAll()","3600000");
setInterval("makeAllOrder()","10000");