官方说明文档 简单集成到fastadmin后台,未做数据处理 下载压缩包放到系统任意位置,运行即可
html路径: \application\admin\view\common\header.html 26行
<!--新订单提醒-->
<li class="hidden-xs orders" data-uid="{$Think.session.admin.id}">
<a href="#" ><i class="fa" style="font-size:14px;"></i>新订单<span id="order_nums">0</span></a>
</li>
js \public\assets\js\backend\index.js 362行
$('.orders').click(function(){
$('#order_nums').html(0);
Backend.api.addtabs('goods/goods_order');
})
$(document).ready(function () {
var uid=$('.orders').attr('data-uid');
var socket = io('http://'+document.domain+':2120');
socket.on('connect', function(){
socket.emit('login', uid);
});
socket.on('new_msg', function(msg){
$('#order_nums').html($('#order_nums').html()*1+1);
});
});
新消息发送接口
function send(){
$push_api_url = request()->domain().":2121/";
$post_data = array(
'type' => 'publish',
'content' => '这个是推送的测试数据',
'to' => '',
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $push_api_url );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, array("Expect:"));
$return = curl_exec ( $ch );
curl_close ( $ch );
}
|