<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title><?php echo C('SITE_NAME'); ?>-后台管理中心</title>

		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<link href="__CSS__/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__CSS__/font-awesome.min.css" />
		<link rel="stylesheet" href="/Common/css/snailfish.css?v=2.0.0" />
		<!--[if IE 7]>
		  <link rel="stylesheet" href="__CSS__/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->
		
		<link type="image/x-icon" href="<?php echo resize(C('SITE_ICON'),16,16); ?>" rel="icon">
		<link type="image/x-icon" href="<?php echo resize(C('SITE_ICON'),16,16); ?>" rel="bookmark">
		
		
		<link rel="stylesheet" href="__CSS__/ace.min.css" />
		<link rel="stylesheet" href="__CSS__/ace-rtl.min.css" />
		<link rel="stylesheet" href="__CSS__/ace-skins.min.css" />
		<link rel="stylesheet" href="__PUBLIC__/css/select.css" />
		
		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="__CSS__/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->

		<script src="__JS__/ace-extra.min.js"></script>

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="__JS__/html5shiv.js"></script>
		<script src="__JS__/respond.min.js"></script>
		<![endif]-->
		
		<block name="css">
			<style>
				.search-row {margin-bottom: 10px;}
			</style>
		</block>		
		
	</head>

	<body class="navbar-fixed">
		<div class="navbar navbar-default navbar-fixed-top" id="navbar">
			
			<div class="navbar-container" id="navbar-container">
				<div class="navbar-header pull-left">
					<a href="{:U('Index/index')}" class="navbar-brand">
						<small>
							<!--
							<i class="icon-leaf"></i>
							-->
							<?php echo C('SITE_NAME'); ?> 后台管理
						</small>
					</a><!-- /.brand -->
				</div><!-- /.navbar-header -->
<style>
.fa-bell:before {
    content: "\f0f3";
}
.dropdown-navbar>li:last-child>a{
text-align:left;
color:#555;
}

