右下角显示全局实时消息提醒

引用notyf.js

<

 

 

js:

$(document).ready(function () {

var notyf = new Notyf({delay:10000});

console.log(notyf);

var messageArr=[];  //存放消息

var currentNum=0;  //第几条消息



/*获取消息*/

function messageFun() {

$.ajax({

type: "POST",

url: location.origin+"/msg.php",

data: {

op:"message"

},

dataType: "json",

success: function (data) {

// console.log(data.message);

messageArr=messageArr.concat(data.message);

console.log(messageArr);

notyf.confirm("

"+messageArr[currentNum].content+"

订单编号:"+messageArr[currentNum].ordersn+"
收货人姓名:"+messageArr[currentNum].nickname+"
联系人电话:" + messageArr[currentNum].mobile+"

订单时间:"+messageArr[currentNum].time+"

"); } }); } //3s获取一次 setInterval(function () { messageFun(); currentNum++; },3000) messageFun(); /*后台删数据*/ function messageEnd(id) { $.ajax({ type: "POST", url: "{php echo $this->createWebUrl('order', array('op' => 'update_msg'))}", data: {id: id}, dataType: "json", success: function (data) { } }); } setInterval(function () { messageEnd(messageArr[currentNum].id); },3000) })

 

你可能感兴趣的:(web)