Thinkphp项目结合JS消息提醒
这里简略贴下项目目录结构,请根据实际情况应用
接下来就是项目实际应用代码
- index.html
<iframe name="right" id="rightMain" src="" frameborder="false" scrolling="auto" style="overflow-x:hidden;border:none;" width="100%" height="auto" allowtransparency="true" class="111"></iframe>
<div class="tipfloat">
<h2 class="tiphead"><strong>消息提示框</strong><span title="关闭" class="close"><img src="__PUBLIC__/admin/yuyue_manage/error.png"/></span></h2>
<div class="ranklist">
<ol id="ranklist">
<li class="top"></li>
</ol>
<div style="display: none;">
<audio id="im_ring" src="__PUBLIC__/admin/yuyue_manage/ring.mp3"></audio>
<input type="hidden" id="opentip_num" value="on" />
</div>
</div>
</div>
- msg_tip.js
checkmsg();
function checkmsg() {
var url = "index.php?s=/Admin/public/ajax_box.html";
$.ajax({
type: "GET",
url: url,
dataType: "json",
success: function(msg) {
var num = msg;
var opentip_num = $('#opentip_num').val();
if (num != opentip_num) {
html = '';
$.each(msg, function(i, data) {
html += '<li class="top"><p>' + data + '</p></li>';
})
opentipwindow(num, html);
}
}
});
setTimeout(function() {
checkmsg();
}, 10000);
}
function opentipwindow(num, str) {
document.getElementById('im_ring').play();
$('#ranklist').html(str);
var titHeight = $("tiphead").height();
$(".tipfloat").show();
// $(".tipfloat").css('height',196);
$(".tipfloat").css('height', 150);
$(".close").click(function() {
$(".tipfloat").animate({ height: titHeight - 50 }, 1000, function() {
$(".tipfloat").hide();
});
});
}
function openwindowleft(targetUrl) {
$('#loading').show();
var titHeight = $("tiphead").height();
$(".tipfloat").animate({ height: titHeight - 50 }, 1000, function() {
$(".tipfloat").hide();
});
$("#rightMain").attr('src', targetUrl);
}
-
yuyue_manage下就是图片啦
-
PublicController.class.php
public function ajax_box() {
$info = I('ex');
$id = session('admin_id');
$map['status'] = 1;
$count = M('OrderInfo')->where($map)->count();
$where_g['status'] = 0;
$goods = M('Goods')->where($where_g)->count();
$where_sh['status'] = 0;
$shops = M('Shops')->where($where_sh)->count();
//$where_jie['money_status'] = 0;
$where_jie['status'] = array('GT', 0);
// pe($where_jie);
$order = M('OrderInfo')->where($where_jie)->count();
$data['count'] = '<a onclick="openwindowleft(\'' . U('OrderInfo/index') . '\')">新订单' . $count . '个</a>';
$data['goods'] = '<a onclick="openwindowleft(\'' . U('Audit/goods') . '\')">未审核商品' . $goods . '个</a>';
$data['shops'] = '<a onclick="openwindowleft(\'' . U('Audit/index') . '\')">未审核店铺' . $shops . '个</a>';
$data['order'] = '<a onclick="openwindowleft(\'' . U('OrderInfo/index') . '\')">订单列表' . $order . '个</a>';
$this->ajaxReturn($data);
}