<title>友情链接</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
      <a lay-href="">控制台</a>
      <a><cite>问答管理</cite></a>
      <a><cite>友情链接</cite></a>
    </div>
  </div>
  
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">     
        <div class="layui-card">
          <div class="layui-card-header">友情链接</div>
          <div class="layui-card-body" pad15>
              <!-- 表单 -->      
              <div style="padding-bottom: 10px;">
                <a href="#J_view" class="layui-btn J_popup" title="添加友情链接"><i class="layui-icon layui-icon-add-circle"></i>添加</a>
                <a href="wendasns/Links/remove" class="layui-btn J_req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
              </div>      
            
              <table id="J_table_list" lay-filter="J_table_list"></table>
        
          </div>
        </div>
      </div>
    </div>
  </div>

  <script type="text/html" id="J_table_hide">
  
  {{# if(d.status == 1){}}
        显示
    {{# } else {}}
        隐藏
    {{# }}}
  </script>
  
  <script type="text/html" id="J_table_tool">
    <a href="#J_view" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="popup" title="编辑友情链接"><i class="layui-icon layui-icon-edit"></i>编辑</a>
    <a href="wendasns/links/remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
  </script>

<script>
;!function(){
      var $ = layui.$
      ,table =layui.table;

      table.render({
      elem: '#J_table_list'
      ,height: 'auto'
      ,url: '{:url('wendasns/links/list')}'
      ,page: true
      ,limit: 16
      ,cols: [[
      {type:'checkbox'}
        ,{field:'name',title:'网站名称',Width:90}
        ,{field:'url',title:'链接地扯',Width:90}
        ,{field:'status',title:'是否可见',Width:120,align:'center',templet: '#J_table_hide'}
        ,{field:'color',title:'链接颜色',Width:90,align:'center',templet:'<div><font color="{{d.color}}">{{d.color}}</font></div>'}
        ,{field:'sort',title:'排列顺序',Width:90,align:'center'}
        ,{field:'pay_status',title:'操作选项',width:180,align:'center',toolbar: '#J_table_tool'}
  
      ]]
      ,text: {
         none: '无任何链接！'
      }
  
    });

    
  }();
function setcolour(){
    layui.colorpicker.render({
      elem: '#colorpicker-select'
      ,color: '#1c97f5'
      ,done: function(color){
        layui.$('#colorpicker-form-input').val(color);
      }
    });
}
</script>

<script type="text/html" id="J_view" lay-done="setcolour()">
    <form class="layui-form" action="{:url('wendasns/links/edit')}" method="post">
      <input type="hidden" name="id" value="{{d.id||0}}">
      
              <div class="layui-form-item">
                <label class="layui-form-label">网站名称</label>
                <div class="layui-input-inline">
                  <input type="text" name="name" value="{{d.name||''}}" lay-verify="required" class="layui-input">
                </div>
              </div>
              
              <div class="layui-form-item">
                <label class="layui-form-label">链接地扯</label>
                <div class="layui-input-inline">
                  <input type="text" name="url" value="{{d.url||''}}" lay-verify="required|url" class="layui-input">
                </div>
              </div>
  
              <div class="layui-form-item">
                <label class="layui-form-label">是否可见</label>
                <div class="layui-input-block">
                  <input type="radio" name="status" value="1" title="显示" {{ typeof d.status === 'undefined' ? 'checked' : (d.status==1 ? 'checked':'')}}><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>显示</div></div>
                  <input type="radio" name="status" value="0" title="隐藏" {{ typeof d.status === 'undefined' ? '' : (d.status==0 ? 'checked':'')}}><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>隐藏</div></div>
                  
                </div>
              </div>

              <div class="layui-form-item">
                <label class="layui-form-label">链接颜色</label>
                <div class="layui-input-inline">
                  <input type="text" name="color" value="{{d.color||''}}" placeholder="请选择颜色" class="layui-input" id="colorpicker-form-input">
                </div>
                <div class="layui-inline" style="left: -11px;">
                  <div id="colorpicker-select"></div>
                </div>
              </div>

              <div class="layui-form-item">
                <label class="layui-form-label">排列顺序</label>
                <div class="layui-input-inline">
                  <input type="text" name="sort" value="{{d.sort||0}}" lay-verify="number" class="layui-input">
                </div>
              </div>
              
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="J_ajax_submit_btn"><i class="layui-icon layui-icon-ok-circle"></i>提交</button>
                </div>
              </div>
            </form>
  </script>