<!--侧滑菜单部分-->

<aside id="offCanvasSide" class="mui-off-canvas-left main-menu">
  <div id="offCanvasSideScroll" class="mui-scroll-wrapper">
    <div class="mui-scroll" id="menu-area" style="display:none">
      <div class="accInfoBox">
        <div class="accPhoto">
        <a class="" href="../Login.ashx" state="logout"><img src="../images/nophoto.jpg" root="{$stpath}" default="/Utility/images/head1.jpg"/></a>
        </div>
        <div class="accInfo">
          <div class="acc-name"> <a class="" href="../Login.ashx" state="logout">未登录 </a> 
          <a class="" href="../SelfInfo.ashx" state="login">(无名) </a></div>
          <vt:if var="mremove" value="false" compare="=">
          <span class="acc-money"> ... </span>
          <a class="mui-badge mui-badge-primary income" href="../recharge.ashx"  type="link">充值 </a>
           <vt:else />
           <span class="signature">(没有签名)</span>
          </vt:if>
        </div>
      </div>
      <ul class="mui-table-view mui-table-view-chevron mui-table-view-inverted">

          <!--如果学员没有登录-->
          <li class="mui-table-view-cell" state="logout"> <a class="mui-navigate-right" type="link" href="../login.ashx"> <span class="iconfont">&#xe614;</span>登录 </a> </li>
          <li class="mui-table-view-cell" state="logout"> <a class="mui-navigate-right" type="link" href="../Register.ashx"> <span class="iconfont">&#xe68f;</span>注册 </a> </li>
          <li class="mui-table-view-cell" state="logout"> <a class="mui-navigate-right" href="../courses.ashx"> <span class="iconfont">&#xe674;</span>课程中心 </a> </li>
          <!--如果处于登录状态-->
          <li class="mui-table-view-cell" state="login"> <a class="mui-navigate-right" href="../selfcourse.ashx"><span class="iconfont">&#xe60b;</span>我的课程 </a> </li>
          <vt:if var="mremove" value="false" compare="=">
              <li class="mui-table-view-cell" state="login"> <a class="mui-navigate-right" href="../MoneyDetails.ashx"><span class="iconfont">&#xe690;</span>资金明细 </a> </li>
          </vt:if>

          <li class="mui-table-view-cell" state="login"> <a class="mui-navigate-right" href="../CouponExchange.ashx"><span class="iconfont">&#xe88a;</span>积分兑换 </a> </li>
          <li class="mui-table-view-cell" state="login"> <a class="mui-navigate-right" href="../LearningCard.ashx"><span class="iconfont">&#xe62c;</span>学习卡</a> </li>
          <li class="mui-table-view-cell" state="login"> <a class="mui-navigate-right" href="../MyFriends.ashx"><span class="iconfont">&#xe62f;</span>我的朋友 </a> </li>
          <li class="mui-table-view-cell" state="login">
              <a class="mui-navigate-right" type="confirm"
                 title="注销登录" msg="您是否要注销当前登录？" cancel="取消" enter="注销登录"
                 href="../logout.ashx"> <span class="iconfont">&#xe61b;</span>注销登录 </a>
          </li>
          <li class="mui-table-view-cell" state="login"> </li>

          <!--其它菜单，不管是否登录都出现-->
          <li class="mui-table-view-cell"> <a class="mui-navigate-right" type="link" href="../news.ashx"> <span class="iconfont">&#xe60e;</span>资讯 </a> </li>
          <li class="mui-table-view-cell"> <a class="mui-navigate-right" type="link" href="../notices.ashx"> <span class="iconfont">&#xe67a;</span>通知 </a> </li>
          <!--<li class="mui-table-view-cell"> <a class="mui-navigate-right"type="open"  href="Message.ashx"> <span class="iconfont rowico">&#xe636;</span>问题返馈 </a> </li>-->
          <!--  <li class="mui-table-view-cell"> <a class="mui-navigate-right" type="open"  href="../Conn.cshtm"> <span class="iconfont">&#xe680;</span>联系我们</a> </li>-->
      </ul>
      
    </div>
    <!-- 上面的侧滑菜单--> 
    
  </div>
  <nav class="mui-bar mui-bar-footer" style="background-color:#333">
   <a class="mui-tab-item btn-link" type="open"  href="../Conn.cshtm" state="normal"> <span class="iconfont">&#xe680;</span>联系我们 </a> 
   
   <a class="mui-tab-item btn-about" type="close" id="closeApp" state="apicloud"> <span class="iconfont">&#xe61b;</span>退出 </a>
   <a class="mui-tab-item btn-about" type="open"  id="btnAbout" href="../about.cshtm"> <span class="iconfont">&#xe661;</span> 关于&nbsp; </a> 
   </nav>
