我的代码,生成一条订单,再生成一条通知,js 获取,然后提示,但是居然提示了 7 次。不知道哪里出现问题,以下是我的代码:
$(document).on('page:change', function() {
NProgress.done();
MessageBus.start(); // call once at startup
// how often do you want the callback to fire in ms
MessageBus.callbackInterval = 500;
MessageBus.subscribe("/notifications_count/" + App.access_token, function(data){
// data shipped from server
var div, link, new_title, span, url;
span = $(".notification-count span");
link = $(".notification-count a");
new_title = document.title.replace(/^\(\d+\) /, '');
if (data.count > 0) {
span.show();
new_title = "(" + data.count + ") " + new_title;
link.addClass("new");
$.notify({
title: "<strong>" + data.title + "</strong> ",
message: "您有新订单(" + data.content + "),请赶快处理 <a href=\"" + data.content_path + "\">点击这里</a>"
},{
delay: 10000
});
} else {
span.hide();
link.removeClass("new");
}
span.text(data.count);
return document.title = new_title;
});
});