</style>
				<div class="navbar-header pull-right" role="navigation">
					<ul class="nav ace-nav">
						<li class="light-blue">
							<a class="dropdown-toggle" target="_blank" href="{:U('Chat/index')}" aria-expanded="true">
								<i class="ace-icon fa icon-envelope"></i>
								<span class="badge badge-important" id="mseg_count">0</span>
							</a>
						</li>	
						<li class="light-blue" style="display:none;">
							<a target="_blank" class="btn btn-primary" href="__ROOT__/?ok=1">网站前台</a>
						</li>
						<li class="light-blue" style="display:none;">
							<a href="{:U('Public/clear')}" class="btn btn-primary">清空缓存</a>
						</li>
						<li class="light-blue">
							<a href="{:U('Public/logout')}" class="btn btn-primary">退出系统</a>
						</li>
						<li class="light-blue">
							<a  href="#" >
								<?php 
								
									if (defined('ROLE') && ROLE == 'agenter' ) 
									{
										$supper_info = get_agent_logininfo();
										echo $supper_info['shopname'];
									}else{
										echo session('seller_auth.username');
									}
								?>
							</a>
						</li>
					</ul><!-- /.ace-nav -->
				</div><!-- /.navbar-header -->
			</div><!-- /.container -->
		</div>

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<div class="sidebar sidebar-fixed" id="sidebar">					
			
					{~W('Menu/menu_show')}
					

					<div class="sidebar-collapse" id="sidebar-collapse">
						<i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
					</div>

					<script type="text/javascript">
					try{ace.settings.check('sidebar' , 'collapsed')
					}catch(e){}
					
					</script>
				</div>

				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							
							<li>
								<i class="icon-home home-icon"></i>
								<a href="#">{$breadcrumb1}</a>
							</li>
							<li class="active">{$breadcrumb2}</li>
							
						</ul><!-- .breadcrumb -->

						
					</div>

					<div class="page-content">
						
							<block name="content">
								
							</block>
						
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->
				
				
			</div><!-- /.main-container-inner -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->
		<audio id="bgMusic">
			<source = src="__PUBLIC__/js/classic.mp3" type="audio/mp3">
		</audio>
		<!-- basic scripts -->

		<!--[if !IE]> -->
		<block name="jquery">
		<script src="__PUBLIC__/js/jquery/jquery-2.0.3.min.js"></script>
		<script src="__PUBLIC__/js/jquery/jquery-migrate-1.2.1.min.js"></script>
		</block>	
		<!-- <![endif]-->

		<!--[if IE]>
		<script src="__PUBLIC__/js/jquery/jquery-1.10.2.min.js"></script>
		<script src="__PUBLIC__/js/jquery/jquery-migrate-1.2.1.min.js"></script>
		<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='__JS__/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="__JS__/bootstrap.min.js"></script>
		<script src="__JS__/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<!--[if lte IE 8]>
		  <script src="__JS__/excanvas.min.js"></script>
		<![endif]-->

		<script src="__JS__/ace-elements.min.js"></script>
		<script src="__JS__/ace.min.js"></script>

		<!-- inline scripts related to this page -->
		<script src="__PUBLIC__/js/oscshop_common.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/swfobject.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/web_socket.js"></script>
		<script type="text/javascript">
			if (typeof console == "undefined") {    this.console = { log: function (msg) {  } };}
			// 如果浏览器不支持websocket，会使用这个flash自动模拟websocket协议，此过程对开发者透明
			WEB_SOCKET_SWF_LOCATION = "__PUBLIC__/swf/WebSocketMain.swf";
			// 开启flash的websocket debug
			WEB_SOCKET_DEBUG = true;
			var ws, name, client_list={};
			var domain = document.domain;
			
			// 连接服务端
			function connect() {
			   // 创建websocket
			   ws = new WebSocket("wss://mall.shiziyu888.com/wss");
			   // 当socket连接打开时，输入用户名
			   ws.onopen = onopen;
			   // 当有消息时根据消息类型显示不同信息
			   ws.onmessage = onmessage; 
			   ws.onclose = function() {
				  console.log("连接关闭，定时重连");
				  connect();
			   };
			   ws.onerror = function() {
				  console.log("出现错误");
			   };
			}

			// 连接建立时发送登录信息
			function onopen()
			{
				//document.domain
				// 登录
				var login_data = '{"type":"sellerlogin","domain":"'+domain+'"}';
				console.log("websocket握手成功，发送登录数据:"+login_data);
				ws.send(login_data);
				
				//mseg_count
				var seller_data = '{"type":"sellermsg_login","room_id":"<?php echo is_seller_login(); ?>","domain":"'+domain+'","uid":"<?php echo is_seller_login(); ?>"}';
				console.log("登录卖家消息成功:"+seller_data);
				ws.send(seller_data);
			
			}

			// 服务端发来消息时
			function onmessage(e)
			{
				console.log('ddddd');
				var data = eval("("+e.data+")");
				switch(data['type']){
					// 服务端ping客户端
					case 'ping':
						ws.send('{"type":"pong"}');
						break;
						//array('type'=>'resv_blog','blog_id'=>$blog_id);
						
					// 登录 更新用户列表
					case 'resv_blog':
						//{"type":"login","client_id":xxx,"client_name":"xxx","client_list":"[...]","time":"xxx"}
						var blog_id = data['blog_id'];
						var title = data['title'];
						
						var blog_count = $('.badge-important').html();
						
						blog_count = parseInt(blog_count) + 1;
						$('.badge-important').html(blog_count);
						
						var new_blg_html = '';
						new_blg_html= '';
						new_blg_html +='<li>';
						new_blg_html +='	<a href="/seller.php?s=/Blog/showdetail/blog_id/'+blog_id+'">';
						new_blg_html +='		<i class="btn btn-xs btn-primary fa fa-user"></i>';
						new_blg_html +='		'+title;
						new_blg_html +='	</a>';
						new_blg_html +='</li>';
						$('#notify_blog').append(new_blg_html);
						//console.log(data['client_name']+"登录成功");
						break;
					case 'seller_unread_count':
						
						if(data['count']>0)
						{
							var audio = document.getElementById("bgMusic");
							//播放(继续播放)
							audio.play();
							audio.currentTime = 0;
							audio.play();
						}
						$('#mseg_count').html(data['count']);
						break;
					break;
				}
			}

			$(function(){
				connect();
			})
		</script>
		<block name="javascript">
								
		</block>		
	</body>
</html>