</aside>
<script type="text/javascript" language="javascript">
    mui.init();
    //侧滑容器父节点
    var offCanvasWrapper = mui('#offCanvasWrapper');
    //主界面容器
    var offCanvasInner = offCanvasWrapper[0].querySelector('.mui-inner-wrap');
    //菜单容器
    var offCanvasSide = document.getElementById("offCanvasSide");
    if (!mui.os.android) {
        var spans = document.querySelectorAll('.android-only');
        for (var i = 0, len = spans.length; i < len; i++) {
            spans[i].style.display = "none";
        }
    }
    //移动效果是否为整体移动
    var moveTogether = false;
    //侧滑容器的class列表，增加.mui-slide-in即可实现菜单移动、主界面不动的效果；
    var classList = offCanvasWrapper[0].classList;

    /* //主界面‘显示侧滑菜单’按钮的点击事件
    document.getElementById('offCanvasShow').addEventListener('tap', function() {
    offCanvasWrapper.offCanvas('show');
    });
    //菜单界面，‘关闭侧滑菜单’按钮的点击事件
    document.getElementById('offCanvasHide').addEventListener('tap', function() {
    offCanvasWrapper.offCanvas('close');
    });*/
    //主界面和侧滑菜单界面均支持区域滚动；
    mui('#offCanvasSideScroll').scroll();
    mui('#offCanvasContentScroll').scroll();
    mui.ready(function () {
        mui('.mui-scroll-wrapper').scroll({ deceleration: 0.0005 });
    });

    //实现ios平台原生侧滑关闭页面；
    if (mui.os.plus && mui.os.ios) {
        mui.plusReady(function () { //5+ iOS暂时无法屏蔽popGesture时传递touch事件，故该demo直接屏蔽popGesture功能
            plus.webview.currentWebview().setStyle({
                'popGesture': 'none'
            });
        });
    }

    //左侧滑菜单的链接事件
    mui('body').on('tap', '#offCanvasSide a', function () {
        var type = this.getAttribute("type");
        //如果超链接，直接跳走
        if (type == "link" || type == null) document.location.href = this.href;
        //如果需要确认，则弹出确认界面，确定后仍然转向超链接
        if (type == "confirm") {
            var msg = this.getAttribute("msg");
            var tit = this.getAttribute("title");
            var href = this.getAttribute("href");
            var cancel = this.getAttribute("cancel");
            cancel = cancel == null ? "取消" : cancel;
            var enter = this.getAttribute("enter");
            enter = enter == null ? "确定" : enter;
            //弹出确认框
            mui.confirm(msg, tit, [cancel, enter], function (e) {
                if (e.index == 1) document.location.href = href;
            });
        }
        //关闭app（采用了apicloud的接口）
        if (type == "close") {
            try {
                api.closeWin();
            } catch (e) { }
        }
        if (type == "open") {
            var href = this.getAttribute("href");
            var info = this.innerHTML;
            new PageBox(info, href, 80, 80, "url").Open();
        }
    });
    //头部栏的超链接事件
    mui('body').on('tap', 'header a', function () {
        document.location.href = this.href;
    });
    //如果处于微信中
    if ($().isWeixin()) {        
    }
    //是否处在APICloud之间
    var isapicloud = window.navigator.userAgent.toLowerCase().indexOf("apicloud") > -1;
    $("nav.mui-bar-footer a").each(function () {
        var state = $(this).attr("state");
        if (state == "normal") return true;
        if (isapicloud && state != "apicloud") $(this).remove();
        if (!isapicloud && state == "apicloud") $(this).remove();
    });
</script> 

<script type="text/javascript" language="javascript">
$(function(){
	//$(".main-menu li.mui-table-view-cell[state=login]").hide();
	$.get("/Ajax/Self.ashx", function(json){
	    var data = eval("(" + json + ")");
	    data = $api.unescape(data);
		$("#menu-area").show();
		//处理侧滑菜单在是否登录状态的显示项目
		$(".main-menu li.mui-table-view-cell").each(function(index, element) {
            var state=$(this).attr("state");
			//如果是登录状态，不用于登录的菜单项将删除
			if(data.login && state=="logout")$(this).remove();
			//如果是非登录状态，
			if(!data.login && state=="login")$(this).remove();
        });
		//学员姓名
		  $(".acc-name a").each(function(index, element) {
			  var state=$(this).attr("state");
			  if(data.login && state=="logout")$(this).remove();
			  if(!data.login && state=="login")$(this).remove();
		  });
		//如果登录状态，更改头像等
		if(data.login){
			var acc=data.object;
			//学员姓名
			$(".acc-name a").text(acc.Ac_Name == "" ? "(无名)" : acc.Ac_Name);
			//学员资金
			var money=String(acc.Ac_Money);
			if(money.indexOf(".")>-1)money=money.substr(0,money.indexOf("."));
			$(".acc-money").text(money);	//钱数
			$(".signature").text(acc.Ac_Signature=="" ? "（没有签名）" : acc.Ac_Signature);	//个人签名
			$(".income").show();
			//头像
			var root=$(".accPhoto img").attr("root");
			$(".accPhoto img").attr("src",root+acc.Ac_Photo).error(function () {
				var errImg = $(this).attr("default");
				if (errImg == null) return false;
				$(this).attr("src", errImg);
			});
			$(".accPhoto a").attr("href",$(".acc-name a").attr("href"));
		}
	});
});
</script>
