Thinkphp项目结合JS消息提醒

原创
2016/04/26 10:24
阅读数 645

Thinkphp项目结合JS消息提醒

这里简略贴下项目目录结构,请根据实际情况应用

项目结构简图

案例链接下载https://pan.baidu.com/s/1kVcsmQ7

接下来就是项目实际应用代码

  • 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);
	}
展开阅读全文
打赏
1
2 收藏
分享
加载中
yeahlife博主

引用来自“宽哥ME”的评论

轮询
好的
2018/07/14 09:08
回复
举报
sfk
轮询
2016/10/10 14:46
回复
举报
更多评论
打赏
2 评论
2 收藏
1
分享
返回顶部
顶部