<extend name="Public/base"/>

<block name="body">

    
    <div class="cf main-place top_nav_list navtab_list">
        <h3 class="page_title">{$meta_title}</h3>
        <p class="description_text"></p>
        <div class="fr">
          <foreach name="menu_list" item="vo" >
            <if condition="$vo.name eq $menu_name">
             <a  class="tabchose"  href="{:U('lists',['menu_name' => $vo['name']])}">{$vo.title}</a>
            <else />
             <a  href="{:U('lists',['menu_name' => $vo['name']])}">{$vo.title}</a>
            </if>
          </foreach>
        </div>
    </div>
    
	<div class="cf top_nav_list">

		<div class="fl button_list">
            <a class="" href="{:U('add',['menu_name' => $menu_name])}"><span class="button_icon button_icon1"></span>新增</a>
            <a class=" ajax-post confirm" url="{:U('del',['menu_name' => $menu_name])}" target-form="ids"><span class="button_icon button_icon2"></span>删 除</a>
        </div>
	</div>

	<div class="data_list">
		<table style="text-align:center">
			<thead>
				<tr>
					<th>
                            <input class="checkbox check-all" type="checkbox">
                    </th>
					<th style="text-align:center">ID</th>
					<th style="text-align:center">菜单名称</th>
					<th style="text-align:center">菜单标题</th>
                    <th style="text-align:center">平台</th>
					<th style="text-align:center">菜单图标</th>
					<th style="text-align:center">菜单链接</th>
					<th style="text-align:center">url类型</th>
					<th style="text-align:center">跳转目标</th>
                    <th style="text-align:center">IOS链接</th>
					<th style="text-align:center">排序</th>
                    <th style="text-align:center">状态</th>
					<th style="text-align:center">操作</th>
				</tr>
			</thead>
			<tbody>
				<notempty name="list">
				<volist name="list" id="channel">
					<tr>
						<td><input class="ids" type="checkbox" name="id[]" value="{$channel.id}"></td>
						<td>{$channel.id}</td>
						<td>{$channel.name}</td>
						<td>{$channel.title}</td>
                        <td>{$channel.menu_version}</td>
						<td><img src="{$channel.icon}"></td>
						<td>{$channel.url}</td>
                        <td>{$channel.type}</td>
						<td>{$channel.act}</td>
                        <td>{$channel.ios_url}</td>
						<td>
                            <div name="sort" data-title="{$channel.game_name} 排序设置" game-id="{$channel.id}" class="tab_not_same editTab">
                                <span class="w70">{$channel.sort}</span>
                            </div>
                        </td>
                        <td>{$channel.status}</td>
						<td>
							<a title="编辑" href="{:U('edit',['id' => $channel['id'],'menu_name' => $menu_name])}">编辑</a>
							<a class="confirm ajax-get" title="删除" href="{:U('del',['id' => $channel['id'],'menu_name' => $menu_name])}">删除</a>
						</td>
					</tr>
				</volist>
				<else/>
				<td colspan="12" class="text-center">aOh! 暂时还没有内容!</td>
				</notempty>
			</tbody>
		</table>
	</div>
	<div class="page">
        {$_page|default=''}
    </div>
		
		
		<div class="common_settings">
			<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
			<form class="addShortcutIcon">
				<input type="hidden" name="title" value="{$m_title}">
				<input type="hidden" name="url" value="{$m_url}">
			</form>
			<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
		</div>
		
</block>

<block name="script">
<script src="__STATIC__/layer/layer.js"></script>
<script src="__STATIC__/layer/extend/layer.ext.js"></script>
<script type="text/javascript">
//导航高亮
highlight_subnav('{:U('SdkMenu/lists')}');

Think.setValue('row',"{:I('row',10)}");
    $(function() {
    	//点击排序
    	$('.list_sort').click(function(){
    		var url = $(this).attr('url');
    		var ids = $('.ids:checked');
    		var param = '';
    		if(ids.length > 0){
    			var str = new Array();
    			ids.each(function(){
    				str.push($(this).val());
    			});
    			param = str.join(',');
    		}

    		if(url != undefined && url != ''){
    			window.location.href = url + '/ids/' + param;
    		}
    	});
    });
    $('.editTab').click(function() {
      var that = $(this),num = $.trim(that.children().text());
      var id = that.attr('game-id');
      var names = that.attr('name');
      var title = that.attr('data-title');
      
      
      layer.prompt({title:title,formType:0},function(value,index) {
        
        if (!/^(?:0|[1-9][0-9]*)$/.test(value)) {
            updateAlert('请输入正整数','tip_error');
            setTimeout(function(){
                $('#tip').find('.tipclose').click();
            },2000);
            return false;
        }
        
        layer.close(index);
        
        var arr = {};
        arr.id = id;
        arr[names] = value;
        $.ajax({
            async: false,
            url:"{:U('edit',['menu_name' => $menu_name])}",
            type:"POST",
            dataType:"json",
            data:arr,
            success:function(result){
                if(result.status){
                    //layer.msg('修改成功',{icon: 1});
                    updateAlert('修改成功');
                    setTimeout(function(){
                        $('#tip').find('.tipclose').click();
                        window.location.reload();
                    },2000);

                }else{
                    //layer.msg('修改失败',{icon: 2});
                    updateAlert('修改失败','tip_error');
                    setTimeout(function(){
                        $('#tip').find('.tipclose').click();
                    },2000);
                }
            },
            error:function(){
                //layer.msg('服务器异常');
                updateAlert('服务器异常','tip_error');
                setTimeout(function(){
                    $('#tip').find('.tipclose').click();
                },2000);
            }
        });
        
      });
      
      return false;
    });
</script>
</block>